summaryrefslogtreecommitdiffstats
path: root/services/voiceinteraction/java
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-04-02 11:46:28 -0700
committerJorim Jaggi <jjaggi@google.com>2015-04-03 11:11:51 -0700
commit25e12abc5b8a4aa83cfa150094fd145b777e6e03 (patch)
tree208268c6666cf72d9a201fe852f350b152cd8e70 /services/voiceinteraction/java
parent0feaaafd7a9206e6bf1d9dc9a1f285937b9def8e (diff)
downloadframeworks_base-25e12abc5b8a4aa83cfa150094fd145b777e6e03.zip
frameworks_base-25e12abc5b8a4aa83cfa150094fd145b777e6e03.tar.gz
frameworks_base-25e12abc5b8a4aa83cfa150094fd145b777e6e03.tar.bz2
Add ability to start voice interaction session directly
Add internal API's for SystemUI to start a voice interaction session directly, without using an intent. Make the assist gesture use that ability, if available. Change-Id: I88ce3c7514714eb45666884847193585a07417a9
Diffstat (limited to 'services/voiceinteraction/java')
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index f032ccf..d8b9140 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -707,6 +707,60 @@ public class VoiceInteractionManagerService extends SystemService {
}
@Override
+ public boolean isServiceActive() {
+ synchronized (this) {
+ if (mContext.checkCallingPermission(
+ Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Caller does not hold the permission "
+ + Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
+ }
+ return mImpl != null;
+ }
+ }
+
+ @Override
+ public void showSessionForActiveService() {
+ synchronized (this) {
+ if (mContext.checkCallingPermission(
+ Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Caller does not hold the permission "
+ + Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
+ }
+ if (mImpl == null) {
+ Slog.w(TAG, "showSessionForActiveService without running voice interaction"
+ + "service");
+ return;
+ }
+ final int callingPid = Binder.getCallingPid();
+ final int callingUid = Binder.getCallingUid();
+ final long caller = Binder.clearCallingIdentity();
+ try {
+ mImpl.showSessionLocked(callingPid, callingUid, new Bundle() /* sessionArgs */,
+ VoiceInteractionService.START_SOURCE_SYSTEM
+ | VoiceInteractionService.START_WITH_ASSIST
+ | VoiceInteractionService.START_WITH_SCREENSHOT);
+ } finally {
+ Binder.restoreCallingIdentity(caller);
+ }
+ }
+ }
+
+ @Override
+ public boolean isSessionRunning() {
+ synchronized (this) {
+ if (mContext.checkCallingPermission(
+ Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Caller does not hold the permission "
+ + Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
+ }
+ return mImpl != null && mImpl.mActiveSession != null;
+ }
+ }
+
+ @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
!= PackageManager.PERMISSION_GRANTED) {