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

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

Merge "Move a call of queryInputMethodServicesInternal() to IO thread" into main

parents 3b55f324 46d10376
Loading
Loading
Loading
Loading
+18 −27
Original line number Diff line number Diff line
@@ -271,7 +271,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    private static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;

    private static final int MSG_SYSTEM_UNLOCK_USER = 5000;
    private static final int MSG_DISPATCH_ON_INPUT_METHOD_LIST_UPDATED = 5010;

    private static final int MSG_NOTIFY_IME_UID_TO_AUDIO_SERVICE = 7000;
@@ -1020,10 +1019,24 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

        @Override
        public void onUserUnlocking(@NonNull TargetUser user) {
            // Called on ActivityManager thread.
            SecureSettingsWrapper.onUserUnlocking(user.getUserIdentifier());
            mService.mHandler.obtainMessage(MSG_SYSTEM_UNLOCK_USER, user.getUserIdentifier(), 0)
                    .sendToTarget();
            // Called on ActivityManager thread. Do not block the calling thread.
            final int userId = user.getUserIdentifier();
            SecureSettingsWrapper.onUserUnlocking(userId);
            mService.mIoHandler.post(() -> {
                final var settings = queryInputMethodServicesInternal(mService.mContext, userId,
                        AdditionalSubtypeMapRepository.get(userId), DirectBootAwareness.AUTO);
                InputMethodSettingsRepository.put(userId, settings);
                synchronized (ImfLock.class) {
                    if (!mService.mSystemReady) {
                        return;
                    }
                    // We need to rebuild IMEs.
                    mService.postInputMethodSettingUpdatedLocked(false /* resetDefaultEnabledIme */,
                            userId);
                    mService.updateInputMethodsFromSettingsLocked(true /* enabledChanged */,
                            userId);
                }
            });
        }

        @Override
@@ -1074,23 +1087,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }
    }

    void onUnlockUser(@UserIdInt int userId) {
        synchronized (ImfLock.class) {
            if (DEBUG) {
                Slog.d(TAG, "onUnlockUser: userId=" + userId + " curUserId=" + mCurrentUserId);
            }
            if (!mSystemReady) {
                return;
            }
            final InputMethodSettings newSettings = queryInputMethodServicesInternal(mContext,
                    userId, AdditionalSubtypeMapRepository.get(userId), DirectBootAwareness.AUTO);
            InputMethodSettingsRepository.put(userId, newSettings);
            // We need to rebuild IMEs.
            postInputMethodSettingUpdatedLocked(false /* resetDefaultEnabledIme */, userId);
            updateInputMethodsFromSettingsLocked(true /* enabledChanged */, userId);
        }
    }

    @GuardedBy("ImfLock.class")
    void scheduleSwitchUserTaskLocked(@UserIdInt int userId,
            @Nullable IInputMethodClientInvoker clientToBeReset) {
@@ -5135,11 +5131,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    sendOnNavButtonFlagsChangedToAllImesLocked();
                }
                return true;
            case MSG_SYSTEM_UNLOCK_USER: {
                final int userId = msg.arg1;
                onUnlockUser(userId);
                return true;
            }
            case MSG_DISPATCH_ON_INPUT_METHOD_LIST_UPDATED: {
                final int userId = msg.arg1;
                final List<InputMethodInfo> imes = (List<InputMethodInfo>) msg.obj;