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