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, 45 insertions, 12 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 0147b1a..6636fb7 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -49,6 +49,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.ContentObserver; +import android.inputmethodservice.InputMethodService; import android.os.Binder; import android.os.Handler; import android.os.IBinder; @@ -59,6 +60,7 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.os.SystemClock; +import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.Secure; import android.provider.Settings.SettingNotFoundException; @@ -311,6 +313,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub */ boolean mScreenOn = true; + int mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT; + int mImeWindowVis; + long mOldSystemSettingsVersion; + AlertDialog.Builder mDialogBuilder; AlertDialog mSwitchingDialog; InputMethodInfo[] mIms; @@ -430,7 +436,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Uh oh, current input method is no longer around! // Pick another one... Slog.i(TAG, "Current input method removed: " + curInputMethodId); - mStatusBar.setIMEButtonVisible(mCurToken, false); + mImeWindowVis = 0; + mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis, + mBackDisposition); if (!chooseNewDefaultIMELocked()) { changed = true; curIm = null; @@ -480,6 +488,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub handleMessage(msg); } }); + // Initialize the system settings version to undefined. + mOldSystemSettingsVersion = -1; (new MyPackageMonitor()).register(mContext, true); @@ -982,24 +992,34 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } - public void setIMEButtonVisible(IBinder token, boolean visible) { + public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { int uid = Binder.getCallingUid(); long ident = Binder.clearCallingIdentity(); try { if (token == null || mCurToken != token) { - Slog.w(TAG, "Ignoring setIMEButtonVisible of uid " + uid + " token: " + token); + Slog.w(TAG, "Ignoring setImeWindowStatus of uid " + uid + " token: " + token); return; } synchronized (mMethodMap) { - mStatusBar.setIMEButtonVisible(token, visible); + mImeWindowVis = vis; + mBackDisposition = backDisposition; + mStatusBar.setImeWindowStatus(token, vis, backDisposition); } } finally { Binder.restoreCallingIdentity(ident); } } + // TODO: Investigate and fix why are settings changes getting processed before the settings seq + // number is updated? + // TODO: Change this stuff to not rely on modifying settings for normal user interactions. void updateFromSettingsLocked() { + long newSystemSettingsVersion = getSystemSettingsVersion(); + // This is a workaround to avoid a situation that old cached value in Settings.Secure + // will be handled. + if (newSystemSettingsVersion == mOldSystemSettingsVersion) return; + // We are assuming that whoever is changing DEFAULT_INPUT_METHOD and // ENABLED_INPUT_METHODS is taking care of keeping them correctly in // sync, so we will never have a DEFAULT_INPUT_METHOD that is not @@ -1045,12 +1065,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } if (mCurMethod != null) { try { - if (mInputShown) { - // If mInputShown is false, there is no IME button on the - // system bar. - // Thus there is no need to make it invisible explicitly. - mStatusBar.setIMEButtonVisible(mCurToken, true); - } + final Configuration conf = mRes.getConfiguration(); + final boolean haveHardKeyboard = conf.keyboard + != Configuration.KEYBOARD_NOKEYS; + final boolean hardKeyShown = haveHardKeyboard + && conf.hardKeyboardHidden + != Configuration.HARDKEYBOARDHIDDEN_YES; + mImeWindowVis = (mInputShown || hardKeyShown) ? ( + InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE) + : 0; + mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis, + mBackDisposition); // If subtype is null, try to find the most applicable one from // getCurrentInputMethodSubtype. if (subtype == null) { @@ -1168,11 +1193,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (!mIWindowManager.inputMethodClientHasFocus(client)) { if (DEBUG) Slog.w(TAG, "Ignoring hideSoftInput of uid " + uid + ": " + client); - mStatusBar.setIMEButtonVisible(mCurToken, false); + mImeWindowVis = 0; + mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis, + mBackDisposition); return false; } } catch (RemoteException e) { - mStatusBar.setIMEButtonVisible(mCurToken, false); + mImeWindowVis = 0; + mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis, mBackDisposition); return false; } } @@ -1942,6 +1970,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, boolean setSubtypeOnly) { + mOldSystemSettingsVersion = getSystemSettingsVersion(); // Update the history of InputMethod and Subtype saveCurrentInputMethodAndSubtypeToHistory(); @@ -2191,6 +2220,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } + private static long getSystemSettingsVersion() { + return SystemProperties.getLong(Settings.Secure.SYS_PROP_SETTING_VERSION, 0); + } + /** * @return Return the current subtype of this input method. */ |
