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

Commit 24e83fb5 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Antonio Kantek
Browse files

Do not trigger IME user switching in experimental multi-user mode

In the (experimental) concurrent multi-user mode, all the active IME
users should be treated equally and there should be no current IME
user any more.

This CL makes it clear that

 * Lifecycle#onUserSwitching can be ignored
 * No need to change the "current IME user" from
   IMMS#startInputOrWindowGainedFocus

Note that the semantics on work-profile when concurrent multi-user
mode is not yet defined, as both personal and work profiles are
supposed to share the same display.

The above special behaviors are guarded behind a runtime flag

  android.view.inputmethod.concurrent_input_methods.

There must be no behavior change unless it is enabled (and other
conditions defined in
IMMS#shouldEnableExperimentalConcurrentMultiUserMode() are met).

Bug: 341558132
Test: presubmit
Flag: android.view.inputmethod.concurrent_input_methods
Change-Id: I48205f8cbd5db77b46bdfd8af19b306c6150e352
parent 5fad06bf
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1243,6 +1243,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        public void onUserSwitching(@Nullable TargetUser from, @NonNull TargetUser to) {
            // Called on ActivityManager thread.
            synchronized (ImfLock.class) {
                if (mService.mExperimentalConcurrentMultiUserModeEnabled) {
                    // In concurrent multi-user mode, we in general do not rely on the concept of
                    // current user.
                    return;
                }
                mService.scheduleSwitchUserTaskLocked(to.getUserIdentifier(),
                        /* clientToBeReset= */ null);
            }
@@ -3670,7 +3675,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                final long ident = Binder.clearCallingIdentity();
                try {
                    // Verify if IMMS is in the process of switching user.
                    if (mUserSwitchHandlerTask != null) {
                    if (!mExperimentalConcurrentMultiUserModeEnabled
                            && mUserSwitchHandlerTask != null) {
                        // There is already an on-going pending user switch task.
                        final int nextUserId = mUserSwitchHandlerTask.mToUserId;
                        if (userId == nextUserId) {
@@ -3724,7 +3730,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    }

                    // Verify if caller is a background user.
                    if (userId != mCurrentUserId) {
                    if (!mExperimentalConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
                        if (ArrayUtils.contains(
                                mUserManagerInternal.getProfileIds(mCurrentUserId, false),
                                userId)) {