summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ahaan Ugale <augale@google.com> 2021-08-17 20:40:36 -0700
committer Ahaan Ugale <augale@google.com> 2022-06-03 17:17:53 +0000
commitc5e8f7f59d775c42fe53cb99fcbafc5ec005f579 (patch)
tree9c0a1c94ca1a4c4f538241e8bed97cf724a0a5e2
parentbd26701a6b7af3a8152cf17ea245c6a0269923f0 (diff)
RESTRICT AUTOMERGE Disable the Trusted Hotword requirement
The requirement to use a sandboxed HotwordDetectionService to avoid incurring the mic indicator will be added back in a future release. With this change, SoundTrigger events and hotword-source audio do not incur the mic indicator for any process. This change adds back the permissions logic from I3275647d0f9a6e3ce8b97a556f56723b49170c8e, adjusted to account for the changes from I6d63c99e2d31e3f668070ac82afed71ff6672c9e (permissions now checked in LegacyPermissionManagerService and a new op is used). We preserve the behavior of showing the indicator when the detected event is delivered from the Trusted Hotword process (no false-positives here, so we can accurately show it). Fix: 234026976 Test: manual - dsp and non-dsp; true and false positives; mute mic sensor - events aren't delivered and no dialog is shown, hotword still works after unmuting; mute mic and restart, unmute after starting reco; Trusted and non-Trusted hotwording Test: atest CameraMicIndicatorsPermissionTest Test: atest HotwordDetectionServiceBasicTest Test: atest android.cts.statsdatom.appops.AppOpsTests#testAppOps Change-Id: I68f2f37b5ce835e7fd8649b382eaee9fc299ec79 Merged-In: I68f2f37b5ce835e7fd8649b382eaee9fc299ec79 (cherry picked from commit 3f961f24f49d30c73097c96a30b8d922bf1c88d9)
-rw-r--r--services/core/java/com/android/server/pm/permission/LegacyPermissionManagerService.java4
-rw-r--r--services/core/java/com/android/server/policy/AppOpsPolicy.java5
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java13
3 files changed, 10 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/pm/permission/LegacyPermissionManagerService.java b/services/core/java/com/android/server/pm/permission/LegacyPermissionManagerService.java
index 88b4a94f7027..03e568c4599e 100644
--- a/services/core/java/com/android/server/pm/permission/LegacyPermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/LegacyPermissionManagerService.java
@@ -413,8 +413,8 @@ public class LegacyPermissionManagerService extends ILegacyPermissionManager.Stu
return result;
}
mContext.getSystemService(AppOpsManager.class).noteOpNoThrow(
- AppOpsManager.OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, uid, packageName,
- attributionTag, reason);
+ AppOpsManager.OP_RECORD_AUDIO_HOTWORD, uid, packageName, attributionTag,
+ reason);
return result;
}
}
diff --git a/services/core/java/com/android/server/policy/AppOpsPolicy.java b/services/core/java/com/android/server/policy/AppOpsPolicy.java
index a6d148c824c9..ebd9126d1439 100644
--- a/services/core/java/com/android/server/policy/AppOpsPolicy.java
+++ b/services/core/java/com/android/server/policy/AppOpsPolicy.java
@@ -202,9 +202,8 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
}
private static boolean isHotwordDetectionServiceRequired(PackageManager pm) {
- // The HotwordDetectionService APIs aren't ready yet for Auto or TV.
- return !(pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
- || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK));
+ // Usage of the HotwordDetectionService won't be enforced until a later release.
+ return false;
}
@Override
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
index 42d446d058b4..434663bd8167 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
@@ -46,11 +46,9 @@ import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPH
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED;
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED_FROM_RESTART;
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECT_UNEXPECTED_CALLBACK;
-import static com.android.server.voiceinteraction.SoundTriggerSessionPermissionsDecorator.enforcePermissionForPreflight;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.AppOpsManager;
import android.content.ComponentName;
import android.content.ContentCaptureOptions;
import android.content.Context;
@@ -1162,11 +1160,12 @@ final class HotwordDetectionConnection {
// TODO: Share this code with SoundTriggerMiddlewarePermission.
private void enforcePermissionsForDataDelivery() {
Binder.withCleanCallingIdentity(() -> {
- enforcePermissionForPreflight(mContext, mVoiceInteractorIdentity, RECORD_AUDIO);
- int hotwordOp = AppOpsManager.strOpToOp(AppOpsManager.OPSTR_RECORD_AUDIO_HOTWORD);
- mContext.getSystemService(AppOpsManager.class).noteOpNoThrow(hotwordOp,
- mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
- mVoiceInteractorIdentity.attributionTag, OP_MESSAGE);
+ // Hack to make sure we show the mic privacy-indicator since the Trusted Hotword
+ // requirement isn't being enforced for now. Normally, we would note the HOTWORD op here
+ // instead.
+ enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
+ RECORD_AUDIO, OP_MESSAGE);
+
enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
CAPTURE_AUDIO_HOTWORD, OP_MESSAGE);
});