/** @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();
  }