diff options
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r-- | services/java/com/android/server/InputMethodManagerService.java | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index c9ff595..cd920b1 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -386,6 +386,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private Locale mLastSystemLocale; private final MyPackageMonitor mMyPackageMonitor = new MyPackageMonitor(); private final IPackageManager mIPackageManager; + private boolean mInputBoundToKeyguard; class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { @@ -443,7 +444,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final int userId = getChangingUserId(); final boolean retval = userId == mSettings.getCurrentUserId(); if (DEBUG) { - Slog.d(TAG, "--- ignore this call back from a background user: " + userId); + if (!retval) { + Slog.d(TAG, "--- ignore this call back from a background user: " + userId); + } } return retval; } @@ -599,12 +602,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mHandler = new Handler(this); mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); - mCaller = new HandlerCaller(context, new HandlerCaller.Callback() { + mCaller = new HandlerCaller(context, null, new HandlerCaller.Callback() { @Override public void executeMessage(Message msg) { handleMessage(msg); } - }); + }, true /*asyncHandler*/); mWindowManagerService = windowManager; mHardKeyboardListener = new HardKeyboardListener(); @@ -657,7 +660,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } catch (RemoteException e) { Slog.w(TAG, "Couldn't get current user ID; guessing it's 0", e); } - mMyPackageMonitor.register(mContext, null, true); + mMyPackageMonitor.register(mContext, null, UserHandle.ALL, true); // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings( @@ -779,6 +782,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (!isSystemIme(imi)) { return false; } + if (imi.isAuxiliaryIme()) { + return false; + } if (imi.getIsDefaultResourceId() != 0) { try { Resources res = context.createPackageContext( @@ -802,6 +808,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (!isSystemIme(imi)) { return false; } + if (imi.isAuxiliaryIme()) { + return false; + } return containsSubtypeOf(imi, ENGLISH_LOCALE.getLanguage()); } @@ -877,10 +886,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final boolean hardKeyShown = haveHardKeyboard && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES; - final boolean isScreenLocked = mKeyguardManager != null - && mKeyguardManager.isKeyguardLocked() - && mKeyguardManager.isKeyguardSecure(); - mImeWindowVis = (!isScreenLocked && (mInputShown || hardKeyShown)) ? + final boolean isScreenLocked = + mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); + final boolean isScreenSecurelyLocked = + isScreenLocked && mKeyguardManager.isKeyguardSecure(); + final boolean inputShown = mInputShown && (!isScreenLocked || mInputBoundToKeyguard); + mImeWindowVis = (!isScreenSecurelyLocked && (inputShown || hardKeyShown)) ? (InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE) : 0; updateImeWindowStatusLocked(); } @@ -1124,6 +1135,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return mNoBinding; } + if (mCurClient == null) { + mInputBoundToKeyguard = mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); + if (DEBUG) { + Slog.v(TAG, "New bind. keyguard = " + mInputBoundToKeyguard); + } + } + if (mCurClient != cs) { // If the client is changing, we need to switch over to the new // one. @@ -1814,9 +1832,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder windowToken, int controlFlags, int softInputMode, int windowFlags, EditorInfo attribute, IInputContext inputContext) { - if (!calledFromValidUser()) { - return null; - } + // Needs to check the validity before clearing calling identity + final boolean calledFromValidUser = calledFromValidUser(); + InputBindResult res = null; long ident = Binder.clearCallingIdentity(); try { @@ -1846,6 +1864,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } catch (RemoteException e) { } + if (!calledFromValidUser) { + Slog.w(TAG, "A background user is requesting window. Hiding IME."); + Slog.w(TAG, "If you want to interect with IME, you need " + + "android.permission.INTERACT_ACROSS_USERS_FULL"); + hideCurrentInputLocked(0, null); + return null; + } + if (mCurFocusedWindow == windowToken) { Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client + " attribute=" + attribute + ", token = " + windowToken); @@ -2486,10 +2512,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub map.put(id, p); // Valid system default IMEs and IMEs that have English subtypes are enabled - // by default, unless there's a hard keyboard and the system IME was explicitly - // disabled - if ((isValidSystemDefaultIme(p, mContext) || isSystemImeThatHasEnglishSubtype(p)) - && (!haveHardKeyboard || disabledSysImes.indexOf(id) < 0)) { + // by default + if ((isValidSystemDefaultIme(p, mContext) || isSystemImeThatHasEnglishSubtype(p))) { setInputMethodEnabledLocked(id, true); } @@ -2838,6 +2862,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings .getEnabledInputMethodsAndSubtypeListLocked(); + if (DEBUG) { + Slog.d(TAG, (enabled ? "Enable " : "Disable ") + id); + } if (enabled) { for (Pair<String, ArrayList<String>> pair: enabledInputMethodsList) { if (pair.first.equals(id)) { |