summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2024-05-22 03:03:15 +0000
committer Yohei Yukawa <yukawa@google.com> 2024-05-22 03:06:35 +0000
commiteec41fccbc7925393fb928f28c4246197c20ccaf (patch)
tree9af0cc5d727ee44916c085de32eb4b688dee7408
parentcd4a8a114cdf99cf747c9b5f10c77163448f7ef0 (diff)
Revert "Conditionally initialize IMMS#mCurrentUserId with a main user"
This reverts commit cd4a8a114cdf99cf747c9b5f10c77163448f7ef0 [1]. [1]: Ie2ee161bea771c5928b504bee494813ac8e1fb7b Reason for revert: Turns out that this approach does not work as we expected. We need to find a different approach. Bug: 341558132 Flag: android.view.inputmethod.concurrent_input_methods Test: presubmit Test: atest FrameworksInputMethodSystemServerTests Change-Id: Ic8758c99854faba95b00b78dea836aea4ab6bebe
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java10
-rw-r--r--services/core/java/com/android/server/inputmethod/MultiUserUtils.java55
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java11
3 files changed, 1 insertions, 75 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 7c678432323a..9477380d408d 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1274,15 +1274,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
InputMethodSettingsRepository.initialize(mHandler, mContext);
AdditionalSubtypeMapRepository.initialize(mHandler, mContext);
- final int currentUserId = mActivityManagerInternal.getCurrentUserId();
-
- // For concurrent multi-user mode, we try to initialize mCurrentUserId with main
- // user rather than the current user when possible.
- mCurrentUserId = mExperimentalConcurrentMultiUserModeEnabled
- ? MultiUserUtils.getFirstMainUserIdOrDefault(
- mUserManagerInternal, currentUserId)
- : currentUserId;
-
+ mCurrentUserId = mActivityManagerInternal.getCurrentUserId();
@SuppressWarnings("GuardedBy") final IntFunction<InputMethodBindingController>
bindingControllerFactory = userId -> new InputMethodBindingController(userId,
InputMethodManagerService.this);
diff --git a/services/core/java/com/android/server/inputmethod/MultiUserUtils.java b/services/core/java/com/android/server/inputmethod/MultiUserUtils.java
deleted file mode 100644
index 8e188daa4209..000000000000
--- a/services/core/java/com/android/server/inputmethod/MultiUserUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.inputmethod;
-
-import android.annotation.AnyThread;
-import android.annotation.NonNull;
-import android.annotation.UserIdInt;
-
-import com.android.server.pm.UserManagerInternal;
-
-final class MultiUserUtils {
- /**
- * Not intended to be instantiated.
- */
- private MultiUserUtils() {
- }
-
- /**
- * Return the first user ID (a user has {@link android.content.pm.UserInfo#FLAG_MAIN} if
- * available). Otherwise, return the given default value.
- *
- * @param userManagerInternal {@link UserManagerInternal} to be used to query about users
- * @param defaultValue a user ID that will be returned when there is no main user
- * @return The first main user ID
- */
- @AnyThread
- @UserIdInt
- static int getFirstMainUserIdOrDefault(@NonNull UserManagerInternal userManagerInternal,
- @UserIdInt int defaultValue) {
- final int[] userIds = userManagerInternal.getUserIds();
- if (userIds != null) {
- for (int userId : userIds) {
- final var userInfo = userManagerInternal.getUserInfo(userId);
- if (userInfo.isMain()) {
- return userId;
- }
- }
- }
- return defaultValue;
- }
-}
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 5f395c567d1f..3b25cb13e66c 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
@@ -37,7 +37,6 @@ import static org.mockito.Mockito.when;
import android.app.ActivityManagerInternal;
import android.content.Context;
import android.content.pm.PackageManagerInternal;
-import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.hardware.input.IInputManager;
import android.hardware.input.InputManagerGlobal;
@@ -208,16 +207,6 @@ public class InputMethodManagerServiceTestBase {
when(mMockUserManagerInternal.getProfileIds(anyInt(), anyBoolean()))
.thenReturn(new int[] {0});
when(mMockUserManagerInternal.getUserIds()).thenReturn(new int[] {0});
- when(mMockUserManagerInternal.getUserInfo(anyInt())).thenAnswer(invocation -> {
- final int userId = invocation.getArgument(0);
- if (userId == 0) {
- new UserInfo(userId, "main",
- UserInfo.FLAG_PRIMARY | UserInfo.FLAG_MAIN | UserInfo.FLAG_SYSTEM);
- }
- // TODO(b/315348827): Update mock for multi-user scenarios.
- throw new UnsupportedOperationException(
- "Please mock #getUserInfo for userId=" + userId);
- });
when(mMockActivityManagerInternal.isSystemReady()).thenReturn(true);
when(mMockActivityManagerInternal.getCurrentUserId()).thenReturn(mCallingUserId);
when(mMockPackageManagerInternal.getPackageUid(anyString(), anyLong(), anyInt()))