Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +20 −60 Original line number Diff line number Diff line Loading @@ -283,6 +283,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. final Context mContext; final Resources mRes; private final Handler mHandler; /** * TODO(b/329163064): Remove this field. */ @NonNull @MultiUserUnawareField private InputMethodSettings mSettings; Loading Loading @@ -1076,13 +1080,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. final boolean isCurrentUser = (userId == mSettings.getUserId()); final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); final InputMethodSettings settings; if (isCurrentUser) { settings = mSettings; } else { settings = queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); InputMethodInfo curIm = null; String curInputMethodId = settings.getSelectedInputMethod(); Loading Loading @@ -1740,9 +1738,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. && (!connectionless || mBindingController.supportsConnectionlessStylusHandwriting()); } //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList. //TODO(b/210039666): use cache. final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); final InputMethodInfo imi = settings.getMethodMap().get( settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting() Loading @@ -1766,9 +1762,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. private List<InputMethodInfo> getInputMethodListLocked(@UserIdInt int userId, @DirectBootAwareness int directBootAwareness, int callingUid) { final InputMethodSettings settings; if (userId == mSettings.getUserId() && directBootAwareness == DirectBootAwareness.AUTO) { settings = mSettings; if (directBootAwareness == DirectBootAwareness.AUTO) { settings = InputMethodSettingsRepository.get(userId); } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); Loading @@ -1792,7 +1787,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. methodList = mSettings.getEnabledInputMethodList(); settings = mSettings; } else { settings = queryMethodMapForUserLocked(userId); settings = InputMethodSettingsRepository.get(userId); methodList = settings.getEnabledInputMethodList(); } // filter caller's access to input methods Loading Loading @@ -1852,22 +1847,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. @GuardedBy("ImfLock.class") private List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(String imiId, boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId, int callingUid) { if (userId == mSettings.getUserId()) { final InputMethodInfo imi; String selectedMethodId = getSelectedMethodIdLocked(); if (imiId == null && selectedMethodId != null) { imi = mSettings.getMethodMap().get(selectedMethodId); } else { imi = mSettings.getMethodMap().get(imiId); } if (imi == null || !canCallerAccessInputMethod( imi.getPackageName(), callingUid, userId, mSettings)) { return Collections.emptyList(); } return mSettings.getEnabledInputMethodSubtypeList( imi, allowsImplicitlyEnabledSubtypes); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); final InputMethodInfo imi = settings.getMethodMap().get(imiId); if (imi == null) { return Collections.emptyList(); Loading Loading @@ -4060,8 +4040,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return mSettings.getLastInputMethodSubtype(); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); return settings.getLastInputMethodSubtype(); return InputMethodSettingsRepository.get(userId).getLastInputMethodSubtype(); } } Loading Loading @@ -4137,8 +4116,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. try { synchronized (ImfLock.class) { final boolean currentUser = (mSettings.getUserId() == userId); final InputMethodSettings settings = currentUser ? mSettings : queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) { return; } Loading Loading @@ -5309,8 +5287,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return getCurrentInputMethodSubtypeLocked(); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); return settings.getCurrentInputMethodSubtypeForNonCurrentUsers(); return InputMethodSettingsRepository.get(userId) .getCurrentInputMethodSubtypeForNonCurrentUsers(); } } Loading Loading @@ -5372,26 +5350,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. */ @GuardedBy("ImfLock.class") private InputMethodInfo queryDefaultInputMethodForUserIdLocked(@UserIdInt int userId) { final InputMethodSettings settings; if (userId == mSettings.getUserId()) { settings = mSettings; } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); settings = queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); return settings.getMethodMap().get(settings.getSelectedInputMethod()); } @GuardedBy("ImfLock.class") private InputMethodSettings queryMethodMapForUserLocked(@UserIdInt int userId) { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); return queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } @GuardedBy("ImfLock.class") private boolean switchToInputMethodLocked(String imeId, @UserIdInt int userId) { if (userId == mSettings.getUserId()) { Loading @@ -5403,7 +5365,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. setInputMethodLocked(imeId, NOT_A_SUBTYPE_ID); return true; } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.getMethodMap().containsKey(imeId) || !settings.getEnabledInputMethodList().contains( settings.getMethodMap().get(imeId))) { Loading Loading @@ -5543,7 +5505,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. setInputMethodEnabledLocked(imeId, enabled); return true; } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.getMethodMap().containsKey(imeId)) { return false; // IME is not found. } Loading Loading @@ -6290,7 +6252,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. previouslyEnabled = setInputMethodEnabledLocked(imeId, enabled); } } else { final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (enabled) { if (!settings.getMethodMap().containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6424,10 +6386,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. nextIme = mSettings.getSelectedInputMethod(); nextEnabledImes = mSettings.getEnabledInputMethodList(); } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); final InputMethodSettings settings = queryInputMethodServicesInternal( mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, settings.getMethodList()); Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +20 −60 Original line number Diff line number Diff line Loading @@ -283,6 +283,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. final Context mContext; final Resources mRes; private final Handler mHandler; /** * TODO(b/329163064): Remove this field. */ @NonNull @MultiUserUnawareField private InputMethodSettings mSettings; Loading Loading @@ -1076,13 +1080,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. final boolean isCurrentUser = (userId == mSettings.getUserId()); final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); final InputMethodSettings settings; if (isCurrentUser) { settings = mSettings; } else { settings = queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); InputMethodInfo curIm = null; String curInputMethodId = settings.getSelectedInputMethod(); Loading Loading @@ -1740,9 +1738,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. && (!connectionless || mBindingController.supportsConnectionlessStylusHandwriting()); } //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList. //TODO(b/210039666): use cache. final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); final InputMethodInfo imi = settings.getMethodMap().get( settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting() Loading @@ -1766,9 +1762,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. private List<InputMethodInfo> getInputMethodListLocked(@UserIdInt int userId, @DirectBootAwareness int directBootAwareness, int callingUid) { final InputMethodSettings settings; if (userId == mSettings.getUserId() && directBootAwareness == DirectBootAwareness.AUTO) { settings = mSettings; if (directBootAwareness == DirectBootAwareness.AUTO) { settings = InputMethodSettingsRepository.get(userId); } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); Loading @@ -1792,7 +1787,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. methodList = mSettings.getEnabledInputMethodList(); settings = mSettings; } else { settings = queryMethodMapForUserLocked(userId); settings = InputMethodSettingsRepository.get(userId); methodList = settings.getEnabledInputMethodList(); } // filter caller's access to input methods Loading Loading @@ -1852,22 +1847,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. @GuardedBy("ImfLock.class") private List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(String imiId, boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId, int callingUid) { if (userId == mSettings.getUserId()) { final InputMethodInfo imi; String selectedMethodId = getSelectedMethodIdLocked(); if (imiId == null && selectedMethodId != null) { imi = mSettings.getMethodMap().get(selectedMethodId); } else { imi = mSettings.getMethodMap().get(imiId); } if (imi == null || !canCallerAccessInputMethod( imi.getPackageName(), callingUid, userId, mSettings)) { return Collections.emptyList(); } return mSettings.getEnabledInputMethodSubtypeList( imi, allowsImplicitlyEnabledSubtypes); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); final InputMethodInfo imi = settings.getMethodMap().get(imiId); if (imi == null) { return Collections.emptyList(); Loading Loading @@ -4060,8 +4040,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return mSettings.getLastInputMethodSubtype(); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); return settings.getLastInputMethodSubtype(); return InputMethodSettingsRepository.get(userId).getLastInputMethodSubtype(); } } Loading Loading @@ -4137,8 +4116,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. try { synchronized (ImfLock.class) { final boolean currentUser = (mSettings.getUserId() == userId); final InputMethodSettings settings = currentUser ? mSettings : queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) { return; } Loading Loading @@ -5309,8 +5287,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return getCurrentInputMethodSubtypeLocked(); } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); return settings.getCurrentInputMethodSubtypeForNonCurrentUsers(); return InputMethodSettingsRepository.get(userId) .getCurrentInputMethodSubtypeForNonCurrentUsers(); } } Loading Loading @@ -5372,26 +5350,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. */ @GuardedBy("ImfLock.class") private InputMethodInfo queryDefaultInputMethodForUserIdLocked(@UserIdInt int userId) { final InputMethodSettings settings; if (userId == mSettings.getUserId()) { settings = mSettings; } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); settings = queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); return settings.getMethodMap().get(settings.getSelectedInputMethod()); } @GuardedBy("ImfLock.class") private InputMethodSettings queryMethodMapForUserLocked(@UserIdInt int userId) { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); return queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); } @GuardedBy("ImfLock.class") private boolean switchToInputMethodLocked(String imeId, @UserIdInt int userId) { if (userId == mSettings.getUserId()) { Loading @@ -5403,7 +5365,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. setInputMethodLocked(imeId, NOT_A_SUBTYPE_ID); return true; } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.getMethodMap().containsKey(imeId) || !settings.getEnabledInputMethodList().contains( settings.getMethodMap().get(imeId))) { Loading Loading @@ -5543,7 +5505,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. setInputMethodEnabledLocked(imeId, enabled); return true; } final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (!settings.getMethodMap().containsKey(imeId)) { return false; // IME is not found. } Loading Loading @@ -6290,7 +6252,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. previouslyEnabled = setInputMethodEnabledLocked(imeId, enabled); } } else { final InputMethodSettings settings = queryMethodMapForUserLocked(userId); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); if (enabled) { if (!settings.getMethodMap().containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6424,10 +6386,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. nextIme = mSettings.getSelectedInputMethod(); nextEnabledImes = mSettings.getEnabledInputMethodList(); } else { final AdditionalSubtypeMap additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId); final InputMethodSettings settings = queryInputMethodServicesInternal( mContext, userId, additionalSubtypeMap, DirectBootAwareness.AUTO); final InputMethodSettings settings = InputMethodSettingsRepository.get(userId); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, settings.getMethodList()); Loading