Loading services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +10 −8 Original line number Diff line number Diff line Loading @@ -783,15 +783,17 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware @Override public void onModuleDied() { synchronized (SoundTriggerMiddlewareValidation.this) { try { mState = ModuleStatus.DEAD; } // Trigger the callback outside of the lock to avoid deadlocks. try { mCallback.onModuleDied(); } catch (RemoteException e) { // Dead client will be handled by binderDied() - no need to handle here. // In any case, client callbacks are considered best effort. Log.e(TAG, "Client callback exception.", e); } } } @Override Loading services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerModule.java +23 −12 Original line number Diff line number Diff line Loading @@ -35,8 +35,10 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.util.Log; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -166,13 +168,24 @@ class SoundTriggerModule implements IHwBinder.DeathRecipient { } @Override public synchronized void serviceDied(long cookie) { public void serviceDied(long cookie) { Log.w(TAG, String.format("Underlying HAL driver died.")); List<ISoundTriggerCallback> callbacks = new ArrayList<>(mActiveSessions.size()); synchronized (this) { for (Session session : mActiveSessions) { session.moduleDied(); callbacks.add(session.moduleDied()); } reset(); } // Trigger the callbacks outside of the lock to avoid deadlocks. for (ISoundTriggerCallback callback : callbacks) { try { callback.onModuleDied(); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } } /** * Resets the transient state of this object. Loading Loading @@ -379,15 +392,13 @@ class SoundTriggerModule implements IHwBinder.DeathRecipient { /** * The underlying module HAL is dead. * @return The client callback that needs to be invoked to notify the client. */ private void moduleDied() { try { mCallback.onModuleDied(); private ISoundTriggerCallback moduleDied() { ISoundTriggerCallback callback = mCallback; removeSession(this); mCallback = null; } catch (RemoteException e) { e.rethrowAsRuntimeException(); } return callback; } private void checkValid() { Loading Loading
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +10 −8 Original line number Diff line number Diff line Loading @@ -783,15 +783,17 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware @Override public void onModuleDied() { synchronized (SoundTriggerMiddlewareValidation.this) { try { mState = ModuleStatus.DEAD; } // Trigger the callback outside of the lock to avoid deadlocks. try { mCallback.onModuleDied(); } catch (RemoteException e) { // Dead client will be handled by binderDied() - no need to handle here. // In any case, client callbacks are considered best effort. Log.e(TAG, "Client callback exception.", e); } } } @Override Loading
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerModule.java +23 −12 Original line number Diff line number Diff line Loading @@ -35,8 +35,10 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.util.Log; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -166,13 +168,24 @@ class SoundTriggerModule implements IHwBinder.DeathRecipient { } @Override public synchronized void serviceDied(long cookie) { public void serviceDied(long cookie) { Log.w(TAG, String.format("Underlying HAL driver died.")); List<ISoundTriggerCallback> callbacks = new ArrayList<>(mActiveSessions.size()); synchronized (this) { for (Session session : mActiveSessions) { session.moduleDied(); callbacks.add(session.moduleDied()); } reset(); } // Trigger the callbacks outside of the lock to avoid deadlocks. for (ISoundTriggerCallback callback : callbacks) { try { callback.onModuleDied(); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } } /** * Resets the transient state of this object. Loading Loading @@ -379,15 +392,13 @@ class SoundTriggerModule implements IHwBinder.DeathRecipient { /** * The underlying module HAL is dead. * @return The client callback that needs to be invoked to notify the client. */ private void moduleDied() { try { mCallback.onModuleDied(); private ISoundTriggerCallback moduleDied() { ISoundTriggerCallback callback = mCallback; removeSession(this); mCallback = null; } catch (RemoteException e) { e.rethrowAsRuntimeException(); } return callback; } private void checkValid() { Loading