summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author fayey <fayey@google.com> 2023-10-13 00:16:07 +0000
committer Faye Yan <fayey@google.com> 2023-10-18 00:11:11 +0000
commit194927bde7f2f47973fe194e580019fa7bc55f62 (patch)
tree899112e5ab62dd26a549f36a5eadb5c165d9878c
parent2372b07d00f6b78228ce85e1656147a7d76eff3f (diff)
When the user changes the OP_RECEIVE_SANDBOX_TRIGGER_AUDIO op mode to MODE_ERRORED via UI toggle, the following actions will be taken to prevent the assistant app from being voice-activated:
1. No OP_RECEIVE_SANDBOX_TRIGGER_AUDIO will be noted and Voice activation is stopped and assistant app will not be triggered. 2. All initialized trusted AOHD/SoftwareHD, HotwordDetectionSession, and SoundTriggerSession (if DSP) needs to be confirmed to be destroyed. The assistant app is no longer able to be activated by voice. 3. If the user change the op mode back to MODE_ALLOWED or MODE_DEFAULT, the voice activation should be resumed immediately. This change only implement the task 1 and the thrown security exception destroyed the detection session etc. Task 2 & 3 is tracked by b/305099192. Bug: 305099192 Test: presubmit Change-Id: I4160bd3011c931fe44d3cbb9612be08560fdbabc
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java
index 42b08e3c5442..93b5a40a5fc0 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java
@@ -20,6 +20,8 @@ import static android.Manifest.permission.CAPTURE_AUDIO_HOTWORD;
import static android.Manifest.permission.LOG_COMPAT_CHANGE;
import static android.Manifest.permission.READ_COMPAT_CHANGE_CONFIG;
import static android.Manifest.permission.RECORD_AUDIO;
+import static android.app.AppOpsManager.MODE_ALLOWED;
+import static android.app.AppOpsManager.MODE_DEFAULT;
import static android.service.attention.AttentionService.PROXIMITY_UNKNOWN;
import static android.service.voice.HotwordDetectionService.AUDIO_SOURCE_EXTERNAL;
import static android.service.voice.HotwordDetectionService.ENABLE_PROXIMITY_RESULT;
@@ -753,11 +755,21 @@ abstract class DetectorSession {
"Failed to obtain permission RECORD_AUDIO for identity "
+ mVoiceInteractorIdentity);
}
- mAppOpsManager.noteOpNoThrow(
- AppOpsPolicy.getVoiceActivationOp(),
- mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
- mVoiceInteractorIdentity.attributionTag,
- HOTWORD_DETECTION_OP_MESSAGE);
+ int opMode = mAppOpsManager.unsafeCheckOpNoThrow(
+ AppOpsManager.opToPublicName(AppOpsPolicy.getVoiceActivationOp()),
+ mVoiceInteractorIdentity.uid,
+ mVoiceInteractorIdentity.packageName);
+ if (opMode == MODE_DEFAULT || opMode == MODE_ALLOWED) {
+ mAppOpsManager.noteOpNoThrow(
+ AppOpsPolicy.getVoiceActivationOp(),
+ mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
+ mVoiceInteractorIdentity.attributionTag,
+ HOTWORD_DETECTION_OP_MESSAGE);
+ } else {
+ throw new SecurityException(
+ "The app op OP_RECEIVE_SANDBOX_TRIGGER_AUDIO is denied for "
+ + "identity" + mVoiceInteractorIdentity);
+ }
} else {
enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
RECORD_AUDIO, HOTWORD_DETECTION_OP_MESSAGE);