diff options
| author | Ytai Ben-tsvi <ytai@google.com> | 2020-04-13 16:27:34 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-13 16:27:34 +0000 |
| commit | 1c233bcccf5356157b968c3ad3df1a596aa6965c (patch) | |
| tree | f3753bbb495242d08525404925127ac3fbd27458 | |
| parent | 6879bcb0b100d590aa9776b53b60c638f2f953dd (diff) | |
| parent | 8ef3e05ccc610ef8079d92e93cf628216d56d012 (diff) | |
Merge "Reboot the soundtrigger HAL on failure" into rvc-dev am: 8ef3e05ccc
Change-Id: I33183ed311c96f48d9631c0ba6384f753782f9fe
2 files changed, 41 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java b/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java index 929d92f56c44..635cb613b934 100644 --- a/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java +++ b/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareService.java @@ -27,7 +27,9 @@ import android.media.soundtrigger_middleware.PhraseSoundModel; import android.media.soundtrigger_middleware.RecognitionConfig; import android.media.soundtrigger_middleware.SoundModel; import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor; +import android.os.Parcel; import android.os.RemoteException; +import android.os.SystemProperties; import android.util.Log; import com.android.server.SystemService; @@ -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 ISoundTriggerModule mDelegate; @@ -119,7 +143,6 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic @Override public void unloadModel(int modelHandle) throws RemoteException { mDelegate.unloadModel(modelHandle); - ; } @Override @@ -159,6 +182,22 @@ public class SoundTriggerMiddlewareService extends ISoundTriggerMiddlewareServic public void detach() throws RemoteException { 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; + } + } } /** diff --git a/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java b/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java index da1b7f3113c4..23259558eeb7 100644 --- a/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +++ b/services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java @@ -149,13 +149,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware e.getMessage()); } - /* Throwing an exception is not enough in this case. When the HAL behaves unexpectedly, the - 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()); + Log.wtf(TAG, "Unexpected exception", e); throw new InternalServerError(e); } |
