summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/InputMethodManagerService.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-05-22 16:30:34 -0700
committerDianne Hackborn <hackbod@google.com>2012-05-22 16:30:34 -0700
commita6e41342e2159402e33866e7145be357065d9c9a (patch)
treeac7a34d85795fbbdaa2998706906458b26758835 /services/java/com/android/server/InputMethodManagerService.java
parent2bccea2461556a525c5c65be0364b5b9404c8651 (diff)
Fix issue #5680541: onStartInputView called upon focus loss
We should tell the app that it is inactive, before unbinding. Otherwise when it is told to unbind it will see that it is still supposed to be active and immediately re-bind. Also change the calls to set the active state to go through the message dispatch path, to ensure ordering is correct. Change-Id: I246241eac8f7521f42c4c1eee7f46097337e7303
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index b97905782653..48219a4a992a 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -139,6 +139,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
static final int MSG_UNBIND_METHOD = 3000;
static final int MSG_BIND_METHOD = 3010;
+ static final int MSG_SET_ACTIVE = 3020;
static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
@@ -413,13 +414,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
// Inform the current client of the change in active status
- try {
- if (mCurClient != null && mCurClient.client != null) {
- mCurClient.client.setActive(mScreenOn);
- }
- } catch (RemoteException e) {
- Slog.w(TAG, "Got RemoteException sending 'screen on/off' notification to pid "
- + mCurClient.pid + " uid " + mCurClient.uid);
+ if (mCurClient != null && mCurClient.client != null) {
+ executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
+ MSG_SET_ACTIVE, mScreenOn ? 1 : 0, mCurClient));
}
}
}
@@ -882,17 +879,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
MSG_UNBIND_INPUT, mCurMethod));
}
}
+
+ executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
+ MSG_SET_ACTIVE, 0, mCurClient));
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
mCurClient.sessionRequested = false;
-
- // Call setActive(false) on the old client
- try {
- mCurClient.client.setActive(false);
- } catch (RemoteException e) {
- Slog.w(TAG, "Got RemoteException sending setActive(false) notification to pid "
- + mCurClient.pid + " uid " + mCurClient.uid);
- }
mCurClient = null;
hideInputMethodMenuLocked();
@@ -987,12 +979,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
// If the screen is on, inform the new client it is active
if (mScreenOn) {
- try {
- cs.client.setActive(mScreenOn);
- } catch (RemoteException e) {
- Slog.w(TAG, "Got RemoteException sending setActive notification to pid "
- + cs.pid + " uid " + cs.uid);
- }
+ executeOrSendMessage(cs.client, mCaller.obtainMessageIO(
+ MSG_SET_ACTIVE, mScreenOn ? 1 : 0, cs));
}
}
@@ -2140,6 +2128,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Slog.w(TAG, "Client died receiving input method " + args.arg2);
}
return true;
+ case MSG_SET_ACTIVE:
+ try {
+ ((ClientState)msg.obj).client.setActive(msg.arg1 != 0);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Got RemoteException sending setActive(false) notification to pid "
+ + ((ClientState)msg.obj).pid + " uid "
+ + ((ClientState)msg.obj).uid);
+ }
+ return true;
// --------------------------------------------------------------
case MSG_HARD_KEYBOARD_SWITCH_CHANGED: