Skip to content

Commit c470b2d

Browse files
Justin HoAndroid (Google) Code Review
authored andcommitted
Merge "Part of fixing issue #6006757: Keyboard dismissal lags" into ics-mr1
2 parents 2a1d191 + a82ba54 commit c470b2d

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

core/java/android/view/inputmethod/InputMethodManager.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ public void handleMessage(Message msg) {
355355
if (mServedView != null && mServedView.isFocused()) {
356356
mServedConnecting = true;
357357
}
358+
if (mActive) {
359+
startInputInner();
360+
}
358361
}
359-
startInputInner();
360362
}
361363
return;
362364
}
@@ -1127,43 +1129,49 @@ void scheduleCheckFocusLocked(View view) {
11271129
* @hide
11281130
*/
11291131
public void checkFocus() {
1132+
if (checkFocusNoStartInput()) {
1133+
startInputInner();
1134+
}
1135+
}
1136+
1137+
private boolean checkFocusNoStartInput() {
11301138
// This is called a lot, so short-circuit before locking.
11311139
if (mServedView == mNextServedView && !mNextServedNeedsStart) {
1132-
return;
1140+
return false;
11331141
}
11341142

11351143
InputConnection ic = null;
11361144
synchronized (mH) {
11371145
if (mServedView == mNextServedView && !mNextServedNeedsStart) {
1138-
return;
1146+
return false;
11391147
}
11401148
if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView
11411149
+ " next=" + mNextServedView
11421150
+ " restart=" + mNextServedNeedsStart);
1143-
1151+
11441152
mNextServedNeedsStart = false;
11451153
if (mNextServedView == null) {
11461154
finishInputLocked();
11471155
// In this case, we used to have a focused view on the window,
11481156
// but no longer do. We should make sure the input method is
11491157
// no longer shown, since it serves no purpose.
11501158
closeCurrentInput();
1151-
return;
1159+
return false;
11521160
}
1153-
1161+
11541162
ic = mServedInputConnection;
1155-
1163+
11561164
mServedView = mNextServedView;
11571165
mCurrentTextBoxAttribute = null;
11581166
mCompletions = null;
11591167
mServedConnecting = true;
11601168
}
1161-
1169+
11621170
if (ic != null) {
11631171
ic.finishComposingText();
11641172
}
1165-
1166-
startInputInner();
1173+
1174+
return true;
11671175
}
11681176

11691177
void closeCurrentInput() {
@@ -1192,7 +1200,7 @@ public void onWindowFocus(View rootView, View focusedView, int softInputMode,
11921200
focusInLocked(focusedView != null ? focusedView : rootView);
11931201
}
11941202

1195-
checkFocus();
1203+
boolean startInput = checkFocusNoStartInput();
11961204

11971205
synchronized (mH) {
11981206
try {
@@ -1201,6 +1209,9 @@ public void onWindowFocus(View rootView, View focusedView, int softInputMode,
12011209
mService.windowGainedFocus(mClient, rootView.getWindowToken(),
12021210
focusedView != null, isTextEditor, softInputMode, first,
12031211
windowFlags);
1212+
if (startInput) {
1213+
startInputInner();
1214+
}
12041215
} catch (RemoteException e) {
12051216
}
12061217
}

0 commit comments

Comments
 (0)