diff options
author | Chris Thornton <thorntonc@google.com> | 2017-03-22 13:50:04 -0700 |
---|---|---|
committer | Chris Thornton <thorntonc@google.com> | 2017-03-22 13:50:04 -0700 |
commit | e492e493f4f1ffd89accd2f8b4e2e0931b0904d9 (patch) | |
tree | 7855110c4a2dee0b2db35748040cafd4ae3fe8dd | |
parent | c79d4388de8cd2de15a077bf840ee03194db1c75 (diff) |
SoundTriggerTestApp: also unload on error conditions
When the service is killed/going down, it should unload all the sound
models it has running as part of being a good citizen.
Test: Kill/stop the service and see that the models are evicted from the
HAL
Change-Id: I6f88c8327682df5870b381d5bafda79e67fb7079
-rw-r--r-- | tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java index a2385d695450..b550cfad74cf 100644 --- a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java +++ b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java @@ -100,7 +100,7 @@ public class SoundTriggerTestService extends Service { @Override public void onDestroy() { super.onDestroy(); - stopAllRecognitions(); + stopAllRecognitionsAndUnload(); unregisterReceiver(mBroadcastReceiver); } @@ -171,7 +171,7 @@ public class SoundTriggerTestService extends Service { @Override public void onTaskRemoved(Intent rootIntent) { super.onTaskRemoved(rootIntent); - stopAllRecognitions(); + stopAllRecognitionsAndUnload(); stopSelf(); } @@ -197,8 +197,10 @@ public class SoundTriggerTestService extends Service { } } - private synchronized void stopAllRecognitions() { + private synchronized void stopAllRecognitionsAndUnload() { + Log.e(TAG, "Stop all recognitions"); for (ModelInfo modelInfo : mModelInfoMap.values()) { + Log.e(TAG, "Loop " + modelInfo.modelUuid); if (modelInfo.detector != null) { Log.i(TAG, "Stopping recognition for " + modelInfo.name); try { @@ -206,6 +208,12 @@ public class SoundTriggerTestService extends Service { } catch (Exception e) { Log.e(TAG, "Failed to stop recognition", e); } + try { + mSoundTriggerUtil.deleteSoundModel(modelInfo.modelUuid); + modelInfo.detector = null; + } catch (Exception e) { + Log.e(TAG, "Failed to unload sound model", e); + } } } } |