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.hardware.soundtrigger.SoundTrigger;
20 import android.media.permission.Identity;
21 import android.media.soundtrigger_middleware.ISoundTriggerInjection;
22 import com.android.internal.app.ISoundTriggerSession;
23 
24 /**
25  * Service interface for a generic sound recognition model.
26  *
27  * This interface serves as an entry point to establish a session, associated with a client
28  * identity, which exposes the actual functionality.
29  *
30  * @hide
31  */
32 interface ISoundTriggerService {
33     /**
34      * Creates a new session.
35      *
36      * This version is intended to be used when the caller itself is the originator of the
37      * operations, for authorization purposes.
38      *
39      * The pid/uid fields are ignored and will be replaced by those provided by binder.
40      *
41      * It is good practice to clear the binder calling identity prior to calling this, in case the
42      * caller is ever in the same process as the callee.
43      *
44      * The binder object being passed is used by the server to keep track of client death, in order
45      * to clean-up whenever that happens.
46      */
attachAsOriginator(in Identity originatorIdentity, in SoundTrigger.ModuleProperties moduleProperties, IBinder client)47     ISoundTriggerSession attachAsOriginator(in Identity originatorIdentity,
48                                             in SoundTrigger.ModuleProperties moduleProperties,
49                                             IBinder client);
50 
51     /**
52      * Creates a new session.
53      *
54      * This version is intended to be used when the caller is acting on behalf of a separate entity
55      * (the originator) and the sessions operations are to be accounted against that originator for
56      * authorization purposes.
57      *
58      * The caller must hold the SOUNDTRIGGER_DELEGATE_IDENTITY permission in order to be trusted to
59      * provide a reliable originator identity. It should follow the best practices for reliably and
60      * securely verifying the identity of the originator.
61      *
62      * It is good practice to clear the binder calling identity prior to calling this, in case the
63      * caller is ever in the same process as the callee.
64      *
65      * The binder object being passed is used by the server to keep track of client death, in order
66      * to clean-up whenever that happens.
67      */
attachAsMiddleman(in Identity middlemanIdentity, in Identity originatorIdentity, in SoundTrigger.ModuleProperties moduleProperties, IBinder client)68     ISoundTriggerSession attachAsMiddleman(in Identity middlemanIdentity,
69                                            in Identity originatorIdentity,
70                                            in SoundTrigger.ModuleProperties moduleProperties,
71                                            IBinder client);
72 
73     /**
74      * Get available underlying SoundTrigger modules to attach to.
75      */
listModuleProperties(in Identity originatorIdentity)76     List<SoundTrigger.ModuleProperties> listModuleProperties(in Identity originatorIdentity);
77 
78     /**
79      * Attach an HAL injection interface.
80      */
attachInjection(ISoundTriggerInjection injection)81      void attachInjection(ISoundTriggerInjection injection);
82 
83     /**
84      * Test API to override the phone call state.
85      */
setInPhoneCallState(boolean isInPhoneCall)86      void setInPhoneCallState(boolean isInPhoneCall);
87 
88 }
89