Loading core/java/android/service/voice/AbstractDetector.java +12 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ abstract class AbstractDetector implements HotwordDetector { */ private final IBinder mToken = new Binder(); /** * A flag controls whether attributionTag will be passed into the Identity. * TODO(b/289087412): This flag will be converted and confirm to the trunk stable flag * configuration. */ static final boolean IS_IDENTITY_WITH_ATTRIBUTION_TAG = false; AbstractDetector( IVoiceInteractionManagerService managerService, Executor executor, Loading Loading @@ -153,12 +160,16 @@ abstract class AbstractDetector implements HotwordDetector { @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, @NonNull IHotwordRecognitionStatusCallback callback, int detectorType) { int detectorType, @Nullable String attributionTag) { if (DEBUG) { Slog.d(TAG, "initAndVerifyDetector()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); if (IS_IDENTITY_WITH_ATTRIBUTION_TAG) { identity.attributionTag = attributionTag; } try { mManagerService.initAndVerifyDetector(identity, options, sharedMemory, mToken, callback, detectorType); Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +11 −2 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { private final Handler mHandler; private final IBinder mBinder = new Binder(); private final boolean mSupportSandboxedDetectionService; private final String mAttributionTag; @GuardedBy("mLock") private boolean mIsAvailabilityOverriddenByTestApi = false; Loading Loading @@ -846,13 +847,17 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { * @param targetSdkVersion The target SDK version. * @param SupportSandboxedDetectionService {@code true} if HotwordDetectionService should be * triggered, otherwise {@code false}. * @param attributionTag an optional attribution tag passed form the * {@link VoiceInteractionService} context via the * {@link createAlwaysOnHotwordDetectorInternal(String, Locale, boolean, PersistableBundle, * SharedMemory, ModuleProperties, Executor, Callback)}. * * @hide */ public AlwaysOnHotwordDetector(String text, Locale locale, Executor executor, Callback callback, KeyphraseEnrollmentInfo keyphraseEnrollmentInfo, IVoiceInteractionManagerService modelManagementService, int targetSdkVersion, boolean supportSandboxedDetectionService) { boolean supportSandboxedDetectionService, @Nullable String attributionTag) { super(modelManagementService, executor, callback); mHandler = new MyHandler(Looper.getMainLooper()); Loading @@ -865,6 +870,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { mInternalCallback = new SoundTriggerListener(mHandler); mModelManagementService = modelManagementService; mSupportSandboxedDetectionService = supportSandboxedDetectionService; mAttributionTag = attributionTag; } // Do nothing. This method should not be abstract. Loading @@ -876,11 +882,14 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { @Nullable SoundTrigger.ModuleProperties moduleProperties) { if (mSupportSandboxedDetectionService) { initAndVerifyDetector(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); DETECTOR_TYPE_TRUSTED_HOTWORD_DSP, mAttributionTag); } try { Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); if (IS_IDENTITY_WITH_ATTRIBUTION_TAG) { identity.attributionTag = mAttributionTag; } if (moduleProperties == null) { moduleProperties = mModelManagementService .listModuleProperties(identity) Loading core/java/android/service/voice/SoftwareHotwordDetector.java +5 −2 Original line number Diff line number Diff line Loading @@ -56,12 +56,14 @@ class SoftwareHotwordDetector extends AbstractDetector { private final HotwordDetector.Callback mCallback; private final AudioFormat mAudioFormat; private final Executor mExecutor; private final String mAttributionTag; SoftwareHotwordDetector( IVoiceInteractionManagerService managerService, AudioFormat audioFormat, Executor executor, HotwordDetector.Callback callback) { HotwordDetector.Callback callback, String attributionTag) { super(managerService, executor, callback); mManagerService = managerService; Loading @@ -69,13 +71,14 @@ class SoftwareHotwordDetector extends AbstractDetector { mCallback = callback; mExecutor = executor != null ? executor : new HandlerExecutor( new Handler(Looper.getMainLooper())); mAttributionTag = attributionTag; } @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mExecutor, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE, mAttributionTag); } void onDetectorRemoteException() { Loading core/java/android/service/voice/VisualQueryDetector.java +4 −2 Original line number Diff line number Diff line Loading @@ -60,15 +60,17 @@ public class VisualQueryDetector { private final Executor mExecutor; private final IVoiceInteractionManagerService mManagerService; private final VisualQueryDetectorInitializationDelegate mInitializationDelegate; private final String mAttributionTag; VisualQueryDetector( IVoiceInteractionManagerService managerService, @NonNull @CallbackExecutor Executor executor, Callback callback) { Callback callback, @Nullable String attributionTag) { mManagerService = managerService; mCallback = callback; mExecutor = executor; mInitializationDelegate = new VisualQueryDetectorInitializationDelegate(); mAttributionTag = attributionTag; } /** Loading Loading @@ -246,7 +248,7 @@ public class VisualQueryDetector { void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mExecutor, mCallback), DETECTOR_TYPE_VISUAL_QUERY_DETECTOR); DETECTOR_TYPE_VISUAL_QUERY_DETECTOR, mAttributionTag); } @Override Loading core/java/android/service/voice/VoiceInteractionService.java +4 −3 Original line number Diff line number Diff line Loading @@ -734,7 +734,7 @@ public class VoiceInteractionService extends Service { AlwaysOnHotwordDetector dspDetector = new AlwaysOnHotwordDetector(keyphrase, locale, executor, callback, mKeyphraseEnrollmentInfo, mSystemService, getApplicationContext().getApplicationInfo().targetSdkVersion, supportHotwordDetectionService); supportHotwordDetectionService, getAttributionTag()); mActiveDetectors.add(dspDetector); try { Loading Loading @@ -895,7 +895,7 @@ public class VoiceInteractionService extends Service { SoftwareHotwordDetector softwareHotwordDetector = new SoftwareHotwordDetector(mSystemService, /* audioFormat= */ null, executor, callback); executor, callback, getAttributionTag()); mActiveDetectors.add(softwareHotwordDetector); try { Loading Loading @@ -965,7 +965,8 @@ public class VoiceInteractionService extends Service { } VisualQueryDetector visualQueryDetector = new VisualQueryDetector(mSystemService, executor, callback); new VisualQueryDetector(mSystemService, executor, callback, getAttributionTag()); HotwordDetector visualQueryDetectorInitializationDelegate = visualQueryDetector.getInitializationDelegate(); mActiveDetectors.add(visualQueryDetectorInitializationDelegate); Loading Loading
core/java/android/service/voice/AbstractDetector.java +12 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ abstract class AbstractDetector implements HotwordDetector { */ private final IBinder mToken = new Binder(); /** * A flag controls whether attributionTag will be passed into the Identity. * TODO(b/289087412): This flag will be converted and confirm to the trunk stable flag * configuration. */ static final boolean IS_IDENTITY_WITH_ATTRIBUTION_TAG = false; AbstractDetector( IVoiceInteractionManagerService managerService, Executor executor, Loading Loading @@ -153,12 +160,16 @@ abstract class AbstractDetector implements HotwordDetector { @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, @NonNull IHotwordRecognitionStatusCallback callback, int detectorType) { int detectorType, @Nullable String attributionTag) { if (DEBUG) { Slog.d(TAG, "initAndVerifyDetector()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); if (IS_IDENTITY_WITH_ATTRIBUTION_TAG) { identity.attributionTag = attributionTag; } try { mManagerService.initAndVerifyDetector(identity, options, sharedMemory, mToken, callback, detectorType); Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +11 −2 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { private final Handler mHandler; private final IBinder mBinder = new Binder(); private final boolean mSupportSandboxedDetectionService; private final String mAttributionTag; @GuardedBy("mLock") private boolean mIsAvailabilityOverriddenByTestApi = false; Loading Loading @@ -846,13 +847,17 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { * @param targetSdkVersion The target SDK version. * @param SupportSandboxedDetectionService {@code true} if HotwordDetectionService should be * triggered, otherwise {@code false}. * @param attributionTag an optional attribution tag passed form the * {@link VoiceInteractionService} context via the * {@link createAlwaysOnHotwordDetectorInternal(String, Locale, boolean, PersistableBundle, * SharedMemory, ModuleProperties, Executor, Callback)}. * * @hide */ public AlwaysOnHotwordDetector(String text, Locale locale, Executor executor, Callback callback, KeyphraseEnrollmentInfo keyphraseEnrollmentInfo, IVoiceInteractionManagerService modelManagementService, int targetSdkVersion, boolean supportSandboxedDetectionService) { boolean supportSandboxedDetectionService, @Nullable String attributionTag) { super(modelManagementService, executor, callback); mHandler = new MyHandler(Looper.getMainLooper()); Loading @@ -865,6 +870,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { mInternalCallback = new SoundTriggerListener(mHandler); mModelManagementService = modelManagementService; mSupportSandboxedDetectionService = supportSandboxedDetectionService; mAttributionTag = attributionTag; } // Do nothing. This method should not be abstract. Loading @@ -876,11 +882,14 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { @Nullable SoundTrigger.ModuleProperties moduleProperties) { if (mSupportSandboxedDetectionService) { initAndVerifyDetector(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); DETECTOR_TYPE_TRUSTED_HOTWORD_DSP, mAttributionTag); } try { Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); if (IS_IDENTITY_WITH_ATTRIBUTION_TAG) { identity.attributionTag = mAttributionTag; } if (moduleProperties == null) { moduleProperties = mModelManagementService .listModuleProperties(identity) Loading
core/java/android/service/voice/SoftwareHotwordDetector.java +5 −2 Original line number Diff line number Diff line Loading @@ -56,12 +56,14 @@ class SoftwareHotwordDetector extends AbstractDetector { private final HotwordDetector.Callback mCallback; private final AudioFormat mAudioFormat; private final Executor mExecutor; private final String mAttributionTag; SoftwareHotwordDetector( IVoiceInteractionManagerService managerService, AudioFormat audioFormat, Executor executor, HotwordDetector.Callback callback) { HotwordDetector.Callback callback, String attributionTag) { super(managerService, executor, callback); mManagerService = managerService; Loading @@ -69,13 +71,14 @@ class SoftwareHotwordDetector extends AbstractDetector { mCallback = callback; mExecutor = executor != null ? executor : new HandlerExecutor( new Handler(Looper.getMainLooper())); mAttributionTag = attributionTag; } @Override void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mExecutor, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE, mAttributionTag); } void onDetectorRemoteException() { Loading
core/java/android/service/voice/VisualQueryDetector.java +4 −2 Original line number Diff line number Diff line Loading @@ -60,15 +60,17 @@ public class VisualQueryDetector { private final Executor mExecutor; private final IVoiceInteractionManagerService mManagerService; private final VisualQueryDetectorInitializationDelegate mInitializationDelegate; private final String mAttributionTag; VisualQueryDetector( IVoiceInteractionManagerService managerService, @NonNull @CallbackExecutor Executor executor, Callback callback) { Callback callback, @Nullable String attributionTag) { mManagerService = managerService; mCallback = callback; mExecutor = executor; mInitializationDelegate = new VisualQueryDetectorInitializationDelegate(); mAttributionTag = attributionTag; } /** Loading Loading @@ -246,7 +248,7 @@ public class VisualQueryDetector { void initialize(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { initAndVerifyDetector(options, sharedMemory, new InitializationStateListener(mExecutor, mCallback), DETECTOR_TYPE_VISUAL_QUERY_DETECTOR); DETECTOR_TYPE_VISUAL_QUERY_DETECTOR, mAttributionTag); } @Override Loading
core/java/android/service/voice/VoiceInteractionService.java +4 −3 Original line number Diff line number Diff line Loading @@ -734,7 +734,7 @@ public class VoiceInteractionService extends Service { AlwaysOnHotwordDetector dspDetector = new AlwaysOnHotwordDetector(keyphrase, locale, executor, callback, mKeyphraseEnrollmentInfo, mSystemService, getApplicationContext().getApplicationInfo().targetSdkVersion, supportHotwordDetectionService); supportHotwordDetectionService, getAttributionTag()); mActiveDetectors.add(dspDetector); try { Loading Loading @@ -895,7 +895,7 @@ public class VoiceInteractionService extends Service { SoftwareHotwordDetector softwareHotwordDetector = new SoftwareHotwordDetector(mSystemService, /* audioFormat= */ null, executor, callback); executor, callback, getAttributionTag()); mActiveDetectors.add(softwareHotwordDetector); try { Loading Loading @@ -965,7 +965,8 @@ public class VoiceInteractionService extends Service { } VisualQueryDetector visualQueryDetector = new VisualQueryDetector(mSystemService, executor, callback); new VisualQueryDetector(mSystemService, executor, callback, getAttributionTag()); HotwordDetector visualQueryDetectorInitializationDelegate = visualQueryDetector.getInitializationDelegate(); mActiveDetectors.add(visualQueryDetectorInitializationDelegate); Loading