Grant CAPTURE_AUDIO_OUTPUT permission for trusted process

HotwordDetectionService is an isolated service which ordinarily
cannot hold permissions, so we dynamically override the permissions
check based on the currently bound HotwordDetectionService.

We have a similar change to grant RECORD_AUDIO and CAPTURE_AUDIO_HOTWORD
permissions to HotwordDetectionService before.
(ag/14427323 and ag/14883678)

Bug: 228328385
Test: atest CtsVoiceInteractionTestCases
Change-Id: I9156be8ff7812774145ab4806523fb503fc9491f
This commit is contained in:
lpeter
2022-05-27 17:42:18 +08:00
parent c7c60d5ec1
commit 487bd3e54b
2 changed files with 5 additions and 4 deletions

View File

@@ -17,6 +17,7 @@
package com.android.server.pm.permission;
import static android.Manifest.permission.CAPTURE_AUDIO_HOTWORD;
import static android.Manifest.permission.CAPTURE_AUDIO_OUTPUT;
import static android.Manifest.permission.RECORD_AUDIO;
import static android.Manifest.permission.UPDATE_APP_OPS_STATS;
import static android.app.AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE;
@@ -1358,8 +1359,8 @@ public class PermissionManagerService extends IPermissionManager.Stub {
// the only use case for this, so simply override here.
if (!permissionGranted
&& Process.isIsolated(uid) // simple check which fails-fast for the common case
&& (permission.equals(RECORD_AUDIO)
|| permission.equals(CAPTURE_AUDIO_HOTWORD))) {
&& (permission.equals(RECORD_AUDIO) || permission.equals(CAPTURE_AUDIO_HOTWORD)
|| permission.equals(CAPTURE_AUDIO_OUTPUT))) {
HotwordDetectionServiceProvider hotwordServiceProvider =
permissionManagerServiceInt.getHotwordDetectionServiceProvider();
permissionGranted = hotwordServiceProvider != null

View File

@@ -449,8 +449,8 @@ public interface PermissionManagerServiceInternal extends PermissionManagerInter
/**
* Provides the uid of the currently active
* {@link android.service.voice.HotwordDetectionService}, which should be granted RECORD_AUDIO
* and CAPTURE_AUDIO_HOTWORD permissions.
* {@link android.service.voice.HotwordDetectionService}, which should be granted RECORD_AUDIO,
* CAPTURE_AUDIO_HOTWORD and CAPTURE_AUDIO_OUTPUT permissions.
*/
interface HotwordDetectionServiceProvider {
int getUid();