private void startAssistActivity(Bundle args) {
    if (!mBar.isDeviceProvisioned()) {
      return;
    }

    // Close Recent Apps if needed
    mBar.animateCollapsePanels(
        CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);

    boolean structureEnabled =
        Settings.Secure.getIntForUser(
                mContext.getContentResolver(),
                Settings.Secure.ASSIST_STRUCTURE_ENABLED,
                1,
                UserHandle.USER_CURRENT)
            != 0;

    final Intent intent =
        ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
            .getAssistIntent(structureEnabled);
    if (intent == null) {
      return;
    }
    if (mAssistComponent != null) {
      intent.setComponent(mAssistComponent);
    }
    intent.putExtras(args);

    if (structureEnabled) {
      showDisclosure();
    }

    try {
      final ActivityOptions opts =
          ActivityOptions.makeCustomAnimation(
              mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      AsyncTask.execute(
          new Runnable() {
            @Override
            public void run() {
              mContext.startActivityAsUser(
                  intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
            }
          });
    } catch (ActivityNotFoundException e) {
      Log.w(TAG, "Activity not found for " + intent.getAction());
    }
  }
 public void hide(boolean animate) {
   if (mBar != null) {
     // This will indirectly cause show(false, ...) to get called
     mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
   } else {
     setVisibility(View.INVISIBLE);
   }
 }
 private void startAssistActivity() {
   // Close Recent Apps if needed
   mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
   // Launch Assist
   Intent intent = SearchManager.getAssistIntent(mContext);
   if (intent == null) return;
   try {
     ActivityOptions opts =
         ActivityOptions.makeCustomAnimation(
             mContext, R.anim.search_launch_enter, R.anim.search_launch_exit, getHandler(), this);
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     mContext.startActivity(intent, opts.toBundle());
   } catch (ActivityNotFoundException e) {
     Slog.w(TAG, "Activity not found for " + intent.getAction());
     onAnimationStarted();
   }
 }