Loading core/java/com/android/internal/app/ISoundTriggerSession.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ interface ISoundTriggerSession { void deleteSoundModel(in ParcelUuid soundModelId); int startRecognition(in ParcelUuid soundModelId, in IRecognitionStatusCallback callback, int startRecognition(in SoundTrigger.GenericSoundModel soundModel, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig config, boolean runInBatterySaver); int stopRecognition(in ParcelUuid soundModelId, in IRecognitionStatusCallback callback); Loading media/java/android/media/soundtrigger/SoundTriggerDetector.java +8 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.hardware.soundtrigger.IRecognitionStatusCallback; import android.hardware.soundtrigger.SoundTrigger; import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel; import android.hardware.soundtrigger.SoundTrigger.ModuleProperties; import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig; import android.media.AudioFormat; Loading @@ -50,6 +51,7 @@ import java.util.UUID; * VoiceInteractionService} instead. Access to this class is protected by a permission * granted only to system or privileged apps. * @deprecated use {@link SoundTriggerManager} directly * * @hide */ @Deprecated Loading @@ -67,7 +69,7 @@ public final class SoundTriggerDetector { private final Object mLock = new Object(); private final ISoundTriggerSession mSoundTriggerSession; private final UUID mSoundModelId; private final GenericSoundModel mSoundModel; private final Callback mCallback; private final Handler mHandler; private final RecognitionCallback mRecognitionCallback; Loading Loading @@ -277,10 +279,11 @@ public final class SoundTriggerDetector { * This class should be constructed by the {@link SoundTriggerManager}. * @hide */ SoundTriggerDetector(ISoundTriggerSession soundTriggerSession, UUID soundModelId, SoundTriggerDetector(ISoundTriggerSession soundTriggerSession, @NonNull GenericSoundModel soundModel, @NonNull Callback callback, @Nullable Handler handler) { mSoundTriggerSession = soundTriggerSession; mSoundModelId = soundModelId; mSoundModel = soundModel; mCallback = callback; if (handler == null) { mHandler = new MyHandler(); Loading Loading @@ -320,7 +323,7 @@ public final class SoundTriggerDetector { int status; try { status = mSoundTriggerSession.startRecognition(new ParcelUuid(mSoundModelId), status = mSoundTriggerSession.startRecognition(mSoundModel, mRecognitionCallback, new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, null, null, audioCapabilities), runInBatterySaver); Loading @@ -339,7 +342,7 @@ public final class SoundTriggerDetector { public boolean stopRecognition() { int status = STATUS_OK; try { status = mSoundTriggerSession.stopRecognition(new ParcelUuid(mSoundModelId), status = mSoundTriggerSession.stopRecognition(new ParcelUuid(mSoundModel.getUuid()), mRecognitionCallback); } catch (RemoteException e) { return false; Loading media/java/android/media/soundtrigger/SoundTriggerManager.java +10 −5 Original line number Diff line number Diff line Loading @@ -184,10 +184,15 @@ public final class SoundTriggerManager { if (oldInstance != null) { // Shutdown old instance. } try { SoundTriggerDetector newInstance = new SoundTriggerDetector(mSoundTriggerSession, soundModelId, callback, handler); mSoundTriggerSession.getSoundModel(new ParcelUuid(soundModelId)), callback, handler); mReceiverInstanceMap.put(soundModelId, newInstance); return newInstance; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +14 −17 Original line number Diff line number Diff line Loading @@ -298,35 +298,33 @@ public class SoundTriggerService extends SystemService { } @Override public int startRecognition(ParcelUuid parcelUuid, IRecognitionStatusCallback callback, public int startRecognition(GenericSoundModel soundModel, IRecognitionStatusCallback callback, RecognitionConfig config, boolean runInBatterySaverMode) { try (SafeCloseable ignored = ClearCallingIdentityContext.create()) { enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER); if (soundModel == null) { Slog.e(TAG, "Null model passed to startRecognition"); return STATUS_ERROR; } if (runInBatterySaverMode) { enforceCallingPermission(Manifest.permission.SOUND_TRIGGER_RUN_IN_BATTERY_SAVER); } if (DEBUG) { Slog.i(TAG, "startRecognition(): Uuid : " + parcelUuid); Slog.i(TAG, "startRecognition(): Uuid : " + soundModel.toString()); } sEventLogger.enqueue(new EventLogger.StringEvent( "startRecognition(): Uuid : " + parcelUuid)); GenericSoundModel model = getSoundModel(parcelUuid); if (model == null) { Slog.w(TAG, "Null model in database for id: " + parcelUuid); sEventLogger.enqueue(new EventLogger.StringEvent( "startRecognition(): Null model in database for id: " + parcelUuid)); return STATUS_ERROR; } "startRecognition(): Uuid : " + soundModel.getUuid().toString())); int ret = mSoundTriggerHelper.startGenericRecognition(parcelUuid.getUuid(), model, int ret = mSoundTriggerHelper.startGenericRecognition(soundModel.getUuid(), soundModel, callback, config, runInBatterySaverMode); if (ret == STATUS_OK) { mSoundModelStatTracker.onStart(parcelUuid.getUuid()); mSoundModelStatTracker.onStart(soundModel.getUuid()); } return ret; } Loading Loading @@ -379,7 +377,6 @@ public class SoundTriggerService extends SystemService { sEventLogger.enqueue(new EventLogger.StringEvent("updateSoundModel(): model = " + soundModel)); mDbHelper.updateGenericSoundModel(soundModel); } } Loading Loading
core/java/com/android/internal/app/ISoundTriggerSession.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ interface ISoundTriggerSession { void deleteSoundModel(in ParcelUuid soundModelId); int startRecognition(in ParcelUuid soundModelId, in IRecognitionStatusCallback callback, int startRecognition(in SoundTrigger.GenericSoundModel soundModel, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig config, boolean runInBatterySaver); int stopRecognition(in ParcelUuid soundModelId, in IRecognitionStatusCallback callback); Loading
media/java/android/media/soundtrigger/SoundTriggerDetector.java +8 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.hardware.soundtrigger.IRecognitionStatusCallback; import android.hardware.soundtrigger.SoundTrigger; import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel; import android.hardware.soundtrigger.SoundTrigger.ModuleProperties; import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig; import android.media.AudioFormat; Loading @@ -50,6 +51,7 @@ import java.util.UUID; * VoiceInteractionService} instead. Access to this class is protected by a permission * granted only to system or privileged apps. * @deprecated use {@link SoundTriggerManager} directly * * @hide */ @Deprecated Loading @@ -67,7 +69,7 @@ public final class SoundTriggerDetector { private final Object mLock = new Object(); private final ISoundTriggerSession mSoundTriggerSession; private final UUID mSoundModelId; private final GenericSoundModel mSoundModel; private final Callback mCallback; private final Handler mHandler; private final RecognitionCallback mRecognitionCallback; Loading Loading @@ -277,10 +279,11 @@ public final class SoundTriggerDetector { * This class should be constructed by the {@link SoundTriggerManager}. * @hide */ SoundTriggerDetector(ISoundTriggerSession soundTriggerSession, UUID soundModelId, SoundTriggerDetector(ISoundTriggerSession soundTriggerSession, @NonNull GenericSoundModel soundModel, @NonNull Callback callback, @Nullable Handler handler) { mSoundTriggerSession = soundTriggerSession; mSoundModelId = soundModelId; mSoundModel = soundModel; mCallback = callback; if (handler == null) { mHandler = new MyHandler(); Loading Loading @@ -320,7 +323,7 @@ public final class SoundTriggerDetector { int status; try { status = mSoundTriggerSession.startRecognition(new ParcelUuid(mSoundModelId), status = mSoundTriggerSession.startRecognition(mSoundModel, mRecognitionCallback, new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, null, null, audioCapabilities), runInBatterySaver); Loading @@ -339,7 +342,7 @@ public final class SoundTriggerDetector { public boolean stopRecognition() { int status = STATUS_OK; try { status = mSoundTriggerSession.stopRecognition(new ParcelUuid(mSoundModelId), status = mSoundTriggerSession.stopRecognition(new ParcelUuid(mSoundModel.getUuid()), mRecognitionCallback); } catch (RemoteException e) { return false; Loading
media/java/android/media/soundtrigger/SoundTriggerManager.java +10 −5 Original line number Diff line number Diff line Loading @@ -184,10 +184,15 @@ public final class SoundTriggerManager { if (oldInstance != null) { // Shutdown old instance. } try { SoundTriggerDetector newInstance = new SoundTriggerDetector(mSoundTriggerSession, soundModelId, callback, handler); mSoundTriggerSession.getSoundModel(new ParcelUuid(soundModelId)), callback, handler); mReceiverInstanceMap.put(soundModelId, newInstance); return newInstance; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +14 −17 Original line number Diff line number Diff line Loading @@ -298,35 +298,33 @@ public class SoundTriggerService extends SystemService { } @Override public int startRecognition(ParcelUuid parcelUuid, IRecognitionStatusCallback callback, public int startRecognition(GenericSoundModel soundModel, IRecognitionStatusCallback callback, RecognitionConfig config, boolean runInBatterySaverMode) { try (SafeCloseable ignored = ClearCallingIdentityContext.create()) { enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER); if (soundModel == null) { Slog.e(TAG, "Null model passed to startRecognition"); return STATUS_ERROR; } if (runInBatterySaverMode) { enforceCallingPermission(Manifest.permission.SOUND_TRIGGER_RUN_IN_BATTERY_SAVER); } if (DEBUG) { Slog.i(TAG, "startRecognition(): Uuid : " + parcelUuid); Slog.i(TAG, "startRecognition(): Uuid : " + soundModel.toString()); } sEventLogger.enqueue(new EventLogger.StringEvent( "startRecognition(): Uuid : " + parcelUuid)); GenericSoundModel model = getSoundModel(parcelUuid); if (model == null) { Slog.w(TAG, "Null model in database for id: " + parcelUuid); sEventLogger.enqueue(new EventLogger.StringEvent( "startRecognition(): Null model in database for id: " + parcelUuid)); return STATUS_ERROR; } "startRecognition(): Uuid : " + soundModel.getUuid().toString())); int ret = mSoundTriggerHelper.startGenericRecognition(parcelUuid.getUuid(), model, int ret = mSoundTriggerHelper.startGenericRecognition(soundModel.getUuid(), soundModel, callback, config, runInBatterySaverMode); if (ret == STATUS_OK) { mSoundModelStatTracker.onStart(parcelUuid.getUuid()); mSoundModelStatTracker.onStart(soundModel.getUuid()); } return ret; } Loading Loading @@ -379,7 +377,6 @@ public class SoundTriggerService extends SystemService { sEventLogger.enqueue(new EventLogger.StringEvent("updateSoundModel(): model = " + soundModel)); mDbHelper.updateGenericSoundModel(soundModel); } } Loading