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

Commit a37ab237 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Remove unused InputMethodSettings#mUserAwareContext" into main

parents a9aedbf0 e851d0ae
Loading
Loading
Loading
Loading
+14 −22
Original line number Diff line number Diff line
@@ -1689,7 +1689,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        mLastSwitchUserId = userId;

        // mSettings should be created before buildInputMethodListLocked
        mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady);
        mSettings = new InputMethodSettings(mMethodMap, userId, !mSystemReady);

        AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId);
        mSwitchingController =
@@ -2019,8 +2019,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList.
            //TODO(b/210039666): use cache.
            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                    userId, true);
            final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
            final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod());
            return imi != null && imi.supportsStylusHandwriting();
        }
@@ -2056,7 +2055,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
            queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
                    methodList, directBootAwareness);
            settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */);
            settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */);
        }
        // filter caller's access to input methods
        methodList.removeIf(imi ->
@@ -2074,7 +2073,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            settings = mSettings;
        } else {
            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
            settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */);
            settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */);
            methodList = settings.getEnabledInputMethodListLocked();
        }
        // filter caller's access to input methods
@@ -2154,8 +2153,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        if (imi == null) {
            return Collections.emptyList();
        }
        final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
                true);
        final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
        if (!canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)) {
            return Collections.emptyList();
        }
@@ -4132,8 +4130,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            }

            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                    userId, false);
            final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
            return settings.getLastInputMethodSubtypeLocked();
        }
    }
@@ -4185,8 +4182,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
            queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
                    methodList, DirectBootAwareness.AUTO);
            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                    userId, false);
            final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
            settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap,
                    mPackageManagerInternal, callingUid);
        }
@@ -4215,7 +4211,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                final boolean currentUser = (mSettings.getCurrentUserId() == userId);
                final InputMethodSettings settings = currentUser
                        ? mSettings
                        : new InputMethodSettings(mContext, queryMethodMapForUser(userId), userId,
                        : new InputMethodSettings(queryMethodMapForUser(userId), userId,
                                !mUserManagerInternal.isUserUnlocked(userId));
                if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) {
                    return;
@@ -5365,8 +5361,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            }

            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                    userId, false);
            final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
            return settings.getCurrentInputMethodSubtypeForNonCurrentUsers();
        }
    }
@@ -5439,8 +5434,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
        queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
                methodList, DirectBootAwareness.AUTO);
        InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
                true /* copyOnWrite */);
        InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
        return methodMap.get(settings.getSelectedInputMethod());
    }

@@ -5467,8 +5461,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            return true;
        }
        final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
        final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
                false);
        final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
        if (!methodMap.containsKey(imeId)
                || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) {
            return false; // IME is not found or not enabled.
@@ -5607,7 +5600,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    return true;
                }
                final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
                final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                final InputMethodSettings settings = new InputMethodSettings(methodMap,
                        userId, false);
                if (!methodMap.containsKey(imeId)) {
                    return false; // IME is not found.
@@ -6331,8 +6324,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            }
        } else {
            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                    userId, false);
            final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
            if (enabled) {
                if (!methodMap.containsKey(imeId)) {
                    failedToEnableUnknownIme = true;
@@ -6476,7 +6468,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                        AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
                        queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap,
                                methodMap, methodList, DirectBootAwareness.AUTO);
                        final InputMethodSettings settings = new InputMethodSettings(mContext,
                        final InputMethodSettings settings = new InputMethodSettings(
                                methodMap, userId, false);

                        nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext,
+1 −14
Original line number Diff line number Diff line
@@ -208,8 +208,6 @@ final class InputMethodUtils {
     */
    @UserHandleAware
    public static class InputMethodSettings {
        @NonNull
        private Context mUserAwareContext;
        private final ArrayMap<String, InputMethodInfo> mMethodMap;

        private boolean mCopyOnWrite = false;
@@ -253,17 +251,9 @@ final class InputMethodUtils {
            return imsList;
        }

        private void initContentWithUserContext(@NonNull Context context, @UserIdInt int userId) {
            mUserAwareContext = context.getUserId() == userId
                    ? context
                    : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */);
        }

        InputMethodSettings(@NonNull Context context,
                ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId,
        InputMethodSettings(ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId,
                boolean copyOnWrite) {
            mMethodMap = methodMap;
            initContentWithUserContext(context, userId);
            switchCurrentUser(userId, copyOnWrite);
        }

@@ -282,9 +272,6 @@ final class InputMethodUtils {
            if (mCurrentUserId != userId || mCopyOnWrite != copyOnWrite) {
                mEnabledInputMethodsStrCache = "";
            }
            if (mUserAwareContext.getUserId() != userId) {
                initContentWithUserContext(mUserAwareContext, userId);
            }
            mCurrentUserId = userId;
            mCopyOnWrite = copyOnWrite;
        }
+1 −1
Original line number Diff line number Diff line
@@ -1234,7 +1234,7 @@ public class InputMethodUtilsTest {
        // Init InputMethodSettings for the owner user (userId=0), verify calls can get the
        // corresponding user's context, contentResolver and the resources configuration.
        InputMethodUtils.InputMethodSettings settings = new InputMethodUtils.InputMethodSettings(
                ownerUserContext, methodMap, 0 /* userId */, true);
                methodMap, 0 /* userId */, true);
        assertEquals(0, settings.getCurrentUserId());

        settings.isShowImeWithHardKeyboardEnabled();