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 import android.os.RemoteCallback; 23 24 import com.android.internal.app.IVoiceActionCheckCallback; 25 import com.android.internal.app.IVoiceInteractionSessionShowCallback; 26 import com.android.internal.app.IVoiceInteractor; 27 import com.android.internal.app.IVoiceInteractionSessionListener; 28 import android.hardware.soundtrigger.IRecognitionStatusCallback; 29 import android.hardware.soundtrigger.SoundTrigger; 30 import android.service.voice.IVoiceInteractionService; 31 import android.service.voice.IVoiceInteractionSession; 32 33 interface IVoiceInteractionManagerService { showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags)34 void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags); deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor)35 boolean deliverNewSession(IBinder token, IVoiceInteractionSession session, 36 IVoiceInteractor interactor); showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags)37 boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags); hideSessionFromSession(IBinder token)38 boolean hideSessionFromSession(IBinder token); startVoiceActivity(IBinder token, in Intent intent, String resolvedType)39 int startVoiceActivity(IBinder token, in Intent intent, String resolvedType); startAssistantActivity(IBinder token, in Intent intent, String resolvedType)40 int startAssistantActivity(IBinder token, in Intent intent, String resolvedType); setKeepAwake(IBinder token, boolean keepAwake)41 void setKeepAwake(IBinder token, boolean keepAwake); closeSystemDialogs(IBinder token)42 void closeSystemDialogs(IBinder token); finish(IBinder token)43 void finish(IBinder token); setDisabledShowContext(int flags)44 void setDisabledShowContext(int flags); getDisabledShowContext()45 int getDisabledShowContext(); getUserDisabledShowContext()46 int getUserDisabledShowContext(); 47 48 /** 49 * Gets the registered Sound model for keyphrase detection for the current user. 50 * May be null if no matching sound model exists. 51 * 52 * @param keyphraseId The unique identifier for the keyphrase. 53 * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. 54 */ 55 @UnsupportedAppUsage getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)56 SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); 57 /** 58 * Add/Update the given keyphrase sound model. 59 */ updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model)60 int updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model); 61 /** 62 * Deletes the given keyphrase sound model for the current user. 63 * 64 * @param keyphraseId The unique identifier for the keyphrase. 65 * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. 66 */ deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)67 int deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); 68 69 /** 70 * Gets the properties of the DSP hardware on this device, null if not present. 71 */ getDspModuleProperties(in IVoiceInteractionService service)72 SoundTrigger.ModuleProperties getDspModuleProperties(in IVoiceInteractionService service); 73 /** 74 * Indicates if there's a keyphrase sound model available for the given keyphrase ID. 75 * This performs the check for the current user. 76 * 77 * @param service The current VoiceInteractionService. 78 * @param keyphraseId The unique identifier for the keyphrase. 79 * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. 80 */ isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId, String bcp47Locale)81 boolean isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId, 82 String bcp47Locale); 83 /** 84 * Starts a recognition for the given keyphrase. 85 */ startRecognition(in IVoiceInteractionService service, int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig recognitionConfig)86 int startRecognition(in IVoiceInteractionService service, int keyphraseId, 87 in String bcp47Locale, in IRecognitionStatusCallback callback, 88 in SoundTrigger.RecognitionConfig recognitionConfig); 89 /** 90 * Stops a recognition for the given keyphrase. 91 */ stopRecognition(in IVoiceInteractionService service, int keyphraseId, in IRecognitionStatusCallback callback)92 int stopRecognition(in IVoiceInteractionService service, int keyphraseId, 93 in IRecognitionStatusCallback callback); 94 95 /** 96 * @return the component name for the currently active voice interaction service 97 */ getActiveServiceComponentName()98 ComponentName getActiveServiceComponentName(); 99 100 /** 101 * Shows the session for the currently active service. Used to start a new session from system 102 * affordances. 103 * 104 * @param args the bundle to pass as arguments to the voice interaction session 105 * @param sourceFlags flags indicating the source of this show 106 * @param showCallback optional callback to be notified when the session was shown 107 * @param activityToken optional token of activity that needs to be on top 108 */ showSessionForActiveService(in Bundle args, int sourceFlags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken)109 boolean showSessionForActiveService(in Bundle args, int sourceFlags, 110 IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken); 111 112 /** 113 * Hides the session from the active service, if it is showing. 114 */ hideCurrentSession()115 void hideCurrentSession(); 116 117 /** 118 * Notifies the active service that a launch was requested from the Keyguard. This will only 119 * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true. 120 */ launchVoiceAssistFromKeyguard()121 void launchVoiceAssistFromKeyguard(); 122 123 /** 124 * Indicates whether there is a voice session running (but not necessarily showing). 125 */ isSessionRunning()126 boolean isSessionRunning(); 127 128 /** 129 * Indicates whether the currently active voice interaction service is capable of handling the 130 * assist gesture. 131 */ activeServiceSupportsAssist()132 boolean activeServiceSupportsAssist(); 133 134 /** 135 * Indicates whether the currently active voice interaction service is capable of being launched 136 * from the lockscreen. 137 */ activeServiceSupportsLaunchFromKeyguard()138 boolean activeServiceSupportsLaunchFromKeyguard(); 139 140 /** 141 * Called when the lockscreen got shown. 142 */ onLockscreenShown()143 void onLockscreenShown(); 144 145 /** 146 * Register a voice interaction listener. 147 */ registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener)148 void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener); 149 150 /** 151 * Checks the availability of a set of voice actions for the current active voice service. 152 * Returns all supported voice actions. 153 */ getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback)154 void getActiveServiceSupportedActions(in List<String> voiceActions, 155 in IVoiceActionCheckCallback callback); 156 157 /** 158 * Provide hints for showing UI. 159 */ setUiHints(in IVoiceInteractionService service, in Bundle hints)160 void setUiHints(in IVoiceInteractionService service, in Bundle hints); 161 162 /** 163 * Requests a list of supported actions from a specific activity. 164 */ requestDirectActions(in IBinder token, int taskId, IBinder assistToken, in RemoteCallback cancellationCallback, in RemoteCallback callback)165 void requestDirectActions(in IBinder token, int taskId, IBinder assistToken, 166 in RemoteCallback cancellationCallback, in RemoteCallback callback); 167 168 /** 169 * Requests performing an action from a specific activity. 170 */ performDirectAction(in IBinder token, String actionId, in Bundle arguments, int taskId, IBinder assistToken, in RemoteCallback cancellationCallback, in RemoteCallback resultCallback)171 void performDirectAction(in IBinder token, String actionId, in Bundle arguments, int taskId, 172 IBinder assistToken, in RemoteCallback cancellationCallback, 173 in RemoteCallback resultCallback); 174 } 175