1 /* 2 * Copyright (C) 2019 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 package android.media.soundtrigger_middleware; 17 18 import android.media.permission.Identity; 19 import android.media.soundtrigger_middleware.ISoundTriggerModule; 20 import android.media.soundtrigger_middleware.ISoundTriggerCallback; 21 import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; 22 23 /** 24 * Main entry point into this module. 25 * 26 * Allows the client to enumerate the available soundtrigger devices and their capabilities, then 27 * attach to either one of them in order to use it. 28 * 29 * {@hide} 30 */ 31 interface ISoundTriggerMiddlewareService { 32 /** 33 * Query the available modules and their capabilities. 34 * 35 * This variant is intended for use by the originator of the operations for permission 36 * enforcement purposes. The provided identity's uid/pid fields will be ignored and overridden 37 * by the ones provided by Binder.getCallingUid() / Binder.getCallingPid(). 38 */ listModulesAsOriginator(in Identity identity)39 SoundTriggerModuleDescriptor[] listModulesAsOriginator(in Identity identity); 40 41 /** 42 * Query the available modules and their capabilities. 43 * 44 * This variant is intended for use by a trusted "middleman", acting on behalf of some identity 45 * other than itself. The caller must provide: 46 * - Its own identity, which will be used to establish trust via the 47 * SOUNDTRIGGER_DELEGATE_IDENTITY permission. This identity's uid/pid fields will be ignored 48 * and overridden by the ones provided by Binder.getCallingUid() / Binder.getCallingPid(). 49 * This implies that the caller must clear its caller identity to protect from the case where 50 * it resides in the same process as the callee. 51 * - The identity of the entity on behalf of which module operations are to be performed. 52 */ listModulesAsMiddleman(in Identity middlemanIdentity, in Identity originatorIdentity)53 SoundTriggerModuleDescriptor[] listModulesAsMiddleman(in Identity middlemanIdentity, 54 in Identity originatorIdentity); 55 56 /** 57 * Attach to one of the available modules. 58 * 59 * This variant is intended for use by the originator of the operations for permission 60 * enforcement purposes. The provided identity's uid/pid fields will be ignored and overridden 61 * by the ones provided by Binder.getCallingUid() / Binder.getCallingPid(). 62 * 63 * listModules() must be called prior to calling this method and the provided handle must be 64 * one of the handles from the returned list. 65 */ attachAsOriginator(int handle, in Identity identity, ISoundTriggerCallback callback)66 ISoundTriggerModule attachAsOriginator(int handle, 67 in Identity identity, 68 ISoundTriggerCallback callback); 69 70 /** 71 * Attach to one of the available modules. 72 * 73 * This variant is intended for use by a trusted "middleman", acting on behalf of some identity 74 * other than itself. The caller must provide: 75 * - Its own identity, which will be used to establish trust via the 76 * SOUNDTRIGGER_DELEGATE_IDENTITY permission. This identity's uid/pid fields will be ignored 77 * and overridden by the ones provided by Binder.getCallingUid() / Binder.getCallingPid(). 78 * This implies that the caller must clear its caller identity to protect from the case where 79 * it resides in the same process as the callee. 80 * - The identity of the entity on behalf of which module operations are to be performed. 81 * 82 * listModules() must be called prior to calling this method and the provided handle must be 83 * one of the handles from the returned list. 84 */ attachAsMiddleman(int handle, in Identity middlemanIdentity, in Identity originatorIdentity, ISoundTriggerCallback callback)85 ISoundTriggerModule attachAsMiddleman(int handle, 86 in Identity middlemanIdentity, 87 in Identity originatorIdentity, 88 ISoundTriggerCallback callback); 89 } 90