Loading services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java +40 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,9 @@ import android.media.soundtrigger_middleware.PhraseSoundModel; import android.media.soundtrigger_middleware.RecognitionConfig; import android.media.soundtrigger_middleware.RecognitionConfig; import android.media.soundtrigger_middleware.SoundModel; import android.media.soundtrigger_middleware.SoundModel; import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; import android.os.Parcel; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemProperties; import android.util.Log; import android.util.Log; import com.android.server.SystemService; import com.android.server.SystemService; Loading Loading @@ -99,6 +101,28 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic } } } } @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { try { return super.onTransact(code, data, reply, flags); } catch (InternalServerError e) { if (e.getCause() instanceof HalException) { // We recover from any sort of HAL failure by rebooting the HAL process. // This will likely reboot more than just the sound trigger HAL. // The rest of the system should be able to tolerate that. rebootHal(); } throw e; } } private static void rebootHal() { Log.i(TAG, "Rebooting the sound trigger HAL"); // This property needs to be defined in an init.rc script and trigger a HAL reboot. SystemProperties.set("sys.audio.restart.hal", "1"); } private final static class ModuleService extends ISoundTriggerModule.Stub { private final static class ModuleService extends ISoundTriggerModule.Stub { private final ISoundTriggerModule mDelegate; private final ISoundTriggerModule mDelegate; Loading @@ -119,7 +143,6 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic @Override @Override public void unloadModel(int modelHandle) throws RemoteException { public void unloadModel(int modelHandle) throws RemoteException { mDelegate.unloadModel(modelHandle); mDelegate.unloadModel(modelHandle); ; } } @Override @Override Loading Loading @@ -159,6 +182,22 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic public void detach() throws RemoteException { public void detach() throws RemoteException { mDelegate.detach(); mDelegate.detach(); } } @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { try { return super.onTransact(code, data, reply, flags); } catch (InternalServerError e) { if (e.getCause() instanceof HalException) { // We recover from any sort of HAL failure by rebooting the HAL process. // This will likely reboot more than just the sound trigger HAL. // The rest of the system should be able to tolerate that. rebootHal(); } throw e; } } } } /** /** Loading services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +1 −7 Original line number Original line Diff line number Diff line Loading @@ -149,13 +149,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware e.getMessage()); e.getMessage()); } } /* Throwing an exception is not enough in this case. When the HAL behaves unexpectedly, the Log.wtf(TAG, "Unexpected exception", e); system service and the HAL must be reset and the client must be notified. Without a full reset in this catastrophic case, the state of the HAL and the system service cannot be guaranteed to the client. */ Log.wtf(TAG, "Crashing system server due to unrecoverable exception", e); Process.killProcess(Process.myPid()); throw new InternalServerError(e); throw new InternalServerError(e); } } Loading Loading
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java +40 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,9 @@ import android.media.soundtrigger_middleware.PhraseSoundModel; import android.media.soundtrigger_middleware.RecognitionConfig; import android.media.soundtrigger_middleware.RecognitionConfig; import android.media.soundtrigger_middleware.SoundModel; import android.media.soundtrigger_middleware.SoundModel; import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; import android.os.Parcel; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemProperties; import android.util.Log; import android.util.Log; import com.android.server.SystemService; import com.android.server.SystemService; Loading Loading @@ -99,6 +101,28 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic } } } } @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { try { return super.onTransact(code, data, reply, flags); } catch (InternalServerError e) { if (e.getCause() instanceof HalException) { // We recover from any sort of HAL failure by rebooting the HAL process. // This will likely reboot more than just the sound trigger HAL. // The rest of the system should be able to tolerate that. rebootHal(); } throw e; } } private static void rebootHal() { Log.i(TAG, "Rebooting the sound trigger HAL"); // This property needs to be defined in an init.rc script and trigger a HAL reboot. SystemProperties.set("sys.audio.restart.hal", "1"); } private final static class ModuleService extends ISoundTriggerModule.Stub { private final static class ModuleService extends ISoundTriggerModule.Stub { private final ISoundTriggerModule mDelegate; private final ISoundTriggerModule mDelegate; Loading @@ -119,7 +143,6 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic @Override @Override public void unloadModel(int modelHandle) throws RemoteException { public void unloadModel(int modelHandle) throws RemoteException { mDelegate.unloadModel(modelHandle); mDelegate.unloadModel(modelHandle); ; } } @Override @Override Loading Loading @@ -159,6 +182,22 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic public void detach() throws RemoteException { public void detach() throws RemoteException { mDelegate.detach(); mDelegate.detach(); } } @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { try { return super.onTransact(code, data, reply, flags); } catch (InternalServerError e) { if (e.getCause() instanceof HalException) { // We recover from any sort of HAL failure by rebooting the HAL process. // This will likely reboot more than just the sound trigger HAL. // The rest of the system should be able to tolerate that. rebootHal(); } throw e; } } } } /** /** Loading
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +1 −7 Original line number Original line Diff line number Diff line Loading @@ -149,13 +149,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware e.getMessage()); e.getMessage()); } } /* Throwing an exception is not enough in this case. When the HAL behaves unexpectedly, the Log.wtf(TAG, "Unexpected exception", e); system service and the HAL must be reset and the client must be notified. Without a full reset in this catastrophic case, the state of the HAL and the system service cannot be guaranteed to the client. */ Log.wtf(TAG, "Crashing system server due to unrecoverable exception", e); Process.killProcess(Process.myPid()); throw new InternalServerError(e); throw new InternalServerError(e); } } Loading