am c470b2dd: Merge "Part of fixing issue #6006757: Keyboard dismissal lags" into ics-mr1

* commit 'c470b2dd49ae2c4894de22f7bdd9f91af1a085f8':
  Part of fixing issue #6006757: Keyboard dismissal lags
This commit is contained in:
Justin Ho
2012-02-16 09:25:03 -08:00
committed by Android Git Automerger

View File

@@ -355,8 +355,10 @@ public final class InputMethodManager {
if (mServedView != null && mServedView.isFocused()) { if (mServedView != null && mServedView.isFocused()) {
mServedConnecting = true; mServedConnecting = true;
} }
if (mActive) {
startInputInner();
}
} }
startInputInner();
} }
return; return;
} }
@@ -1127,20 +1129,26 @@ public final class InputMethodManager {
* @hide * @hide
*/ */
public void checkFocus() { public void checkFocus() {
if (checkFocusNoStartInput()) {
startInputInner();
}
}
private boolean checkFocusNoStartInput() {
// This is called a lot, so short-circuit before locking. // This is called a lot, so short-circuit before locking.
if (mServedView == mNextServedView && !mNextServedNeedsStart) { if (mServedView == mNextServedView && !mNextServedNeedsStart) {
return; return false;
} }
InputConnection ic = null; InputConnection ic = null;
synchronized (mH) { synchronized (mH) {
if (mServedView == mNextServedView && !mNextServedNeedsStart) { if (mServedView == mNextServedView && !mNextServedNeedsStart) {
return; return false;
} }
if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView
+ " next=" + mNextServedView + " next=" + mNextServedView
+ " restart=" + mNextServedNeedsStart); + " restart=" + mNextServedNeedsStart);
mNextServedNeedsStart = false; mNextServedNeedsStart = false;
if (mNextServedView == null) { if (mNextServedView == null) {
finishInputLocked(); finishInputLocked();
@@ -1148,22 +1156,22 @@ public final class InputMethodManager {
// but no longer do. We should make sure the input method is // but no longer do. We should make sure the input method is
// no longer shown, since it serves no purpose. // no longer shown, since it serves no purpose.
closeCurrentInput(); closeCurrentInput();
return; return false;
} }
ic = mServedInputConnection; ic = mServedInputConnection;
mServedView = mNextServedView; mServedView = mNextServedView;
mCurrentTextBoxAttribute = null; mCurrentTextBoxAttribute = null;
mCompletions = null; mCompletions = null;
mServedConnecting = true; mServedConnecting = true;
} }
if (ic != null) { if (ic != null) {
ic.finishComposingText(); ic.finishComposingText();
} }
startInputInner(); return true;
} }
void closeCurrentInput() { void closeCurrentInput() {
@@ -1192,7 +1200,7 @@ public final class InputMethodManager {
focusInLocked(focusedView != null ? focusedView : rootView); focusInLocked(focusedView != null ? focusedView : rootView);
} }
checkFocus(); boolean startInput = checkFocusNoStartInput();
synchronized (mH) { synchronized (mH) {
try { try {
@@ -1201,6 +1209,9 @@ public final class InputMethodManager {
mService.windowGainedFocus(mClient, rootView.getWindowToken(), mService.windowGainedFocus(mClient, rootView.getWindowToken(),
focusedView != null, isTextEditor, softInputMode, first, focusedView != null, isTextEditor, softInputMode, first,
windowFlags); windowFlags);
if (startInput) {
startInputInner();
}
} catch (RemoteException e) { } catch (RemoteException e) {
} }
} }