1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.app;
18 
19 import android.content.ComponentName;
20 import android.content.Intent;
21 import android.os.Bundle;
22 
23 import com.android.internal.app.IVoiceInteractionSessionShowCallback;
24 import com.android.internal.app.IVoiceInteractor;
25 import com.android.internal.app.IVoiceInteractionSessionListener;
26 import android.hardware.soundtrigger.IRecognitionStatusCallback;
27 import android.hardware.soundtrigger.SoundTrigger;
28 import android.service.voice.IVoiceInteractionService;
29 import android.service.voice.IVoiceInteractionSession;
30 
31 interface IVoiceInteractionManagerService {
showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags)32     void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags);
deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor)33     boolean deliverNewSession(IBinder token, IVoiceInteractionSession session,
34             IVoiceInteractor interactor);
showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags)35     boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags);
hideSessionFromSession(IBinder token)36     boolean hideSessionFromSession(IBinder token);
startVoiceActivity(IBinder token, in Intent intent, String resolvedType)37     int startVoiceActivity(IBinder token, in Intent intent, String resolvedType);
startAssistantActivity(IBinder token, in Intent intent, String resolvedType)38     int startAssistantActivity(IBinder token, in Intent intent, String resolvedType);
setKeepAwake(IBinder token, boolean keepAwake)39     void setKeepAwake(IBinder token, boolean keepAwake);
closeSystemDialogs(IBinder token)40     void closeSystemDialogs(IBinder token);
finish(IBinder token)41     void finish(IBinder token);
setDisabledShowContext(int flags)42     void setDisabledShowContext(int flags);
getDisabledShowContext()43     int getDisabledShowContext();
getUserDisabledShowContext()44     int getUserDisabledShowContext();
45 
46     /**
47      * Gets the registered Sound model for keyphrase detection for the current user.
48      * May be null if no matching sound model exists.
49      *
50      * @param keyphraseId The unique identifier for the keyphrase.
51      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
52      */
getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)53     SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
54     /**
55      * Add/Update the given keyphrase sound model.
56      */
updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model)57     int updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model);
58     /**
59      * Deletes the given keyphrase sound model for the current user.
60      *
61      * @param keyphraseId The unique identifier for the keyphrase.
62      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
63      */
deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)64     int deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
65 
66     /**
67      * Gets the properties of the DSP hardware on this device, null if not present.
68      */
getDspModuleProperties(in IVoiceInteractionService service)69     SoundTrigger.ModuleProperties getDspModuleProperties(in IVoiceInteractionService service);
70     /**
71      * Indicates if there's a keyphrase sound model available for the given keyphrase ID.
72      * This performs the check for the current user.
73      *
74      * @param service The current VoiceInteractionService.
75      * @param keyphraseId The unique identifier for the keyphrase.
76      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
77      */
isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId, String bcp47Locale)78     boolean isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId,
79             String bcp47Locale);
80     /**
81      * Starts a recognition for the given keyphrase.
82      */
startRecognition(in IVoiceInteractionService service, int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig recognitionConfig)83     int startRecognition(in IVoiceInteractionService service, int keyphraseId,
84             in String bcp47Locale, in IRecognitionStatusCallback callback,
85             in SoundTrigger.RecognitionConfig recognitionConfig);
86     /**
87      * Stops a recognition for the given keyphrase.
88      */
stopRecognition(in IVoiceInteractionService service, int keyphraseId, in IRecognitionStatusCallback callback)89     int stopRecognition(in IVoiceInteractionService service, int keyphraseId,
90             in IRecognitionStatusCallback callback);
91 
92     /**
93      * @return the component name for the currently active voice interaction service
94      */
getActiveServiceComponentName()95     ComponentName getActiveServiceComponentName();
96 
97     /**
98      * Shows the session for the currently active service. Used to start a new session from system
99      * affordances.
100      *
101      * @param args the bundle to pass as arguments to the voice interaction session
102      * @param sourceFlags flags indicating the source of this show
103      * @param showCallback optional callback to be notified when the session was shown
104      * @param activityToken optional token of activity that needs to be on top
105      */
showSessionForActiveService(in Bundle args, int sourceFlags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken)106     boolean showSessionForActiveService(in Bundle args, int sourceFlags,
107             IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken);
108 
109     /**
110      * Hides the session from the active service, if it is showing.
111      */
hideCurrentSession()112     void hideCurrentSession();
113 
114     /**
115      * Notifies the active service that a launch was requested from the Keyguard. This will only
116      * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true.
117      */
launchVoiceAssistFromKeyguard()118     void launchVoiceAssistFromKeyguard();
119 
120     /**
121      * Indicates whether there is a voice session running (but not necessarily showing).
122      */
isSessionRunning()123     boolean isSessionRunning();
124 
125     /**
126      * Indicates whether the currently active voice interaction service is capable of handling the
127      * assist gesture.
128      */
activeServiceSupportsAssist()129     boolean activeServiceSupportsAssist();
130 
131     /**
132      * Indicates whether the currently active voice interaction service is capable of being launched
133      * from the lockscreen.
134      */
activeServiceSupportsLaunchFromKeyguard()135     boolean activeServiceSupportsLaunchFromKeyguard();
136 
137     /**
138      * Called when the lockscreen got shown.
139      */
onLockscreenShown()140     void onLockscreenShown();
141 
142     /**
143      * Register a voice interaction listener.
144      */
registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener)145     void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener);
146 }
147