summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/InputMethodManagerService.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-02-24 15:44:55 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-02-24 15:44:55 -0800
commit0aec3ea6defdee1ee4a9c0d6c4a3c13df3e7b812 (patch)
tree91e2e56e8b3a4da1ea037fded1f9c7078bae6d99 /services/java/com/android/server/InputMethodManagerService.java
parent7b49b4bea8090bb8e5015225eb05686d3676205c (diff)
parent911b505f11c719906985f169a4f45930bdec8695 (diff)
downloadframeworks_base-0aec3ea6defdee1ee4a9c0d6c4a3c13df3e7b812.zip
frameworks_base-0aec3ea6defdee1ee4a9c0d6c4a3c13df3e7b812.tar.gz
frameworks_base-0aec3ea6defdee1ee4a9c0d6c4a3c13df3e7b812.tar.bz2
am 911b505f: am dc5fa185: am 133dc2d7: Merge "Fix issue #6048808: sometimes auto-correct is inactive" into ics-mr1
* commit '911b505f11c719906985f169a4f45930bdec8695': Fix issue #6048808: sometimes auto-correct is inactive
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java111
1 files changed, 78 insertions, 33 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 86669f8..c705646 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -786,7 +786,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return flags;
}
- InputBindResult attachNewInputLocked(boolean initial, boolean needResult) {
+ InputBindResult attachNewInputLocked(boolean initial) {
if (!mBoundToMethod) {
executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
MSG_BIND_INPUT, mCurMethod, mCurClient.binding));
@@ -804,14 +804,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (DEBUG) Slog.v(TAG, "Attach new input asks to show input");
showCurrentInputLocked(getAppShowFlags(), null);
}
- return needResult
- ? new InputBindResult(session.session, mCurId, mCurSeq)
- : null;
+ return new InputBindResult(session.session, mCurId, mCurSeq);
}
InputBindResult startInputLocked(IInputMethodClient client,
- IInputContext inputContext, EditorInfo attribute,
- boolean initial, boolean needResult) {
+ IInputContext inputContext, EditorInfo attribute, int controlFlags) {
// If no method is currently selected, do nothing.
if (mCurMethodId == null) {
return mNoBinding;
@@ -837,6 +834,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} catch (RemoteException e) {
}
+ return startInputUncheckedLocked(cs, inputContext, attribute, controlFlags);
+ }
+
+ InputBindResult startInputUncheckedLocked(ClientState cs,
+ IInputContext inputContext, EditorInfo attribute, int controlFlags) {
+ // If no method is currently selected, do nothing.
+ if (mCurMethodId == null) {
+ return mNoBinding;
+ }
+
if (mCurClient != cs) {
// If the client is changing, we need to switch over to the new
// one.
@@ -867,7 +874,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (cs.curSession != null) {
// Fast case: if we are already connected to the input method,
// then just return it.
- return attachNewInputLocked(initial, needResult);
+ return attachNewInputLocked(
+ (controlFlags&InputMethodManager.CONTROL_START_INITIAL) != 0);
}
if (mHaveConnection) {
if (mCurMethod != null) {
@@ -948,13 +956,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@Override
public InputBindResult startInput(IInputMethodClient client,
- IInputContext inputContext, EditorInfo attribute,
- boolean initial, boolean needResult) {
+ IInputContext inputContext, EditorInfo attribute, int controlFlags) {
synchronized (mMethodMap) {
final long ident = Binder.clearCallingIdentity();
try {
- return startInputLocked(client, inputContext, attribute,
- initial, needResult);
+ return startInputLocked(client, inputContext, attribute, controlFlags);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -997,7 +1003,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
mCurClient.curSession = new SessionState(mCurClient,
method, session);
mCurClient.sessionRequested = false;
- InputBindResult res = attachNewInputLocked(true, true);
+ InputBindResult res = attachNewInputLocked(true);
if (res.method != null) {
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageOO(
MSG_BIND_METHOD, mCurClient.client, res));
@@ -1482,36 +1488,45 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
@Override
- public void windowGainedFocus(IInputMethodClient client, IBinder windowToken,
- boolean viewHasFocus, boolean isTextEditor, int softInputMode,
- boolean first, int windowFlags) {
+ public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder windowToken,
+ int controlFlags, int softInputMode, int windowFlags,
+ EditorInfo attribute, IInputContext inputContext) {
+ InputBindResult res = null;
long ident = Binder.clearCallingIdentity();
try {
synchronized (mMethodMap) {
if (DEBUG) Slog.v(TAG, "windowGainedFocus: " + client.asBinder()
- + " viewHasFocus=" + viewHasFocus
- + " isTextEditor=" + isTextEditor
+ + " controlFlags=#" + Integer.toHexString(controlFlags)
+ " softInputMode=#" + Integer.toHexString(softInputMode)
- + " first=" + first + " flags=#"
- + Integer.toHexString(windowFlags));
+ + " windowFlags=#" + Integer.toHexString(windowFlags));
- if (mCurClient == null || client == null
- || mCurClient.client.asBinder() != client.asBinder()) {
- try {
- // We need to check if this is the current client with
- // focus in the window manager, to allow this call to
- // be made before input is started in it.
- if (!mIWindowManager.inputMethodClientHasFocus(client)) {
- Slog.w(TAG, "Client not active, ignoring focus gain of: " + client);
- return;
- }
- } catch (RemoteException e) {
+ ClientState cs = mClients.get(client.asBinder());
+ if (cs == null) {
+ throw new IllegalArgumentException("unknown client "
+ + client.asBinder());
+ }
+
+ try {
+ if (!mIWindowManager.inputMethodClientHasFocus(cs.client)) {
+ // Check with the window manager to make sure this client actually
+ // has a window with focus. If not, reject. This is thread safe
+ // because if the focus changes some time before or after, the
+ // next client receiving focus that has any interest in input will
+ // be calling through here after that change happens.
+ Slog.w(TAG, "Focus gain on non-focused client " + cs.client
+ + " (uid=" + cs.uid + " pid=" + cs.pid + ")");
+ return null;
}
+ } catch (RemoteException e) {
}
if (mCurFocusedWindow == windowToken) {
Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client);
- return;
+ if (attribute != null) {
+ return startInputUncheckedLocked(cs, inputContext, attribute,
+ controlFlags);
+ }
+ return null;
}
mCurFocusedWindow = windowToken;
@@ -1527,6 +1542,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
== WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
|| mRes.getConfiguration().isLayoutSizeAtLeast(
Configuration.SCREENLAYOUT_SIZE_LARGE);
+ final boolean isTextEditor =
+ (controlFlags&InputMethodManager.CONTROL_WINDOW_IS_TEXT_EDITOR) != 0;
+
+ // We want to start input before showing the IME, but after closing
+ // it. We want to do this after closing it to help the IME disappear
+ // more quickly (not get stuck behind it initializing itself for the
+ // new focused input, even if its window wants to hide the IME).
+ boolean didStart = false;
switch (softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) {
case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED:
@@ -1542,12 +1565,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) {
// There is a focus view, and we are navigating forward
// into the window, so show the input window for the user.
- // We only do this automatically if the window an resize
- // to accomodate the IME (so what the user sees will give
+ // We only do this automatically if the window can resize
+ // to accommodate the IME (so what the user sees will give
// them good context without input information being obscured
// by the IME) or if running on a large screen where there
// is more room for the target window + IME.
if (DEBUG) Slog.v(TAG, "Unspecified window will show input");
+ if (attribute != null) {
+ res = startInputUncheckedLocked(cs, inputContext, attribute,
+ controlFlags);
+ didStart = true;
+ }
showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null);
}
break;
@@ -1569,18 +1597,35 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if ((softInputMode &
WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) {
if (DEBUG) Slog.v(TAG, "Window asks to show input going forward");
+ if (attribute != null) {
+ res = startInputUncheckedLocked(cs, inputContext, attribute,
+ controlFlags);
+ didStart = true;
+ }
showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null);
}
break;
case WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE:
if (DEBUG) Slog.v(TAG, "Window asks to always show input");
+ if (attribute != null) {
+ res = startInputUncheckedLocked(cs, inputContext, attribute,
+ controlFlags);
+ didStart = true;
+ }
showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null);
break;
}
+
+ if (!didStart && attribute != null) {
+ res = startInputUncheckedLocked(cs, inputContext, attribute,
+ controlFlags);
+ }
}
} finally {
Binder.restoreCallingIdentity(ident);
}
+
+ return res;
}
@Override