From 69c6adc96eecfde74ceb83cf9177428dc08b6067 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 2 Jun 2015 10:52:59 -0700 Subject: More API changes. Start moving Assist* stuff to android.app.assist. Clean up some more of the VoiceInteractionSession APIs. Clearly document that finish() is not the same as hide(), always call hide() instead, and fix the finish() path to also always do a hide to make sure everything is cleaned up correctly. Change-Id: I962d4069fcb34fe89547a95d395ae1b9fa3b4148 --- .../VoiceInteractionManagerServiceImpl.java | 4 +- .../VoiceInteractionSessionConnection.java | 71 +++++++++++----------- 2 files changed, 38 insertions(+), 37 deletions(-) (limited to 'services/voiceinteraction') diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index 6de887b..d8569bc 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -201,7 +201,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne Slog.w(TAG, "finish does not match active session"); return; } - mActiveSession.cancel(); + mActiveSession.cancelLocked(); mActiveSession = null; } @@ -251,7 +251,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne // If there is an active session, cancel it to allow it to clean up its window and other // state. if (mActiveSession != null) { - mActiveSession.cancel(); + mActiveSession.cancelLocked(); mActiveSession = null; } try { diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java index b4629f2..0b430ca 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java @@ -19,9 +19,9 @@ package com.android.server.voiceinteraction; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.AppOpsManager; -import android.app.AssistContent; -import android.app.AssistStructure; import android.app.IActivityManager; +import android.app.assist.AssistContent; +import android.app.assist.AssistStructure; import android.content.ClipData; import android.content.ComponentName; import android.content.ContentProvider; @@ -376,6 +376,40 @@ final class VoiceInteractionSessionConnection implements ServiceConnection { return false; } + public void cancelLocked() { + hideLocked(); + mCanceled = true; + if (mBound) { + if (mSession != null) { + try { + mSession.destroy(); + } catch (RemoteException e) { + Slog.w(TAG, "Voice interation session already dead"); + } + } + if (mSession != null) { + try { + mAm.finishVoiceTask(mSession); + } catch (RemoteException e) { + } + } + mContext.unbindService(this); + try { + mIWindowManager.removeWindowToken(mToken); + } catch (RemoteException e) { + Slog.w(TAG, "Failed removing window token", e); + } + mBound = false; + mService = null; + mSession = null; + mInteractor = null; + } + if (mFullyBound) { + mContext.unbindService(mFullConnection); + mFullyBound = false; + } + } + public boolean deliverNewSessionLocked(IVoiceInteractionSession session, IVoiceInteractor interactor) { mSession = session; @@ -432,39 +466,6 @@ final class VoiceInteractionSessionConnection implements ServiceConnection { mService = null; } - public void cancel() { - mCanceled = true; - if (mBound) { - if (mSession != null) { - try { - mSession.destroy(); - } catch (RemoteException e) { - Slog.w(TAG, "Voice interation session already dead"); - } - } - if (mSession != null) { - try { - mAm.finishVoiceTask(mSession); - } catch (RemoteException e) { - } - } - mContext.unbindService(this); - try { - mIWindowManager.removeWindowToken(mToken); - } catch (RemoteException e) { - Slog.w(TAG, "Failed removing window token", e); - } - mBound = false; - mService = null; - mSession = null; - mInteractor = null; - } - if (mFullyBound) { - mContext.unbindService(mFullConnection); - mFullyBound = false; - } - } - private boolean isStructureEnabled() { return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, mUser) != 0; -- cgit v1.1