void finishRequest() {
   VoiceInteractionSession session = mSession.get();
   if (session == null) {
     throw new IllegalStateException("VoiceInteractionSession has been destroyed");
   }
   Request req = session.removeRequest(mInterface.asBinder());
   if (req == null) {
     throw new IllegalStateException("Request not active: " + this);
   } else if (req != this) {
     throw new IllegalStateException(
         "Current active request " + req + " not same as calling request " + this);
   }
 }
 @Override
 public void onTaskFinished(Intent intent, int taskId) {
   super.onTaskFinished(intent, taskId);
   if (mCurrentTask == taskId) {
     mCurrentTask = -1;
   }
 }
 @Override
 public void onComputeInsets(Insets outInsets) {
   super.onComputeInsets(outInsets);
   if (mState != STATE_IDLE) {
     outInsets.contentInsets.top = mBottomContent.getTop();
     outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_CONTENT;
   }
 }
 @Override
 public void onHide() {
   super.onHide();
   if (mAssistVisualizer != null) {
     mAssistVisualizer.clearAssistData();
   }
   mState = STATE_DONE;
   updateState();
 }
 @Override
 public void onShow(Bundle args, int showFlags) {
   super.onShow(args, showFlags);
   Log.i(TAG, "onShow: flags=0x" + Integer.toHexString(showFlags) + " args=" + args);
   mState = STATE_IDLE;
   mStartIntent = args != null ? (Intent) args.getParcelable("intent") : null;
   if (mStartIntent == null) {
     mStartIntent = new Intent(getContext(), TestInteractionActivity.class);
   }
   if (mAssistVisualizer != null) {
     mAssistVisualizer.clearAssistData();
   }
   onHandleScreenshot(null);
   updateState();
   refreshOptions();
 }
 @Override
 public void onCreate() {
   super.onCreate();
   ActivityManager am = getContext().getSystemService(ActivityManager.class);
   am.setWatchHeapLimit(40 * 1024 * 1024);
 }
 @Override
 public void onTaskStarted(Intent intent, int taskId) {
   super.onTaskStarted(intent, taskId);
   mCurrentTask = taskId;
 }