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

Commit bce89b57 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Synchronize IMMS constructor to avoid lock contention issues

Fix: 331628477
Test: atest CtsInputMethodTestCases
Change-Id: I8e51b1ced4dc16cdca7e898885c64793665fafef
parent 27851cbb
Loading
Loading
Loading
Loading
+68 −67
Original line number Diff line number Diff line
@@ -1336,9 +1336,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            Context context,
            @Nullable ServiceThread serviceThreadForTesting,
            @Nullable InputMethodBindingController bindingControllerForTesting) {
        synchronized (ImfLock.class) {
            mContext = context;
            mRes = context.getResources();
            SecureSettingsWrapper.onStart(mContext);

            // TODO(b/196206770): Disallow I/O on this thread. Currently it's needed for loading
            // additional subtypes in switchUserOnHandlerLocked().
            final ServiceThread thread =
@@ -1391,10 +1393,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            mVisibilityApplier = new DefaultImeVisibilityApplier(this);

            mClientController = new ClientController(mPackageManagerInternal);
        synchronized (ImfLock.class) {
            mClientController.addClientControllerCallback(c -> onClientRemoved(c));
            mImeBindingState = ImeBindingState.newEmptyState();
        }

            mPreventImeStartupUnlessTextEditor = mRes.getBoolean(
                    com.android.internal.R.bool.config_preventImeStartupUnlessTextEditor);
@@ -1408,6 +1408,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    new InkWindowInitializer(), toolTypeConsumer, discardDelegationTextRunnable);
            registerDeviceListenerAndCheckStylusSupport();
        }
    }

    @GuardedBy("ImfLock.class")
    @UserIdInt