Loading core/java/android/hardware/soundtrigger/SoundTriggerModule.java +6 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,12 @@ public class SoundTriggerModule { mHandler.sendMessage(m); } @Override public synchronized void onModuleDied() { Message m = mHandler.obtainMessage(EVENT_SERVICE_DIED); mHandler.sendMessage(m); } @Override public synchronized void binderDied() { Message m = mHandler.obtainMessage(EVENT_SERVICE_DIED); Loading media/java/android/media/soundtrigger_middleware/ISoundTriggerCallback.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,11 @@ oneway interface ISoundTriggerCallback { * and this event will be sent in addition to the abort event. */ void onRecognitionAvailabilityChange(boolean available); /** * Notifies the client that the associated module has crashed and restarted. The module instance * is no longer usable and will throw a ServiceSpecificException with a Status.DEAD_OBJECT code * for every call. The client should detach, then re-attach to the module in order to get a new, * usable instance. All state for this module has been lost. */ void onModuleDied(); } media/java/android/media/soundtrigger_middleware/Status.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,6 @@ enum Status { OPERATION_NOT_SUPPORTED = 2, /** Temporary lack of permission. */ TEMPORARY_PERMISSION_DENIED = 3, /** The object on which this method is called is dead and all of its state is lost. */ DEAD_OBJECT = 4, } services/core/java/com/android/server/soundtrigger_middleware/HalFactory.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.soundtrigger_middleware; import android.hardware.soundtrigger.V2_0.ISoundTriggerHw; /** * A factory for creating instances of {@link ISoundTriggerHw}. * * @hide */ public interface HalFactory { /** * @return An instance of {@link ISoundTriggerHw}. */ ISoundTriggerHw create(); } services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareImpl.java +9 −10 Original line number Diff line number Diff line Loading @@ -78,18 +78,17 @@ public class SoundTriggerMiddlewareImpl implements ISoundTriggerMiddlewareServic } /** * Most generic constructor - gets an array of HAL driver instances. * Constructor - gets an array of HAL driver factories. */ public SoundTriggerMiddlewareImpl(@NonNull ISoundTriggerHw[] halServices, public SoundTriggerMiddlewareImpl(@NonNull HalFactory[] halFactories, @NonNull AudioSessionProvider audioSessionProvider) { List<SoundTriggerModule> modules = new ArrayList<>(halServices.length); List<SoundTriggerModule> modules = new ArrayList<>(halFactories.length); for (int i = 0; i < halServices.length; ++i) { ISoundTriggerHw service = halServices[i]; for (int i = 0; i < halFactories.length; ++i) { try { modules.add(new SoundTriggerModule(service, audioSessionProvider)); modules.add(new SoundTriggerModule(halFactories[i], audioSessionProvider)); } catch (Exception e) { Log.e(TAG, "Failed to a SoundTriggerModule instance", e); Log.e(TAG, "Failed to add a SoundTriggerModule instance", e); } } Loading @@ -97,11 +96,11 @@ public class SoundTriggerMiddlewareImpl implements ISoundTriggerMiddlewareServic } /** * Convenience constructor - gets a single HAL driver instance. * Convenience constructor - gets a single HAL factory. */ public SoundTriggerMiddlewareImpl(@NonNull ISoundTriggerHw halService, public SoundTriggerMiddlewareImpl(@NonNull HalFactory factory, @NonNull AudioSessionProvider audioSessionProvider) { this(new ISoundTriggerHw[]{halService}, audioSessionProvider); this(new HalFactory[]{factory}, audioSessionProvider); } @Override Loading Loading
core/java/android/hardware/soundtrigger/SoundTriggerModule.java +6 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,12 @@ public class SoundTriggerModule { mHandler.sendMessage(m); } @Override public synchronized void onModuleDied() { Message m = mHandler.obtainMessage(EVENT_SERVICE_DIED); mHandler.sendMessage(m); } @Override public synchronized void binderDied() { Message m = mHandler.obtainMessage(EVENT_SERVICE_DIED); Loading
media/java/android/media/soundtrigger_middleware/ISoundTriggerCallback.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,11 @@ oneway interface ISoundTriggerCallback { * and this event will be sent in addition to the abort event. */ void onRecognitionAvailabilityChange(boolean available); /** * Notifies the client that the associated module has crashed and restarted. The module instance * is no longer usable and will throw a ServiceSpecificException with a Status.DEAD_OBJECT code * for every call. The client should detach, then re-attach to the module in order to get a new, * usable instance. All state for this module has been lost. */ void onModuleDied(); }
media/java/android/media/soundtrigger_middleware/Status.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,6 @@ enum Status { OPERATION_NOT_SUPPORTED = 2, /** Temporary lack of permission. */ TEMPORARY_PERMISSION_DENIED = 3, /** The object on which this method is called is dead and all of its state is lost. */ DEAD_OBJECT = 4, }
services/core/java/com/android/server/soundtrigger_middleware/HalFactory.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.soundtrigger_middleware; import android.hardware.soundtrigger.V2_0.ISoundTriggerHw; /** * A factory for creating instances of {@link ISoundTriggerHw}. * * @hide */ public interface HalFactory { /** * @return An instance of {@link ISoundTriggerHw}. */ ISoundTriggerHw create(); }
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareImpl.java +9 −10 Original line number Diff line number Diff line Loading @@ -78,18 +78,17 @@ public class SoundTriggerMiddlewareImpl implements ISoundTriggerMiddlewareServic } /** * Most generic constructor - gets an array of HAL driver instances. * Constructor - gets an array of HAL driver factories. */ public SoundTriggerMiddlewareImpl(@NonNull ISoundTriggerHw[] halServices, public SoundTriggerMiddlewareImpl(@NonNull HalFactory[] halFactories, @NonNull AudioSessionProvider audioSessionProvider) { List<SoundTriggerModule> modules = new ArrayList<>(halServices.length); List<SoundTriggerModule> modules = new ArrayList<>(halFactories.length); for (int i = 0; i < halServices.length; ++i) { ISoundTriggerHw service = halServices[i]; for (int i = 0; i < halFactories.length; ++i) { try { modules.add(new SoundTriggerModule(service, audioSessionProvider)); modules.add(new SoundTriggerModule(halFactories[i], audioSessionProvider)); } catch (Exception e) { Log.e(TAG, "Failed to a SoundTriggerModule instance", e); Log.e(TAG, "Failed to add a SoundTriggerModule instance", e); } } Loading @@ -97,11 +96,11 @@ public class SoundTriggerMiddlewareImpl implements ISoundTriggerMiddlewareServic } /** * Convenience constructor - gets a single HAL driver instance. * Convenience constructor - gets a single HAL factory. */ public SoundTriggerMiddlewareImpl(@NonNull ISoundTriggerHw halService, public SoundTriggerMiddlewareImpl(@NonNull HalFactory factory, @NonNull AudioSessionProvider audioSessionProvider) { this(new ISoundTriggerHw[]{halService}, audioSessionProvider); this(new HalFactory[]{factory}, audioSessionProvider); } @Override Loading