/** * When the focused window is dismissed, this method is called to finish the input method started * before. * * @hide */ public void windowDismissed(IBinder appWindowToken) { checkFocus(); synchronized (mH) { if (mServedView != null && mServedView.getWindowToken() == appWindowToken) { finishInputLocked(); } } }
/** @hide */ public void checkFocus() { // This is called a lot, so short-circuit before locking. if (mServedView == mNextServedView && !mNextServedNeedsStart) { return; } InputConnection ic = null; synchronized (mH) { if (mServedView == mNextServedView && !mNextServedNeedsStart) { return; } if (DEBUG) Log.v( TAG, "checkFocus: view=" + mServedView + " next=" + mNextServedView + " restart=" + mNextServedNeedsStart); mNextServedNeedsStart = false; if (mNextServedView == null) { finishInputLocked(); // In this case, we used to have a focused view on the window, // but no longer do. We should make sure the input method is // no longer shown, since it serves no purpose. closeCurrentInput(); return; } ic = mServedInputConnection; mServedView = mNextServedView; mCurrentTextBoxAttribute = null; mCompletions = null; mServedConnecting = true; } if (ic != null) { ic.finishComposingText(); } startInputInner(); }