fix calling SoundTriggerMiddleware in safeMode

deleteSoundModel is calling into the SoundTriggerModdleware when safe
mode is enabled. Middleware should not be called in this case.

Bug: 152354427
Test: atest SoundTriggerServiceTest#testServiceDisabledInSafeMode
Change-Id: I1fa13fd32a384b59928a5deb9505dc4a1e757efa
This commit is contained in:
Nicholas Ambur
2020-04-17 10:12:18 -07:00
parent ba749f87d4
commit dc1ea7ce04

View File

@@ -346,12 +346,15 @@ public class SoundTriggerService extends SystemService {
sEventLogger.log(new SoundTriggerLogger.StringEvent("deleteSoundModel(): id = "
+ soundModelId));
// Unload the model if it is loaded.
mSoundTriggerHelper.unloadGenericSoundModel(soundModelId.getUuid());
mDbHelper.deleteGenericSoundModel(soundModelId.getUuid());
if (isInitialized()) {
// Unload the model if it is loaded.
mSoundTriggerHelper.unloadGenericSoundModel(soundModelId.getUuid());
// Stop recognition if it is started.
mSoundModelStatTracker.onStop(soundModelId.getUuid());
// Stop tracking recognition if it is started.
mSoundModelStatTracker.onStop(soundModelId.getUuid());
}
mDbHelper.deleteGenericSoundModel(soundModelId.getUuid());
}
@Override