Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +38 −11 Original line number Original line Diff line number Diff line Loading @@ -1044,6 +1044,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub super(handler); super(handler); } } @GuardedBy("mMethodMap") public void registerContentObserverLocked(@UserIdInt int userId) { public void registerContentObserverLocked(@UserIdInt int userId) { if (mRegistered && mUserId == userId) { if (mRegistered && mUserId == userId) { return; return; Loading Loading @@ -1662,6 +1663,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mMenuController = new InputMethodMenuController(this); mMenuController = new InputMethodMenuController(this); } } @GuardedBy("mMethodMap") private void resetDefaultImeLocked(Context context) { private void resetDefaultImeLocked(Context context) { // Do not reset the default (current) IME when it is a 3rd-party IME // Do not reset the default (current) IME when it is a 3rd-party IME if (mCurMethodId != null && !mMethodMap.get(mCurMethodId).isSystem()) { if (mCurMethodId != null && !mMethodMap.get(mCurMethodId).isSystem()) { Loading Loading @@ -1712,7 +1714,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // The mSystemReady flag is set during boot phase, // The mSystemReady flag is set during boot phase, // and user switch would not happen at that time. // and user switch would not happen at that time. resetCurrentMethodAndClient(UnbindReason.SWITCH_USER); resetCurrentMethodAndClientLocked(UnbindReason.SWITCH_USER); buildInputMethodListLocked(initialUserSwitch); buildInputMethodListLocked(initialUserSwitch); if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) { if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) { // This is the first time of the user switch and // This is the first time of the user switch and Loading Loading @@ -2235,6 +2237,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) { void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) { if (mCurClient != null) { if (mCurClient != null) { if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client=" if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client=" Loading @@ -2258,7 +2261,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } private int getImeShowFlags() { @GuardedBy("mMethodMap") private int getImeShowFlagsLocked() { int flags = 0; int flags = 0; if (mShowForced) { if (mShowForced) { flags |= InputMethod.SHOW_FORCED flags |= InputMethod.SHOW_FORCED Loading @@ -2269,7 +2273,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return flags; return flags; } } private int getAppShowFlags() { @GuardedBy("mMethodMap") private int getAppShowFlagsLocked() { int flags = 0; int flags = 0; if (mShowForced) { if (mShowForced) { flags |= InputMethodManager.SHOW_FORCED; flags |= InputMethodManager.SHOW_FORCED; Loading Loading @@ -2312,7 +2317,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub startInputToken, session, mCurInputContext, mCurAttribute)); startInputToken, session, mCurInputContext, mCurAttribute)); if (mShowRequested) { if (mShowRequested) { if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); showCurrentInputLocked(mCurFocusedWindow, getAppShowFlags(), null, showCurrentInputLocked(mCurFocusedWindow, getAppShowFlagsLocked(), null, SoftInputShowHideReason.ATTACH_NEW_INPUT); SoftInputShowHideReason.ATTACH_NEW_INPUT); } } final InputMethodInfo curInputMethodInfo = mMethodMap.get(mCurId); final InputMethodInfo curInputMethodInfo = mMethodMap.get(mCurId); Loading Loading @@ -2566,6 +2571,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub channel.dispose(); channel.dispose(); } } @GuardedBy("mMethodMap") void unbindCurrentMethodLocked() { void unbindCurrentMethodLocked() { if (mVisibleBound) { if (mVisibleBound) { mContext.unbindService(mVisibleConnection); mContext.unbindService(mVisibleConnection); Loading Loading @@ -2597,12 +2603,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub clearCurMethodLocked(); clearCurMethodLocked(); } } void resetCurrentMethodAndClient(@UnbindReason int unbindClientReason) { @GuardedBy("mMethodMap") void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) { mCurMethodId = null; mCurMethodId = null; unbindCurrentMethodLocked(); unbindCurrentMethodLocked(); unbindCurrentClientLocked(unbindClientReason); unbindCurrentClientLocked(unbindClientReason); } } @GuardedBy("mMethodMap") void requestClientSessionLocked(ClientState cs) { void requestClientSessionLocked(ClientState cs) { if (!cs.sessionRequested) { if (!cs.sessionRequested) { if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs); if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs); Loading @@ -2614,12 +2622,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void clearClientSessionLocked(ClientState cs) { void clearClientSessionLocked(ClientState cs) { finishSessionLocked(cs.curSession); finishSessionLocked(cs.curSession); cs.curSession = null; cs.curSession = null; cs.sessionRequested = false; cs.sessionRequested = false; } } @GuardedBy("mMethodMap") private void finishSessionLocked(SessionState sessionState) { private void finishSessionLocked(SessionState sessionState) { if (sessionState != null) { if (sessionState != null) { if (sessionState.session != null) { if (sessionState.session != null) { Loading @@ -2638,6 +2648,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void clearCurMethodLocked() { void clearCurMethodLocked() { if (mCurMethod != null) { if (mCurMethod != null) { final int numClients = mClients.size(); final int numClients = mClients.size(); Loading Loading @@ -2721,6 +2732,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private boolean shouldShowImeSwitcherLocked(int visibility) { private boolean shouldShowImeSwitcherLocked(int visibility) { if (!mShowOngoingImeSwitcherForPhones) return false; if (!mShowOngoingImeSwitcherForPhones) return false; if (mMenuController.getSwitchingDialogLocked() != null) return false; if (mMenuController.getSwitchingDialogLocked() != null) return false; Loading Loading @@ -2784,6 +2796,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return false; return false; } } @GuardedBy("mMethodMap") private boolean isKeyguardLocked() { private boolean isKeyguardLocked() { return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); } } Loading Loading @@ -2850,11 +2863,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void updateSystemUiLocked() { void updateSystemUiLocked() { updateSystemUiLocked(mImeWindowVis, mBackDisposition); updateSystemUiLocked(mImeWindowVis, mBackDisposition); } } // Caution! This method is called in this class. Handle multi-user carefully // Caution! This method is called in this class. Handle multi-user carefully @GuardedBy("mMethodMap") private void updateSystemUiLocked(int vis, int backDisposition) { private void updateSystemUiLocked(int vis, int backDisposition) { if (mCurToken == null) { if (mCurToken == null) { return; return; Loading Loading @@ -2922,11 +2937,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void updateFromSettingsLocked(boolean enabledMayChange) { void updateFromSettingsLocked(boolean enabledMayChange) { updateInputMethodsFromSettingsLocked(enabledMayChange); updateInputMethodsFromSettingsLocked(enabledMayChange); mMenuController.updateKeyboardFromSettingsLocked(); mMenuController.updateKeyboardFromSettingsLocked(); } } @GuardedBy("mMethodMap") void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) { void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) { if (enabledMayChange) { if (enabledMayChange) { List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked(); List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked(); Loading Loading @@ -2967,11 +2984,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Slog.w(TAG, "Unknown input method from prefs: " + id, e); Slog.w(TAG, "Unknown input method from prefs: " + id, e); resetCurrentMethodAndClient(UnbindReason.SWITCH_IME_FAILED); resetCurrentMethodAndClientLocked(UnbindReason.SWITCH_IME_FAILED); } } } else { } else { // There is no longer an input method set, so stop any current one. // There is no longer an input method set, so stop any current one. resetCurrentMethodAndClient(UnbindReason.NO_IME); resetCurrentMethodAndClientLocked(UnbindReason.NO_IME); } } // Here is not the perfect place to reset the switching controller. Ideally // Here is not the perfect place to reset the switching controller. Ideally // mSwitchingController and mSettings should be able to share the same state. // mSwitchingController and mSettings should be able to share the same state. Loading @@ -2981,7 +2998,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } /* package */ void setInputMethodLocked(String id, int subtypeId) { @GuardedBy("mMethodMap") void setInputMethodLocked(String id, int subtypeId) { InputMethodInfo info = mMethodMap.get(id); InputMethodInfo info = mMethodMap.get(id); if (info == null) { if (info == null) { throw new IllegalArgumentException("Unknown id: " + id); throw new IllegalArgumentException("Unknown id: " + id); Loading Loading @@ -3129,9 +3147,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // create a placeholder token for IMS so that IMS cannot inject windows into client app. // create a placeholder token for IMS so that IMS cannot inject windows into client app. Binder showInputToken = new Binder(); Binder showInputToken = new Binder(); mShowRequestWindowMap.put(showInputToken, windowToken); mShowRequestWindowMap.put(showInputToken, windowToken); executeOrSendMessage(mCurMethod, mCaller.obtainMessageIIOOO( executeOrSendMessage(mCurMethod, mCaller.obtainMessageIIOOO(MSG_SHOW_SOFT_INPUT, MSG_SHOW_SOFT_INPUT, getImeShowFlags(), reason, mCurMethod, resultReceiver, getImeShowFlagsLocked(), reason, mCurMethod, resultReceiver, showInputToken)); showInputToken)); mInputShown = true; mInputShown = true; if (mHaveConnection && !mVisibleBound) { if (mHaveConnection && !mVisibleBound) { bindCurrentInputMethodServiceLocked( bindCurrentInputMethodServiceLocked( Loading Loading @@ -3203,6 +3220,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver, boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0 if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0 Loading Loading @@ -3324,6 +3342,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") @NonNull @NonNull private InputBindResult startInputOrWindowGainedFocusInternalLocked( private InputBindResult startInputOrWindowGainedFocusInternalLocked( @StartInputReason int startInputReason, IInputMethodClient client, @StartInputReason int startInputReason, IInputMethodClient client, Loading Loading @@ -3603,6 +3622,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return (mImeWindowVis & InputMethodService.IME_VISIBLE) != 0; return (mImeWindowVis & InputMethodService.IME_VISIBLE) != 0; } } @GuardedBy("mMethodMap") private boolean canShowInputMethodPickerLocked(IInputMethodClient client) { private boolean canShowInputMethodPickerLocked(IInputMethodClient client) { // TODO(yukawa): multi-display support. // TODO(yukawa): multi-display support. final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid(); Loading Loading @@ -4094,6 +4114,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } @GuardedBy("mMethodMap") private void setInputMethodWithSubtypeIdLocked(IBinder token, String id, int subtypeId) { private void setInputMethodWithSubtypeIdLocked(IBinder token, String id, int subtypeId) { if (token == null) { if (token == null) { if (mContext.checkCallingOrSelfPermission( if (mContext.checkCallingOrSelfPermission( Loading Loading @@ -4491,6 +4512,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub active ? 1 : 0, fullscreen ? 1 : 0, reportToImeController ? 1 : 0, 0, state)); active ? 1 : 0, fullscreen ? 1 : 0, reportToImeController ? 1 : 0, 0, state)); } } @GuardedBy("mMethodMap") private boolean chooseNewDefaultIMELocked() { private boolean chooseNewDefaultIMELocked() { final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME( final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME( mSettings.getEnabledInputMethodListLocked()); mSettings.getEnabledInputMethodListLocked()); Loading Loading @@ -4726,6 +4748,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * @param enabled {@code true} if {@code id} needs to be enabled. * @param enabled {@code true} if {@code id} needs to be enabled. * @return {@code true} if the IME was previously enabled. {@code false} otherwise. * @return {@code true} if the IME was previously enabled. {@code false} otherwise. */ */ @GuardedBy("mMethodMap") private boolean setInputMethodEnabledLocked(String id, boolean enabled) { private boolean setInputMethodEnabledLocked(String id, boolean enabled) { List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings .getEnabledInputMethodsAndSubtypeListLocked(); .getEnabledInputMethodsAndSubtypeListLocked(); Loading Loading @@ -4761,6 +4784,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, boolean setSubtypeOnly) { boolean setSubtypeOnly) { mSettings.saveCurrentInputMethodAndSubtypeToHistory(mCurMethodId, mCurrentSubtype); mSettings.saveCurrentInputMethodAndSubtypeToHistory(mCurMethodId, mCurrentSubtype); Loading @@ -4787,6 +4811,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private void resetSelectedInputMethodAndSubtypeLocked(String newDefaultIme) { private void resetSelectedInputMethodAndSubtypeLocked(String newDefaultIme) { InputMethodInfo imi = mMethodMap.get(newDefaultIme); InputMethodInfo imi = mMethodMap.get(newDefaultIme); int lastSubtypeId = NOT_A_SUBTYPE_ID; int lastSubtypeId = NOT_A_SUBTYPE_ID; Loading Loading @@ -4819,6 +4844,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") InputMethodSubtype getCurrentInputMethodSubtypeLocked() { InputMethodSubtype getCurrentInputMethodSubtypeLocked() { if (mCurMethodId == null) { if (mCurMethodId == null) { return null; return null; Loading Loading @@ -5569,6 +5595,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * @return {@code false} if it fails to enable the IME. {@code false} otherwise. * @return {@code false} if it fails to enable the IME. {@code false} otherwise. */ */ @BinderThread @BinderThread @GuardedBy("mMethodMap") private boolean handleShellCommandEnableDisableInputMethodInternalLocked( private boolean handleShellCommandEnableDisableInputMethodInternalLocked( @UserIdInt int userId, String imeId, boolean enabled, PrintWriter out, @UserIdInt int userId, String imeId, boolean enabled, PrintWriter out, PrintWriter error) { PrintWriter error) { Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +38 −11 Original line number Original line Diff line number Diff line Loading @@ -1044,6 +1044,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub super(handler); super(handler); } } @GuardedBy("mMethodMap") public void registerContentObserverLocked(@UserIdInt int userId) { public void registerContentObserverLocked(@UserIdInt int userId) { if (mRegistered && mUserId == userId) { if (mRegistered && mUserId == userId) { return; return; Loading Loading @@ -1662,6 +1663,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mMenuController = new InputMethodMenuController(this); mMenuController = new InputMethodMenuController(this); } } @GuardedBy("mMethodMap") private void resetDefaultImeLocked(Context context) { private void resetDefaultImeLocked(Context context) { // Do not reset the default (current) IME when it is a 3rd-party IME // Do not reset the default (current) IME when it is a 3rd-party IME if (mCurMethodId != null && !mMethodMap.get(mCurMethodId).isSystem()) { if (mCurMethodId != null && !mMethodMap.get(mCurMethodId).isSystem()) { Loading Loading @@ -1712,7 +1714,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // The mSystemReady flag is set during boot phase, // The mSystemReady flag is set during boot phase, // and user switch would not happen at that time. // and user switch would not happen at that time. resetCurrentMethodAndClient(UnbindReason.SWITCH_USER); resetCurrentMethodAndClientLocked(UnbindReason.SWITCH_USER); buildInputMethodListLocked(initialUserSwitch); buildInputMethodListLocked(initialUserSwitch); if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) { if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) { // This is the first time of the user switch and // This is the first time of the user switch and Loading Loading @@ -2235,6 +2237,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) { void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) { if (mCurClient != null) { if (mCurClient != null) { if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client=" if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client=" Loading @@ -2258,7 +2261,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } private int getImeShowFlags() { @GuardedBy("mMethodMap") private int getImeShowFlagsLocked() { int flags = 0; int flags = 0; if (mShowForced) { if (mShowForced) { flags |= InputMethod.SHOW_FORCED flags |= InputMethod.SHOW_FORCED Loading @@ -2269,7 +2273,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return flags; return flags; } } private int getAppShowFlags() { @GuardedBy("mMethodMap") private int getAppShowFlagsLocked() { int flags = 0; int flags = 0; if (mShowForced) { if (mShowForced) { flags |= InputMethodManager.SHOW_FORCED; flags |= InputMethodManager.SHOW_FORCED; Loading Loading @@ -2312,7 +2317,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub startInputToken, session, mCurInputContext, mCurAttribute)); startInputToken, session, mCurInputContext, mCurAttribute)); if (mShowRequested) { if (mShowRequested) { if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); showCurrentInputLocked(mCurFocusedWindow, getAppShowFlags(), null, showCurrentInputLocked(mCurFocusedWindow, getAppShowFlagsLocked(), null, SoftInputShowHideReason.ATTACH_NEW_INPUT); SoftInputShowHideReason.ATTACH_NEW_INPUT); } } final InputMethodInfo curInputMethodInfo = mMethodMap.get(mCurId); final InputMethodInfo curInputMethodInfo = mMethodMap.get(mCurId); Loading Loading @@ -2566,6 +2571,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub channel.dispose(); channel.dispose(); } } @GuardedBy("mMethodMap") void unbindCurrentMethodLocked() { void unbindCurrentMethodLocked() { if (mVisibleBound) { if (mVisibleBound) { mContext.unbindService(mVisibleConnection); mContext.unbindService(mVisibleConnection); Loading Loading @@ -2597,12 +2603,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub clearCurMethodLocked(); clearCurMethodLocked(); } } void resetCurrentMethodAndClient(@UnbindReason int unbindClientReason) { @GuardedBy("mMethodMap") void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) { mCurMethodId = null; mCurMethodId = null; unbindCurrentMethodLocked(); unbindCurrentMethodLocked(); unbindCurrentClientLocked(unbindClientReason); unbindCurrentClientLocked(unbindClientReason); } } @GuardedBy("mMethodMap") void requestClientSessionLocked(ClientState cs) { void requestClientSessionLocked(ClientState cs) { if (!cs.sessionRequested) { if (!cs.sessionRequested) { if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs); if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs); Loading @@ -2614,12 +2622,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void clearClientSessionLocked(ClientState cs) { void clearClientSessionLocked(ClientState cs) { finishSessionLocked(cs.curSession); finishSessionLocked(cs.curSession); cs.curSession = null; cs.curSession = null; cs.sessionRequested = false; cs.sessionRequested = false; } } @GuardedBy("mMethodMap") private void finishSessionLocked(SessionState sessionState) { private void finishSessionLocked(SessionState sessionState) { if (sessionState != null) { if (sessionState != null) { if (sessionState.session != null) { if (sessionState.session != null) { Loading @@ -2638,6 +2648,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void clearCurMethodLocked() { void clearCurMethodLocked() { if (mCurMethod != null) { if (mCurMethod != null) { final int numClients = mClients.size(); final int numClients = mClients.size(); Loading Loading @@ -2721,6 +2732,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private boolean shouldShowImeSwitcherLocked(int visibility) { private boolean shouldShowImeSwitcherLocked(int visibility) { if (!mShowOngoingImeSwitcherForPhones) return false; if (!mShowOngoingImeSwitcherForPhones) return false; if (mMenuController.getSwitchingDialogLocked() != null) return false; if (mMenuController.getSwitchingDialogLocked() != null) return false; Loading Loading @@ -2784,6 +2796,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return false; return false; } } @GuardedBy("mMethodMap") private boolean isKeyguardLocked() { private boolean isKeyguardLocked() { return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); } } Loading Loading @@ -2850,11 +2863,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void updateSystemUiLocked() { void updateSystemUiLocked() { updateSystemUiLocked(mImeWindowVis, mBackDisposition); updateSystemUiLocked(mImeWindowVis, mBackDisposition); } } // Caution! This method is called in this class. Handle multi-user carefully // Caution! This method is called in this class. Handle multi-user carefully @GuardedBy("mMethodMap") private void updateSystemUiLocked(int vis, int backDisposition) { private void updateSystemUiLocked(int vis, int backDisposition) { if (mCurToken == null) { if (mCurToken == null) { return; return; Loading Loading @@ -2922,11 +2937,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") void updateFromSettingsLocked(boolean enabledMayChange) { void updateFromSettingsLocked(boolean enabledMayChange) { updateInputMethodsFromSettingsLocked(enabledMayChange); updateInputMethodsFromSettingsLocked(enabledMayChange); mMenuController.updateKeyboardFromSettingsLocked(); mMenuController.updateKeyboardFromSettingsLocked(); } } @GuardedBy("mMethodMap") void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) { void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) { if (enabledMayChange) { if (enabledMayChange) { List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked(); List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked(); Loading Loading @@ -2967,11 +2984,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Slog.w(TAG, "Unknown input method from prefs: " + id, e); Slog.w(TAG, "Unknown input method from prefs: " + id, e); resetCurrentMethodAndClient(UnbindReason.SWITCH_IME_FAILED); resetCurrentMethodAndClientLocked(UnbindReason.SWITCH_IME_FAILED); } } } else { } else { // There is no longer an input method set, so stop any current one. // There is no longer an input method set, so stop any current one. resetCurrentMethodAndClient(UnbindReason.NO_IME); resetCurrentMethodAndClientLocked(UnbindReason.NO_IME); } } // Here is not the perfect place to reset the switching controller. Ideally // Here is not the perfect place to reset the switching controller. Ideally // mSwitchingController and mSettings should be able to share the same state. // mSwitchingController and mSettings should be able to share the same state. Loading @@ -2981,7 +2998,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } /* package */ void setInputMethodLocked(String id, int subtypeId) { @GuardedBy("mMethodMap") void setInputMethodLocked(String id, int subtypeId) { InputMethodInfo info = mMethodMap.get(id); InputMethodInfo info = mMethodMap.get(id); if (info == null) { if (info == null) { throw new IllegalArgumentException("Unknown id: " + id); throw new IllegalArgumentException("Unknown id: " + id); Loading Loading @@ -3129,9 +3147,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // create a placeholder token for IMS so that IMS cannot inject windows into client app. // create a placeholder token for IMS so that IMS cannot inject windows into client app. Binder showInputToken = new Binder(); Binder showInputToken = new Binder(); mShowRequestWindowMap.put(showInputToken, windowToken); mShowRequestWindowMap.put(showInputToken, windowToken); executeOrSendMessage(mCurMethod, mCaller.obtainMessageIIOOO( executeOrSendMessage(mCurMethod, mCaller.obtainMessageIIOOO(MSG_SHOW_SOFT_INPUT, MSG_SHOW_SOFT_INPUT, getImeShowFlags(), reason, mCurMethod, resultReceiver, getImeShowFlagsLocked(), reason, mCurMethod, resultReceiver, showInputToken)); showInputToken)); mInputShown = true; mInputShown = true; if (mHaveConnection && !mVisibleBound) { if (mHaveConnection && !mVisibleBound) { bindCurrentInputMethodServiceLocked( bindCurrentInputMethodServiceLocked( Loading Loading @@ -3203,6 +3220,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver, boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0 if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0 Loading Loading @@ -3324,6 +3342,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") @NonNull @NonNull private InputBindResult startInputOrWindowGainedFocusInternalLocked( private InputBindResult startInputOrWindowGainedFocusInternalLocked( @StartInputReason int startInputReason, IInputMethodClient client, @StartInputReason int startInputReason, IInputMethodClient client, Loading Loading @@ -3603,6 +3622,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return (mImeWindowVis & InputMethodService.IME_VISIBLE) != 0; return (mImeWindowVis & InputMethodService.IME_VISIBLE) != 0; } } @GuardedBy("mMethodMap") private boolean canShowInputMethodPickerLocked(IInputMethodClient client) { private boolean canShowInputMethodPickerLocked(IInputMethodClient client) { // TODO(yukawa): multi-display support. // TODO(yukawa): multi-display support. final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid(); Loading Loading @@ -4094,6 +4114,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } @GuardedBy("mMethodMap") private void setInputMethodWithSubtypeIdLocked(IBinder token, String id, int subtypeId) { private void setInputMethodWithSubtypeIdLocked(IBinder token, String id, int subtypeId) { if (token == null) { if (token == null) { if (mContext.checkCallingOrSelfPermission( if (mContext.checkCallingOrSelfPermission( Loading Loading @@ -4491,6 +4512,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub active ? 1 : 0, fullscreen ? 1 : 0, reportToImeController ? 1 : 0, 0, state)); active ? 1 : 0, fullscreen ? 1 : 0, reportToImeController ? 1 : 0, 0, state)); } } @GuardedBy("mMethodMap") private boolean chooseNewDefaultIMELocked() { private boolean chooseNewDefaultIMELocked() { final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME( final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME( mSettings.getEnabledInputMethodListLocked()); mSettings.getEnabledInputMethodListLocked()); Loading Loading @@ -4726,6 +4748,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * @param enabled {@code true} if {@code id} needs to be enabled. * @param enabled {@code true} if {@code id} needs to be enabled. * @return {@code true} if the IME was previously enabled. {@code false} otherwise. * @return {@code true} if the IME was previously enabled. {@code false} otherwise. */ */ @GuardedBy("mMethodMap") private boolean setInputMethodEnabledLocked(String id, boolean enabled) { private boolean setInputMethodEnabledLocked(String id, boolean enabled) { List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings .getEnabledInputMethodsAndSubtypeListLocked(); .getEnabledInputMethodsAndSubtypeListLocked(); Loading Loading @@ -4761,6 +4784,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, boolean setSubtypeOnly) { boolean setSubtypeOnly) { mSettings.saveCurrentInputMethodAndSubtypeToHistory(mCurMethodId, mCurrentSubtype); mSettings.saveCurrentInputMethodAndSubtypeToHistory(mCurMethodId, mCurrentSubtype); Loading @@ -4787,6 +4811,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") private void resetSelectedInputMethodAndSubtypeLocked(String newDefaultIme) { private void resetSelectedInputMethodAndSubtypeLocked(String newDefaultIme) { InputMethodInfo imi = mMethodMap.get(newDefaultIme); InputMethodInfo imi = mMethodMap.get(newDefaultIme); int lastSubtypeId = NOT_A_SUBTYPE_ID; int lastSubtypeId = NOT_A_SUBTYPE_ID; Loading Loading @@ -4819,6 +4844,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } @GuardedBy("mMethodMap") InputMethodSubtype getCurrentInputMethodSubtypeLocked() { InputMethodSubtype getCurrentInputMethodSubtypeLocked() { if (mCurMethodId == null) { if (mCurMethodId == null) { return null; return null; Loading Loading @@ -5569,6 +5595,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * @return {@code false} if it fails to enable the IME. {@code false} otherwise. * @return {@code false} if it fails to enable the IME. {@code false} otherwise. */ */ @BinderThread @BinderThread @GuardedBy("mMethodMap") private boolean handleShellCommandEnableDisableInputMethodInternalLocked( private boolean handleShellCommandEnableDisableInputMethodInternalLocked( @UserIdInt int userId, String imeId, boolean enabled, PrintWriter out, @UserIdInt int userId, String imeId, boolean enabled, PrintWriter out, PrintWriter error) { PrintWriter error) { Loading