/** @hide */
 @SystemApi
 public void hideWindow() {
   if (mWindowVisible) {
     mWindow.hide();
     mWindowVisible = false;
   }
 }
  /** @hide */
  @SystemApi
  public void showWindow() {
    if (DEBUG)
      Log.v(
          TAG,
          "Showing window: mWindowAdded=" + mWindowAdded + " mWindowVisible=" + mWindowVisible);

    if (mInShowWindow) {
      Log.w(TAG, "Re-entrance in to showWindow");
      return;
    }

    try {
      mInShowWindow = true;
      if (!mWindowVisible) {
        mWindowVisible = true;
        if (!mWindowAdded) {
          mWindowAdded = true;
          View v = onCreateContentView();
          if (v != null) {
            setContentView(v);
          }
        }
        mWindow.show();
      }
    } finally {
      mWindowWasVisible = true;
      mInShowWindow = false;
    }
  }
 void doDestroy() {
   onDestroy();
   if (mInitialized) {
     mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener(mInsetsComputer);
     if (mWindowAdded) {
       mWindow.dismiss();
       mWindowAdded = false;
     }
     mInitialized = false;
   }
 }
  void initViews() {
    mInitialized = true;

    mThemeAttrs = mContext.obtainStyledAttributes(android.R.styleable.VoiceInteractionSession);
    mRootView = mInflater.inflate(com.android.internal.R.layout.voice_interaction_session, null);
    mRootView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    mWindow.setContentView(mRootView);
    mRootView.getViewTreeObserver().addOnComputeInternalInsetsListener(mInsetsComputer);

    mContentFrame = (FrameLayout) mRootView.findViewById(android.R.id.content);
  }
 /**
  * Initiatize a new session.
  *
  * @param args The arguments that were supplied to {@link VoiceInteractionService#startSession
  *     VoiceInteractionService.startSession}.
  */
 public void onCreate(Bundle args) {
   mTheme =
       mTheme != 0
           ? mTheme
           : com.android.internal.R.style.Theme_DeviceDefault_VoiceInteractionSession;
   mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mWindow =
       new SoftInputWindow(
           mContext,
           "VoiceInteractionSession",
           mTheme,
           mCallbacks,
           this,
           mDispatcherState,
           WindowManager.LayoutParams.TYPE_VOICE_INTERACTION,
           Gravity.TOP,
           true);
   mWindow.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
   initViews();
   mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
   mWindow.setToken(mToken);
 }