Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +8 −38 Original line number Diff line number Diff line Loading @@ -1187,23 +1187,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } /** * {@link BroadcastReceiver} that is intended to listen to broadcasts sent to the system user * only. */ private final class ImmsBroadcastReceiverForSystemUser extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_USER_ADDED.equals(action) || Intent.ACTION_USER_REMOVED.equals(action)) { updateCurrentProfileIds(); } else { Slog.w(TAG, "Unexpected intent " + intent); } } } /** * {@link BroadcastReceiver} that is intended to listen to broadcasts sent to all the users. */ Loading Loading @@ -1708,7 +1691,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); updateCurrentProfileIds(); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); mSwitchingController = InputMethodSubtypeSwitchingController.createInstanceLocked(mSettings, context); Loading Loading @@ -1826,7 +1808,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final boolean useCopyOnWriteSettings = !mSystemReady || !mUserManagerInternal.isUserUnlockingOrUnlocked(newUserId); mSettings.switchCurrentUser(newUserId, useCopyOnWriteSettings); updateCurrentProfileIds(); // Additional subtypes should be reset when the user is changed AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, newUserId); final String defaultImiId = mSettings.getSelectedInputMethod(); Loading Loading @@ -1877,12 +1858,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } void updateCurrentProfileIds() { mSettings.setCurrentProfileIds( mUserManagerInternal.getProfileIds(mSettings.getCurrentUserId(), false /* enabledOnly */)); } /** * TODO(b/32343335): The entire systemRunning() method needs to be revisited. */ Loading Loading @@ -1929,12 +1904,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mMyPackageMonitor.register(mContext, null, UserHandle.ALL, true); mSettingsObserver.registerContentObserverLocked(currentUserId); final IntentFilter broadcastFilterForSystemUser = new IntentFilter(); broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_ADDED); broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(new ImmsBroadcastReceiverForSystemUser(), broadcastFilterForSystemUser); final IntentFilter broadcastFilterForAllUsers = new IntentFilter(); broadcastFilterForAllUsers.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); mContext.registerReceiverAsUser(new ImmsBroadcastReceiverForAllUsers(), Loading Loading @@ -3796,8 +3765,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mVisibilityStateComputer.mShowForced = false; } final int currentUserId = mSettings.getCurrentUserId(); if (userId != currentUserId) { if (ArrayUtils.contains( mUserManagerInternal.getProfileIds(currentUserId, false), userId)) { // cross-profile access is always allowed here to allow profile-switching. if (!mSettings.isCurrentProfile(userId)) { scheduleSwitchUserTaskLocked(userId, cs.mClient); return InputBindResult.USER_SWITCHING; } Slog.w(TAG, "A background user is requesting window. Hiding IME."); Slog.w(TAG, "If you need to impersonate a foreground user/profile from" + " a background user, use EditorInfo.targetInputMethodUser with" Loading @@ -3807,11 +3782,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return InputBindResult.INVALID_USER; } if (userId != mSettings.getCurrentUserId()) { scheduleSwitchUserTaskLocked(userId, cs.mClient); return InputBindResult.USER_SWITCHING; } final boolean sameWindowFocused = mCurFocusedWindow == windowToken; final boolean isTextEditor = (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0; final boolean startInputByWinGainedFocus = Loading services/core/java/com/android/server/inputmethod/InputMethodUtils.java +0 −18 Original line number Diff line number Diff line Loading @@ -43,14 +43,12 @@ import android.view.textservice.SpellCheckerInfo; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.util.ArrayUtils; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.textservices.TextServicesManagerInternal; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Predicate; Loading Loading @@ -219,7 +217,6 @@ final class InputMethodUtils { private String mEnabledInputMethodsStrCache = ""; @UserIdInt private int mCurrentUserId; private int[] mCurrentProfileIds = new int[0]; private static void buildEnabledInputMethodsSettingString( StringBuilder builder, Pair<String, ArrayList<String>> ime) { Loading Loading @@ -284,14 +281,12 @@ final class InputMethodUtils { } if (mCurrentUserId != userId || mCopyOnWrite != copyOnWrite) { mEnabledInputMethodsStrCache = ""; // TODO: mCurrentProfileIds should be cleared here. } if (mUserAwareContext.getUserId() != userId) { initContentWithUserContext(mUserAwareContext, userId); } mCurrentUserId = userId; mCopyOnWrite = copyOnWrite; // TODO: mCurrentProfileIds should be updated here. } private void putString(@NonNull String key, @Nullable String str) { Loading Loading @@ -319,18 +314,6 @@ final class InputMethodUtils { return SecureSettingsWrapper.getBoolean(key, defaultValue, mCurrentUserId); } public void setCurrentProfileIds(int[] currentProfileIds) { synchronized (this) { mCurrentProfileIds = currentProfileIds; } } public boolean isCurrentProfile(int userId) { synchronized (this) { return ArrayUtils.contains(mCurrentProfileIds, userId); } } ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() { return getEnabledInputMethodListWithFilterLocked(null /* matchingCondition */); } Loading Loading @@ -905,7 +888,6 @@ final class InputMethodUtils { public void dumpLocked(final Printer pw, final String prefix) { pw.println(prefix + "mCurrentUserId=" + mCurrentUserId); pw.println(prefix + "mCurrentProfileIds=" + Arrays.toString(mCurrentProfileIds)); pw.println(prefix + "mCopyOnWrite=" + mCopyOnWrite); pw.println(prefix + "mEnabledInputMethodsStrCache=" + mEnabledInputMethodsStrCache); } Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +8 −38 Original line number Diff line number Diff line Loading @@ -1187,23 +1187,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } /** * {@link BroadcastReceiver} that is intended to listen to broadcasts sent to the system user * only. */ private final class ImmsBroadcastReceiverForSystemUser extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_USER_ADDED.equals(action) || Intent.ACTION_USER_REMOVED.equals(action)) { updateCurrentProfileIds(); } else { Slog.w(TAG, "Unexpected intent " + intent); } } } /** * {@link BroadcastReceiver} that is intended to listen to broadcasts sent to all the users. */ Loading Loading @@ -1708,7 +1691,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); updateCurrentProfileIds(); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); mSwitchingController = InputMethodSubtypeSwitchingController.createInstanceLocked(mSettings, context); Loading Loading @@ -1826,7 +1808,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final boolean useCopyOnWriteSettings = !mSystemReady || !mUserManagerInternal.isUserUnlockingOrUnlocked(newUserId); mSettings.switchCurrentUser(newUserId, useCopyOnWriteSettings); updateCurrentProfileIds(); // Additional subtypes should be reset when the user is changed AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, newUserId); final String defaultImiId = mSettings.getSelectedInputMethod(); Loading Loading @@ -1877,12 +1858,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } void updateCurrentProfileIds() { mSettings.setCurrentProfileIds( mUserManagerInternal.getProfileIds(mSettings.getCurrentUserId(), false /* enabledOnly */)); } /** * TODO(b/32343335): The entire systemRunning() method needs to be revisited. */ Loading Loading @@ -1929,12 +1904,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mMyPackageMonitor.register(mContext, null, UserHandle.ALL, true); mSettingsObserver.registerContentObserverLocked(currentUserId); final IntentFilter broadcastFilterForSystemUser = new IntentFilter(); broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_ADDED); broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(new ImmsBroadcastReceiverForSystemUser(), broadcastFilterForSystemUser); final IntentFilter broadcastFilterForAllUsers = new IntentFilter(); broadcastFilterForAllUsers.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); mContext.registerReceiverAsUser(new ImmsBroadcastReceiverForAllUsers(), Loading Loading @@ -3796,8 +3765,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mVisibilityStateComputer.mShowForced = false; } final int currentUserId = mSettings.getCurrentUserId(); if (userId != currentUserId) { if (ArrayUtils.contains( mUserManagerInternal.getProfileIds(currentUserId, false), userId)) { // cross-profile access is always allowed here to allow profile-switching. if (!mSettings.isCurrentProfile(userId)) { scheduleSwitchUserTaskLocked(userId, cs.mClient); return InputBindResult.USER_SWITCHING; } Slog.w(TAG, "A background user is requesting window. Hiding IME."); Slog.w(TAG, "If you need to impersonate a foreground user/profile from" + " a background user, use EditorInfo.targetInputMethodUser with" Loading @@ -3807,11 +3782,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return InputBindResult.INVALID_USER; } if (userId != mSettings.getCurrentUserId()) { scheduleSwitchUserTaskLocked(userId, cs.mClient); return InputBindResult.USER_SWITCHING; } final boolean sameWindowFocused = mCurFocusedWindow == windowToken; final boolean isTextEditor = (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0; final boolean startInputByWinGainedFocus = Loading
services/core/java/com/android/server/inputmethod/InputMethodUtils.java +0 −18 Original line number Diff line number Diff line Loading @@ -43,14 +43,12 @@ import android.view.textservice.SpellCheckerInfo; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.util.ArrayUtils; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.textservices.TextServicesManagerInternal; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Predicate; Loading Loading @@ -219,7 +217,6 @@ final class InputMethodUtils { private String mEnabledInputMethodsStrCache = ""; @UserIdInt private int mCurrentUserId; private int[] mCurrentProfileIds = new int[0]; private static void buildEnabledInputMethodsSettingString( StringBuilder builder, Pair<String, ArrayList<String>> ime) { Loading Loading @@ -284,14 +281,12 @@ final class InputMethodUtils { } if (mCurrentUserId != userId || mCopyOnWrite != copyOnWrite) { mEnabledInputMethodsStrCache = ""; // TODO: mCurrentProfileIds should be cleared here. } if (mUserAwareContext.getUserId() != userId) { initContentWithUserContext(mUserAwareContext, userId); } mCurrentUserId = userId; mCopyOnWrite = copyOnWrite; // TODO: mCurrentProfileIds should be updated here. } private void putString(@NonNull String key, @Nullable String str) { Loading Loading @@ -319,18 +314,6 @@ final class InputMethodUtils { return SecureSettingsWrapper.getBoolean(key, defaultValue, mCurrentUserId); } public void setCurrentProfileIds(int[] currentProfileIds) { synchronized (this) { mCurrentProfileIds = currentProfileIds; } } public boolean isCurrentProfile(int userId) { synchronized (this) { return ArrayUtils.contains(mCurrentProfileIds, userId); } } ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() { return getEnabledInputMethodListWithFilterLocked(null /* matchingCondition */); } Loading Loading @@ -905,7 +888,6 @@ final class InputMethodUtils { public void dumpLocked(final Printer pw, final String prefix) { pw.println(prefix + "mCurrentUserId=" + mCurrentUserId); pw.println(prefix + "mCurrentProfileIds=" + Arrays.toString(mCurrentProfileIds)); pw.println(prefix + "mCopyOnWrite=" + mCopyOnWrite); pw.println(prefix + "mEnabledInputMethodsStrCache=" + mEnabledInputMethodsStrCache); } Loading