Ambient Activation p1.1
This change is intended to pass the attributionTag the assistant app provides, to the AOHD, VQD and AOHD ctor, and to the Identity for attributing ops when delivering data to the Interactor. Changes are flag protected by the boolean IS_IDENTITY_WITH_ATTRIBUTION_TAG set to false as default. Bug: 287264308 Bug: 290642124 Test: manual-tested with test apk which provides attributionTag and verified by adb shell dumpsys appops --package PACKAGE_NAME Change-Id: I69c8f90af02c36042639bfa8605bbb84ed4c00d9
This commit is contained in:
@@ -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,
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -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());
|
||||
@@ -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.
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user