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
diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java
index 419b92b..bc020e9 100644
--- a/core/java/android/service/voice/VoiceInteractionService.java
+++ b/core/java/android/service/voice/VoiceInteractionService.java
@@ -82,6 +82,12 @@
*/
public static final int START_WITH_SCREENSHOT = 1<<1;
+ /**
+ * Flag for use with {@link #showSession}: indicate that the session has been started from the
+ * system.
+ */
+ public static final int START_SOURCE_SYSTEM = 1<<2;
+
IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() {
@Override public void ready() {
mHandler.sendEmptyMessage(MSG_READY);
diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
index 6450d52..144dca4 100644
--- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
+++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
@@ -80,4 +80,20 @@
*/
int stopRecognition(in IVoiceInteractionService service, int keyphraseId,
in IRecognitionStatusCallback callback);
+
+ /**
+ * Indicates whether any voice interaction service is currently active.
+ */
+ boolean isServiceActive();
+
+ /**
+ * Shows the session for the currently active service. Used to start a new session from system
+ * affordances.
+ */
+ void showSessionForActiveService();
+
+ /**
+ * Indicates whether there is a voice session running (but not necessarily showing).
+ */
+ boolean isSessionRunning();
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index b0771dd..f427f2b 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3009,6 +3009,14 @@
android:description="@string/permdesc_bindCarrierMessagingService"
android:protectionLevel="signature|system" />
+ <!-- Allows an application to interact with the currently active
+ {@link android.service.voice.VoiceInteractionService}.
+ @hide -->
+ <permission android:name="android.permission.ACCESS_VOICE_INTERACTION_SERVICE"
+ android:protectionLevel="signature"
+ android:description="@string/permdesc_accessVoiceInteractionService"
+ android:label="@string/permlab_accessVoiceInteractionService" />
+
<!-- The system process is explicitly the only one allowed to launch the
confirmation UI for full backup/restore -->
<uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 6cd3139..4d90932 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2462,6 +2462,11 @@
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_bindCarrierMessagingService">Allows the holder to bind to the top-level interface of a carrier messaging service. Should never be needed for normal apps.</string>
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_accessVoiceInteractionService">interact with voice interaction service</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_accessVoiceInteractionService">Allows the holder to interact with the currently active voice interaction service. Should never be needed for normal apps.</string>
+
<!-- Policy administration -->
<!-- Title of policy access to limiting the user's password choices -->