static boolean canTextInput(View v) {
    if (v.onCheckIsTextEditor()) {
      return true;
    }

    if (!(v instanceof ViewGroup)) {
      return false;
    }

    ViewGroup vg = (ViewGroup) v;
    int i = vg.getChildCount();
    while (i > 0) {
      i--;
      v = vg.getChildAt(i);
      if (canTextInput(v)) {
        return true;
      }
    }

    return false;
  }
  /**
   * Called by ViewRoot when its window gets input focus.
   *
   * @hide
   */
  public void onWindowFocus(
      View rootView, View focusedView, int softInputMode, boolean first, int windowFlags) {
    synchronized (mH) {
      if (DEBUG)
        Log.v(
            TAG,
            "onWindowFocus: "
                + focusedView
                + " softInputMode="
                + softInputMode
                + " first="
                + first
                + " flags=#"
                + Integer.toHexString(windowFlags));
      if (mHasBeenInactive) {
        if (DEBUG) Log.v(TAG, "Has been inactive!  Starting fresh");
        mHasBeenInactive = false;
        mNextServedNeedsStart = true;
      }
      focusInLocked(focusedView != null ? focusedView : rootView);
    }

    checkFocus();

    synchronized (mH) {
      try {
        final boolean isTextEditor = focusedView != null && focusedView.onCheckIsTextEditor();
        mService.windowGainedFocus(
            mClient,
            rootView.getWindowToken(),
            focusedView != null,
            isTextEditor,
            softInputMode,
            first,
            windowFlags);
      } catch (RemoteException e) {
      }
    }
  }