diff options
| author | 2024-05-17 17:28:20 +0000 | |
|---|---|---|
| committer | 2024-05-17 17:28:20 +0000 | |
| commit | ca3755c4e742136d1bd60fef2d0dbd25ee3bcb0b (patch) | |
| tree | faf41614101e8049060abae421c42c693e9f3a65 | |
| parent | 79536d8a70d3d1cf354593c3543f69684d2faf76 (diff) | |
| parent | 5503bec515a8149212e1f86d53ca793027872579 (diff) | |
Merge "Introduce IMMS#mExperimentalConcurrentMultiUserModeEnabled" into main
2 files changed, 37 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index f882d6d4582b..f8dda6073b0b 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -282,6 +282,28 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. @NonNull private final String[] mNonPreemptibleInputMethods; + /** + * See {@link #shouldEnableExperimentalConcurrentMultiUserMode(Context)} about when set to be + * {@code true}. + */ + private final boolean mExperimentalConcurrentMultiUserModeEnabled; + + /** + * Returns {@code true} if experimental concurrent multi-user mode is enabled. + * + * <p>Currently not compatible with profiles (e.g. work profile).</p> + * + * @param context {@link Context} to be used to query + * {@link PackageManager#FEATURE_AUTOMOTIVE} + * @return {@code true} if experimental concurrent multi-user mode is enabled. + */ + static boolean shouldEnableExperimentalConcurrentMultiUserMode(@NonNull Context context) { + return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) + && UserManager.isVisibleBackgroundUsersEnabled() + && context.getResources().getBoolean(android.R.bool.config_perDisplayFocusEnabled) + && Flags.concurrentInputMethods(); + } + final Context mContext; final Resources mRes; private final Handler mHandler; @@ -1191,8 +1213,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. public static final class Lifecycle extends SystemService { private final InputMethodManagerService mService; + public Lifecycle(Context context) { - this(context, new InputMethodManagerService(context)); + this(context, new InputMethodManagerService(context, + shouldEnableExperimentalConcurrentMultiUserMode(context))); } public Lifecycle( @@ -1291,17 +1315,21 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. mHandler.post(task); } - public InputMethodManagerService(Context context) { - this(context, null, null, null); + public InputMethodManagerService(Context context, + boolean experimentalConcurrentMultiUserModeEnabled) { + this(context, experimentalConcurrentMultiUserModeEnabled, null, null, null); } @VisibleForTesting InputMethodManagerService( Context context, + boolean experimentalConcurrentMultiUserModeEnabled, @Nullable ServiceThread serviceThreadForTesting, @Nullable ServiceThread packageMonitorThreadForTesting, @Nullable IntFunction<InputMethodBindingController> bindingControllerForTesting) { synchronized (ImfLock.class) { + mExperimentalConcurrentMultiUserModeEnabled = + experimentalConcurrentMultiUserModeEnabled; mContext = context; mRes = context.getResources(); SecureSettingsWrapper.onStart(mContext); @@ -5951,6 +5979,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. mVisibilityStateComputer.dump(pw, " "); p.println(" mInFullscreenMode=" + mInFullscreenMode); p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive); + p.println(" mExperimentalConcurrentMultiUserModeEnabled=" + + mExperimentalConcurrentMultiUserModeEnabled); p.println(" ENABLE_HIDE_IME_CAPTION_BAR=" + InputMethodService.ENABLE_HIDE_IME_CAPTION_BAR); p.println(" mSettingsObserver=" + mSettingsObserver); diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java index 2bbd3c06556f..3b25cb13e66c 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java @@ -231,8 +231,10 @@ public class InputMethodManagerServiceTestBase { "immstest2", Process.THREAD_PRIORITY_FOREGROUND, true /* allowIo */); - mInputMethodManagerService = new InputMethodManagerService(mContext, mServiceThread, - mPackageMonitorThread, unusedUserId -> mMockInputMethodBindingController); + mInputMethodManagerService = new InputMethodManagerService(mContext, + InputMethodManagerService.shouldEnableExperimentalConcurrentMultiUserMode(mContext), + mServiceThread, mPackageMonitorThread, + unusedUserId -> mMockInputMethodBindingController); spyOn(mInputMethodManagerService); // Start a InputMethodManagerService.Lifecycle to publish and manage the lifecycle of |