Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 487bd3e5 authored by lpeter's avatar lpeter
Browse files

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
parent c7c60d5e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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();