summaryrefslogtreecommitdiffstats
path: root/core/java/android/service
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-07-27 18:11:14 -0700
committerDianne Hackborn <hackbod@google.com>2015-07-28 12:52:11 -0700
commit57dd737443a174379eb638450e4888500d8e4a23 (patch)
treeac0750125c23a5e1e932e93407b421b5c397775a /core/java/android/service
parente827c2525a6b76c130d2b877fbcdcf62b0ce42eb (diff)
downloadframeworks_base-57dd737443a174379eb638450e4888500d8e4a23.zip
frameworks_base-57dd737443a174379eb638450e4888500d8e4a23.tar.gz
frameworks_base-57dd737443a174379eb638450e4888500d8e4a23.tar.bz2
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
Diffstat (limited to 'core/java/android/service')
-rw-r--r--core/java/android/service/voice/VoiceInteractionSession.java117
-rw-r--r--core/java/android/service/voice/VoiceInteractionSessionService.java13
2 files changed, 130 insertions, 0 deletions
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<mOptions.length; i++) {
+ VoiceInteractor.PickOptionRequest.Option op = mOptions[i];
+ writer.print(prefix); writer.print(" #"); writer.print(i); writer.println(":");
+ writer.print(prefix); writer.print(" mLabel=");
+ writer.println(op.getLabel());
+ writer.print(prefix); writer.print(" mIndex=");
+ writer.println(op.getIndex());
+ if (op.countSynonyms() > 0) {
+ writer.print(prefix); writer.println(" Synonyms:");
+ for (int j=0; j<op.countSynonyms(); j++) {
+ writer.print(prefix); writer.print(" #"); writer.print(j);
+ writer.print(": "); writer.println(op.getSynonymAt(j));
+ }
+ }
+ if (op.getExtras() != null) {
+ writer.print(prefix); writer.print(" mExtras=");
+ writer.println(op.getExtras());
+ }
+ }
+ }
+ }
}
/**
@@ -557,6 +623,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);
+ }
}
/**
@@ -607,6 +679,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);
+ }
}
/**
@@ -661,6 +739,12 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
public void sendResult(Bundle result) {
sendCommandResult(true, result);
}
+
+ void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
+ super.dump(prefix, fd, writer, args);
+ writer.print(prefix); writer.print("mCommand=");
+ writer.println(mCommand);
+ }
}
static final int MSG_START_CONFIRMATION = 1;
@@ -1446,4 +1530,37 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
*/
public void onCancelRequest(Request request) {
}
+
+ /**
+ * Print the Service's state into the given stream. This gets invoked by
+ * {@link VoiceInteractionSessionService} when its Service
+ * {@link android.app.Service#dump} method is called.
+ *
+ * @param prefix Text to print at the front of each line.
+ * @param fd The raw file descriptor that the dump is being sent to.
+ * @param writer The PrintWriter to which you should dump your state. This will be
+ * closed for you after you return.
+ * @param args additional arguments to the dump request.
+ */
+ public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
+ writer.print(prefix); writer.print("mToken="); writer.println(mToken);
+ writer.print(prefix); writer.print("mTheme=#"); writer.println(Integer.toHexString(mTheme));
+ writer.print(prefix); writer.print("mInitialized="); writer.println(mInitialized);
+ writer.print(prefix); writer.print("mWindowAdded="); writer.print(mWindowAdded);
+ writer.print(" mWindowVisible="); writer.println(mWindowVisible);
+ writer.print(prefix); writer.print("mWindowWasVisible="); writer.print(mWindowWasVisible);
+ writer.print(" mInShowWindow="); writer.println(mInShowWindow);
+ if (mActiveRequests.size() > 0) {
+ writer.print(prefix); writer.println("Active requests:");
+ String innerPrefix = prefix + " ";
+ for (int i=0; i<mActiveRequests.size(); i++) {
+ Request req = mActiveRequests.valueAt(i);
+ writer.print(prefix); writer.print(" #"); writer.print(i);
+ writer.print(": ");
+ writer.println(req);
+ req.dump(innerPrefix, fd, writer, args);
+
+ }
+ }
+ }
}
diff --git a/core/java/android/service/voice/VoiceInteractionSessionService.java b/core/java/android/service/voice/VoiceInteractionSessionService.java
index fb9f973..424ff9d 100644
--- a/core/java/android/service/voice/VoiceInteractionSessionService.java
+++ b/core/java/android/service/voice/VoiceInteractionSessionService.java
@@ -30,6 +30,9 @@ import com.android.internal.app.IVoiceInteractionManagerService;
import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* An active voice interaction session, initiated by a {@link VoiceInteractionService}.
*/
@@ -101,6 +104,16 @@ public abstract class VoiceInteractionSessionService extends Service {
}
}
+ @Override
+ protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
+ if (mSession == null) {
+ writer.println("(no active session)");
+ } else {
+ writer.println("VoiceInteractionSession:");
+ mSession.dump(" ", fd, writer, args);
+ }
+ }
+
void doNewSession(IBinder token, Bundle args, int startFlags) {
if (mSession != null) {
mSession.doDestroy();