From 57dd737443a174379eb638450e4888500d8e4a23 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 27 Jul 2015 18:11:14 -0700 Subject: Work on issue #21516866: Implement voice interaction in ResolverActivity The main change here is to not allow the dialog to go in to its "focus on the last app the user selected" when running in voice interaction mode, instead just always giving a simple list. This also fixes some problems with cleaning up active commands when an activity finishes and not forcing the current session to go away when the screen is turned off. Also added some debug help, having activity print the state of the voice interactor. Change-Id: Ifebee9c74d78398a730a280bb4970f47789dadf5 --- .../service/voice/VoiceInteractionSession.java | 117 +++++++++++++++++++++ .../voice/VoiceInteractionSessionService.java | 13 +++ 2 files changed, 130 insertions(+) (limited to 'core/java/android/service') diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index f647aa6..ec14740 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -37,7 +37,9 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; +import android.os.UserHandle; import android.util.ArrayMap; +import android.util.DebugUtils; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; @@ -55,6 +57,8 @@ import com.android.internal.app.IVoiceInteractorRequest; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; +import java.io.FileDescriptor; +import java.io.PrintWriter; import java.lang.ref.WeakReference; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; @@ -369,6 +373,34 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall } catch (RemoteException e) { } } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(128); + DebugUtils.buildShortClassTag(this, sb); + sb.append(" "); + sb.append(mInterface.asBinder()); + sb.append(" pkg="); + sb.append(mCallingPackage); + sb.append(" uid="); + UserHandle.formatUid(sb, mCallingUid); + sb.append('}'); + return sb.toString(); + } + + void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { + writer.print(prefix); writer.print("mInterface="); + writer.println(mInterface.asBinder()); + writer.print(prefix); writer.print("mCallingPackage="); writer.print(mCallingPackage); + writer.print(" mCallingUid="); UserHandle.formatUid(writer, mCallingUid); + writer.println(); + writer.print(prefix); writer.print("mCallback="); + writer.println(mCallback.asBinder()); + if (mExtras != null) { + writer.print(prefix); writer.print("mExtras="); + writer.println(mExtras); + } + } } /** @@ -422,6 +454,12 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall } catch (RemoteException e) { } } + + void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { + super.dump(prefix, fd, writer, args); + writer.print(prefix); writer.print("mPrompt="); + writer.println(mPrompt); + } } /** @@ -504,6 +542,34 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) { sendPickOptionResult(true, selections, result); } + + void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { + super.dump(prefix, fd, writer, args); + writer.print(prefix); writer.print("mPrompt="); + writer.println(mPrompt); + if (mOptions != null) { + writer.print(prefix); writer.println("Options:"); + for (int i=0; i