Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44a859a6 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Revert "Remove UserLifecycleListener deps from SecureSettingsWrapper"

This reverts commit 1a7311fe.

Reason for revert:
While it is highly unlikely, reverting this is the fastest and easiest
way to to demonstrate that this CL is not the real culprit of the SysUI
perf regression discussed in Bug 355334507.

Once it is confirmed that this CL is not the culprit, we will re-land
this as this CL should indeed improve our memory consumption.

Bug: 352354308
Bug: 355334507
Flag: EXEMPT refactor
Test: presubmit
Change-Id: Ib4ce3cb283f5165cff0e66c9a6ddc29910abd911
parent 3a4fae41
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -997,8 +997,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    Process.THREAD_PRIORITY_FOREGROUND, true /* allowIo */);
            ioThread.start();

            SecureSettingsWrapper.setContentResolver(context.getContentResolver());

            return new InputMethodManagerService(context,
                    shouldEnableConcurrentMultiUserMode(context), thread.getLooper(),
                    Handler.createAsync(ioThread.getLooper()),
@@ -1057,7 +1055,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        public void onUserRemoved(UserInfo user) {
            // Called directly from UserManagerService. Do not block the calling thread.
            final int userId = user.id;
            SecureSettingsWrapper.onUserRemoved(userId);
            AdditionalSubtypeMapRepository.remove(userId);
            InputMethodSettingsRepository.remove(userId);
            mService.mUserDataRepository.remove(userId);
@@ -1163,6 +1160,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mConcurrentMultiUserModeEnabled = concurrentMultiUserModeEnabled;
            mContext = context;
            mRes = context.getResources();
            SecureSettingsWrapper.onStart(mContext);

            mHandler = Handler.createAsync(uiLooper, this);
            mIoHandler = ioHandler;
+24 −16
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ import android.annotation.AnyThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManagerInternal;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.UserInfo;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -318,13 +321,30 @@ final class SecureSettingsWrapper {
    }

    /**
     * Called when the system is starting.
     * Called when {@link InputMethodManagerService} is starting.
     *
     * @param contentResolver the {@link ContentResolver} to be used
     * @param context the {@link Context} to be used.
     */
    @AnyThread
    static void setContentResolver(@NonNull ContentResolver contentResolver) {
        sContentResolver = contentResolver;
    static void onStart(@NonNull Context context) {
        sContentResolver = context.getContentResolver();

        final int userId = LocalServices.getService(ActivityManagerInternal.class)
                .getCurrentUserId();
        final UserManagerInternal userManagerInternal =
                LocalServices.getService(UserManagerInternal.class);
        putOrGet(userId, createImpl(userManagerInternal, userId));

        userManagerInternal.addUserLifecycleListener(
                new UserManagerInternal.UserLifecycleListener() {
                    @Override
                    public void onUserRemoved(UserInfo user) {
                        synchronized (sMutationLock) {
                            sUserMap = sUserMap.cloneWithRemoveOrSelf(user.id);
                        }
                    }
                }
        );
    }

    /**
@@ -356,18 +376,6 @@ final class SecureSettingsWrapper {
        putOrGet(userId, readerWriter);
    }

    /**
     * Called when a user is being removed.
     *
     * @param userId the ID of the user whose storage is being removed.
     */
    @AnyThread
    static void onUserRemoved(@UserIdInt int userId) {
        synchronized (sMutationLock) {
            sUserMap = sUserMap.cloneWithRemoveOrSelf(userId);
        }
    }

    /**
     * Put the given string {@code value} to {@code key}.
     *