Loading core/java/android/service/voice/AbstractHotwordDetector.java +11 −6 Original line number Diff line number Diff line Loading @@ -126,21 +126,26 @@ abstract class AbstractHotwordDetector implements HotwordDetector { Slog.d(TAG, "updateState()"); } throwIfDetectorIsNoLongerActive(); synchronized (mLock) { updateStateLocked(options, sharedMemory, null /* callback */, mDetectorType); try { mManagerService.updateState(options, sharedMemory); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } protected void updateStateLocked(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback, protected void initAndVerifyDetector( @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, @NonNull IHotwordRecognitionStatusCallback callback, int detectorType) { if (DEBUG) { Slog.d(TAG, "updateStateLocked()"); Slog.d(TAG, "initAndVerifyDetector()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); try { mManagerService.updateState(identity, options, sharedMemory, callback, detectorType); mManagerService.initAndVerifyDetector(identity, options, sharedMemory, callback, detectorType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +1 −3 Original line number Diff line number Diff line Loading @@ -817,10 +817,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { // TODO: transition to use an API that is not updateState to provide // onHotwordDetectionServiceInitialized status to external callback if (mSupportHotwordDetectionService) { updateStateLocked(options, sharedMemory, mInternalCallback, initAndVerifyDetector(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); } try { Loading core/java/android/service/voice/SoftwareHotwordDetector.java +1 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,7 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { // TODO: transition to use an API that is not updateState to provide // onHotwordDetectionServiceInitialized status to external callback updateStateLocked(options, sharedMemory, initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mHandler, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } Loading core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +18 −1 Original line number Diff line number Diff line Loading @@ -245,6 +245,23 @@ interface IVoiceInteractionManagerService { /** * Set configuration and pass read-only data to hotword detection service. * * @param options Application configuration data to provide to the * {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or * other contents that can be used to communicate with other processes. * @param sharedMemory The unrestricted data blob to provide to the * {@link HotwordDetectionService}. Use this to provide the hotword models data or other * such data to the trusted process. */ @EnforcePermission("MANAGE_HOTWORD_DETECTION") void updateState( in PersistableBundle options, in SharedMemory sharedMemory); /** * Set configuration and pass read-only data to hotword detection service when creating * the detector. * * Caller must provide an identity, used for permission tracking purposes. * The uid/pid elements of the identity will be ignored by the server and replaced with the ones * provided by binder. Loading @@ -259,7 +276,7 @@ interface IVoiceInteractionManagerService { * @param detectorType Indicate which detector is used. */ @EnforcePermission("MANAGE_HOTWORD_DETECTION") void updateState( void initAndVerifyDetector( in Identity originatorIdentity, in PersistableBundle options, in SharedMemory sharedMemory, Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +16 −12 Original line number Diff line number Diff line Loading @@ -1242,6 +1242,19 @@ public class VoiceInteractionManagerService extends SystemService { @android.annotation.EnforcePermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) @Override public void updateState( @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { synchronized (this) { enforceIsCurrentVoiceInteractionService(); Binder.withCleanCallingIdentity( () -> mImpl.updateStateLocked(options, sharedMemory)); } } @android.annotation.EnforcePermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) @Override public void initAndVerifyDetector( @NonNull Identity voiceInteractorIdentity, @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, Loading @@ -1250,21 +1263,12 @@ public class VoiceInteractionManagerService extends SystemService { synchronized (this) { enforceIsCurrentVoiceInteractionService(); if (mImpl == null) { Slog.w(TAG, "updateState without running voice interaction service"); return; } voiceInteractorIdentity.uid = Binder.getCallingUid(); voiceInteractorIdentity.pid = Binder.getCallingPid(); final long caller = Binder.clearCallingIdentity(); try { mImpl.updateStateLocked( voiceInteractorIdentity, options, sharedMemory, callback, detectorType); } finally { Binder.restoreCallingIdentity(caller); } Binder.withCleanCallingIdentity( () -> mImpl.initAndVerifyDetectorLocked(voiceInteractorIdentity, options, sharedMemory, callback, detectorType)); } } Loading Loading
core/java/android/service/voice/AbstractHotwordDetector.java +11 −6 Original line number Diff line number Diff line Loading @@ -126,21 +126,26 @@ abstract class AbstractHotwordDetector implements HotwordDetector { Slog.d(TAG, "updateState()"); } throwIfDetectorIsNoLongerActive(); synchronized (mLock) { updateStateLocked(options, sharedMemory, null /* callback */, mDetectorType); try { mManagerService.updateState(options, sharedMemory); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } protected void updateStateLocked(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback, protected void initAndVerifyDetector( @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, @NonNull IHotwordRecognitionStatusCallback callback, int detectorType) { if (DEBUG) { Slog.d(TAG, "updateStateLocked()"); Slog.d(TAG, "initAndVerifyDetector()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); try { mManagerService.updateState(identity, options, sharedMemory, callback, detectorType); mManagerService.initAndVerifyDetector(identity, options, sharedMemory, callback, detectorType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +1 −3 Original line number Diff line number Diff line Loading @@ -817,10 +817,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { // TODO: transition to use an API that is not updateState to provide // onHotwordDetectionServiceInitialized status to external callback if (mSupportHotwordDetectionService) { updateStateLocked(options, sharedMemory, mInternalCallback, initAndVerifyDetector(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); } try { Loading
core/java/android/service/voice/SoftwareHotwordDetector.java +1 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,7 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { // TODO: transition to use an API that is not updateState to provide // onHotwordDetectionServiceInitialized status to external callback updateStateLocked(options, sharedMemory, initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mHandler, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } Loading
core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +18 −1 Original line number Diff line number Diff line Loading @@ -245,6 +245,23 @@ interface IVoiceInteractionManagerService { /** * Set configuration and pass read-only data to hotword detection service. * * @param options Application configuration data to provide to the * {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or * other contents that can be used to communicate with other processes. * @param sharedMemory The unrestricted data blob to provide to the * {@link HotwordDetectionService}. Use this to provide the hotword models data or other * such data to the trusted process. */ @EnforcePermission("MANAGE_HOTWORD_DETECTION") void updateState( in PersistableBundle options, in SharedMemory sharedMemory); /** * Set configuration and pass read-only data to hotword detection service when creating * the detector. * * Caller must provide an identity, used for permission tracking purposes. * The uid/pid elements of the identity will be ignored by the server and replaced with the ones * provided by binder. Loading @@ -259,7 +276,7 @@ interface IVoiceInteractionManagerService { * @param detectorType Indicate which detector is used. */ @EnforcePermission("MANAGE_HOTWORD_DETECTION") void updateState( void initAndVerifyDetector( in Identity originatorIdentity, in PersistableBundle options, in SharedMemory sharedMemory, Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +16 −12 Original line number Diff line number Diff line Loading @@ -1242,6 +1242,19 @@ public class VoiceInteractionManagerService extends SystemService { @android.annotation.EnforcePermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) @Override public void updateState( @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { synchronized (this) { enforceIsCurrentVoiceInteractionService(); Binder.withCleanCallingIdentity( () -> mImpl.updateStateLocked(options, sharedMemory)); } } @android.annotation.EnforcePermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) @Override public void initAndVerifyDetector( @NonNull Identity voiceInteractorIdentity, @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, Loading @@ -1250,21 +1263,12 @@ public class VoiceInteractionManagerService extends SystemService { synchronized (this) { enforceIsCurrentVoiceInteractionService(); if (mImpl == null) { Slog.w(TAG, "updateState without running voice interaction service"); return; } voiceInteractorIdentity.uid = Binder.getCallingUid(); voiceInteractorIdentity.pid = Binder.getCallingPid(); final long caller = Binder.clearCallingIdentity(); try { mImpl.updateStateLocked( voiceInteractorIdentity, options, sharedMemory, callback, detectorType); } finally { Binder.restoreCallingIdentity(caller); } Binder.withCleanCallingIdentity( () -> mImpl.initAndVerifyDetectorLocked(voiceInteractorIdentity, options, sharedMemory, callback, detectorType)); } } Loading