Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +1 −9 Original line number Diff line number Diff line Loading @@ -1273,15 +1273,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); Loading services/core/java/com/android/server/inputmethod/MultiUserUtils.javadeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /* * 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; } } services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +0 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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())) Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +1 −9 Original line number Diff line number Diff line Loading @@ -1273,15 +1273,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); Loading
services/core/java/com/android/server/inputmethod/MultiUserUtils.javadeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /* * 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; } }
services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +0 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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())) Loading