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 com.android.internal.app.IVoiceInteractionSessionListener;
26import android.hardware.soundtrigger.IRecognitionStatusCallback;
27import android.hardware.soundtrigger.SoundTrigger;
28import android.service.voice.IVoiceInteractionService;
29import android.service.voice.IVoiceInteractionSession;
30
31interface IVoiceInteractionManagerService {
32    void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags);
33    boolean deliverNewSession(IBinder token, IVoiceInteractionSession session,
34            IVoiceInteractor interactor);
35    boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags);
36    boolean hideSessionFromSession(IBinder token);
37    int startVoiceActivity(IBinder token, in Intent intent, String resolvedType);
38    int startAssistantActivity(IBinder token, in Intent intent, String resolvedType);
39    void setKeepAwake(IBinder token, boolean keepAwake);
40    void closeSystemDialogs(IBinder token);
41    void finish(IBinder token);
42    void setDisabledShowContext(int flags);
43    int getDisabledShowContext();
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     */
53    SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
54    /**
55     * Add/Update the given keyphrase sound model.
56     */
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     */
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     */
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     */
78    boolean isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId,
79            String bcp47Locale);
80    /**
81     * Starts a recognition for the given keyphrase.
82     */
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     */
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     */
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     */
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     */
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     */
118    void launchVoiceAssistFromKeyguard();
119
120    /**
121     * Indicates whether there is a voice session running (but not necessarily showing).
122     */
123    boolean isSessionRunning();
124
125    /**
126     * Indicates whether the currently active voice interaction service is capable of handling the
127     * assist gesture.
128     */
129    boolean activeServiceSupportsAssist();
130
131    /**
132     * Indicates whether the currently active voice interaction service is capable of being launched
133     * from the lockscreen.
134     */
135    boolean activeServiceSupportsLaunchFromKeyguard();
136
137    /**
138     * Called when the lockscreen got shown.
139     */
140    void onLockscreenShown();
141
142    /**
143     * Register a voice interaction listener.
144     */
145    void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener);
146}
147