Loading core/java/android/hardware/soundtrigger/SoundTrigger.java +1 −1 Original line number Diff line number Diff line Loading @@ -2306,7 +2306,7 @@ public class SoundTrigger { Looper looper = handler != null ? handler.getLooper() : Looper.getMainLooper(); try { return new SoundTriggerModule(getService(), moduleId, listener, looper, middlemanIdentity, originatorIdentity); middlemanIdentity, originatorIdentity, false); } catch (Exception e) { Log.e(TAG, "", e); return null; Loading core/java/android/hardware/soundtrigger/SoundTriggerModule.java +4 −2 Original line number Diff line number Diff line Loading @@ -83,7 +83,8 @@ public class SoundTriggerModule { */ public SoundTriggerModule(@NonNull ISoundTriggerMiddlewareService service, int moduleId, @NonNull SoundTrigger.StatusListener listener, @NonNull Looper looper, @NonNull Identity middlemanIdentity, @NonNull Identity originatorIdentity) { @NonNull Identity middlemanIdentity, @NonNull Identity originatorIdentity, boolean isTrusted) { mId = moduleId; mEventHandlerDelegate = new EventHandlerDelegate(listener, looper); Loading @@ -91,7 +92,8 @@ public class SoundTriggerModule { try (SafeCloseable ignored = ClearCallingIdentityContext.create()) { mService = service.attachAsMiddleman(moduleId, middlemanIdentity, originatorIdentity, mEventHandlerDelegate); mEventHandlerDelegate, isTrusted); } mService.asBinder().linkToDeath(mEventHandlerDelegate, 0); } catch (RemoteException e) { Loading media/aidl/android/media/soundtrigger_middleware/ISoundTriggerMiddlewareService.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -80,14 +80,16 @@ interface ISoundTriggerMiddlewareService { * This implies that the caller must clear its caller identity to protect from the case where * it resides in the same process as the callee. * - The identity of the entity on behalf of which module operations are to be performed. * * @param isTrusted - {@code true} if the middleware should not audit data delivery, since the * callback is being delivered to another trusted component which will audit access. * listModules() must be called prior to calling this method and the provided handle must be * one of the handles from the returned list. */ ISoundTriggerModule attachAsMiddleman(int handle, in Identity middlemanIdentity, in Identity originatorIdentity, ISoundTriggerCallback callback); ISoundTriggerCallback callback, boolean isTrusted); /** * Attach an injection interface interface to the ST mock HAL. Loading services/core/java/com/android/server/SoundTriggerInternal.java +8 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,14 @@ public interface SoundTriggerInternal { int STATUS_OK = SoundTrigger.STATUS_OK; // Attach to a specific underlying STModule Session attach(@NonNull IBinder client, ModuleProperties underlyingModule); /** * Attach to a specific underlying STModule. * @param client - Binder token representing the app client for death notifications * @param underlyingModule - Properties of the underlying STModule to attach to * @param isTrusted - {@code true} if callbacks will be appropriately AppOps attributed by * a trusted component prior to delivery to the ultimate client. */ Session attach(@NonNull IBinder client, ModuleProperties underlyingModule, boolean isTrusted); // Enumerate possible STModules to attach to List<ModuleProperties> listModuleProperties(Identity originatorIdentity); Loading services/tests/voiceinteractiontests/src/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareImplTest.java +19 −19 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAttachDetach() throws Exception { // Normal attachment / detachment. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); assertNotNull(module); module.detach(); } Loading @@ -172,7 +172,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadUnloadModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 7; int handle = loadGenericModel(module, hwHandle).first; Loading @@ -183,7 +183,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadPreemptModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 7; Pair<Integer, SoundTriggerHwCallback> loadResult = loadGenericModel(module, hwHandle); Loading @@ -202,7 +202,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadUnloadPhraseModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 73; int handle = loadPhraseModel(module, hwHandle).first; Loading @@ -213,7 +213,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartStopRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading @@ -233,7 +233,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartRecognitionBusy() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading @@ -257,7 +257,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartStopPhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 67; Loading @@ -277,7 +277,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading Loading @@ -322,7 +322,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testPhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading Loading @@ -352,7 +352,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForceRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -389,7 +389,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForceRecognitionNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -420,7 +420,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForcePhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -457,7 +457,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForcePhraseRecognitionNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -489,7 +489,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAbortRecognition() throws Exception { // Make sure the HAL doesn't support concurrent capture. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 11; Loading Loading @@ -521,7 +521,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAbortPhraseRecognition() throws Exception { // Make sure the HAL doesn't support concurrent capture. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 11; Loading Loading @@ -552,7 +552,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testParameterSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 12; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -574,7 +574,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testParameterNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 13; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -592,7 +592,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testGetParameter() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 14; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -609,7 +609,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testSetParameter() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 17; int modelHandle = loadGenericModel(module, hwHandle).first; Loading Loading
core/java/android/hardware/soundtrigger/SoundTrigger.java +1 −1 Original line number Diff line number Diff line Loading @@ -2306,7 +2306,7 @@ public class SoundTrigger { Looper looper = handler != null ? handler.getLooper() : Looper.getMainLooper(); try { return new SoundTriggerModule(getService(), moduleId, listener, looper, middlemanIdentity, originatorIdentity); middlemanIdentity, originatorIdentity, false); } catch (Exception e) { Log.e(TAG, "", e); return null; Loading
core/java/android/hardware/soundtrigger/SoundTriggerModule.java +4 −2 Original line number Diff line number Diff line Loading @@ -83,7 +83,8 @@ public class SoundTriggerModule { */ public SoundTriggerModule(@NonNull ISoundTriggerMiddlewareService service, int moduleId, @NonNull SoundTrigger.StatusListener listener, @NonNull Looper looper, @NonNull Identity middlemanIdentity, @NonNull Identity originatorIdentity) { @NonNull Identity middlemanIdentity, @NonNull Identity originatorIdentity, boolean isTrusted) { mId = moduleId; mEventHandlerDelegate = new EventHandlerDelegate(listener, looper); Loading @@ -91,7 +92,8 @@ public class SoundTriggerModule { try (SafeCloseable ignored = ClearCallingIdentityContext.create()) { mService = service.attachAsMiddleman(moduleId, middlemanIdentity, originatorIdentity, mEventHandlerDelegate); mEventHandlerDelegate, isTrusted); } mService.asBinder().linkToDeath(mEventHandlerDelegate, 0); } catch (RemoteException e) { Loading
media/aidl/android/media/soundtrigger_middleware/ISoundTriggerMiddlewareService.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -80,14 +80,16 @@ interface ISoundTriggerMiddlewareService { * This implies that the caller must clear its caller identity to protect from the case where * it resides in the same process as the callee. * - The identity of the entity on behalf of which module operations are to be performed. * * @param isTrusted - {@code true} if the middleware should not audit data delivery, since the * callback is being delivered to another trusted component which will audit access. * listModules() must be called prior to calling this method and the provided handle must be * one of the handles from the returned list. */ ISoundTriggerModule attachAsMiddleman(int handle, in Identity middlemanIdentity, in Identity originatorIdentity, ISoundTriggerCallback callback); ISoundTriggerCallback callback, boolean isTrusted); /** * Attach an injection interface interface to the ST mock HAL. Loading
services/core/java/com/android/server/SoundTriggerInternal.java +8 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,14 @@ public interface SoundTriggerInternal { int STATUS_OK = SoundTrigger.STATUS_OK; // Attach to a specific underlying STModule Session attach(@NonNull IBinder client, ModuleProperties underlyingModule); /** * Attach to a specific underlying STModule. * @param client - Binder token representing the app client for death notifications * @param underlyingModule - Properties of the underlying STModule to attach to * @param isTrusted - {@code true} if callbacks will be appropriately AppOps attributed by * a trusted component prior to delivery to the ultimate client. */ Session attach(@NonNull IBinder client, ModuleProperties underlyingModule, boolean isTrusted); // Enumerate possible STModules to attach to List<ModuleProperties> listModuleProperties(Identity originatorIdentity); Loading
services/tests/voiceinteractiontests/src/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareImplTest.java +19 −19 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAttachDetach() throws Exception { // Normal attachment / detachment. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); assertNotNull(module); module.detach(); } Loading @@ -172,7 +172,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadUnloadModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 7; int handle = loadGenericModel(module, hwHandle).first; Loading @@ -183,7 +183,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadPreemptModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 7; Pair<Integer, SoundTriggerHwCallback> loadResult = loadGenericModel(module, hwHandle); Loading @@ -202,7 +202,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testLoadUnloadPhraseModel() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 73; int handle = loadPhraseModel(module, hwHandle).first; Loading @@ -213,7 +213,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartStopRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading @@ -233,7 +233,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartRecognitionBusy() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading @@ -257,7 +257,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testStartStopPhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 67; Loading @@ -277,7 +277,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading Loading @@ -322,7 +322,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testPhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 7; Loading Loading @@ -352,7 +352,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForceRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -389,7 +389,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForceRecognitionNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -420,7 +420,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForcePhraseRecognition() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -457,7 +457,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testForcePhraseRecognitionNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 17; Loading Loading @@ -489,7 +489,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAbortRecognition() throws Exception { // Make sure the HAL doesn't support concurrent capture. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 11; Loading Loading @@ -521,7 +521,7 @@ public class SoundTriggerMiddlewareImplTest { public void testAbortPhraseRecognition() throws Exception { // Make sure the HAL doesn't support concurrent capture. ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); // Load the model. final int hwHandle = 11; Loading Loading @@ -552,7 +552,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testParameterSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 12; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -574,7 +574,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testParameterNotSupported() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 13; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -592,7 +592,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testGetParameter() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 14; int modelHandle = loadGenericModel(module, hwHandle).first; Loading @@ -609,7 +609,7 @@ public class SoundTriggerMiddlewareImplTest { @Test public void testSetParameter() throws Exception { ISoundTriggerCallback callback = createCallbackMock(); ISoundTriggerModule module = mService.attach(0, callback); ISoundTriggerModule module = mService.attach(0, callback, false); final int hwHandle = 17; int modelHandle = loadGenericModel(module, hwHandle).first; Loading