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

Commit 60269402 authored by Nate Myren's avatar Nate Myren Committed by android-build-team Robot
Browse files

TEMP: note "RECORD_AUDIO_HOTWORD" in SoundTriggerMiddleware

note the RECORD_AUDIO_HOTWORD op, rather than the RECORD_AUDIO. In
addition, check the RECORD_AUDIO permission for preflight, not data
delivery

Bug: 186164881
Test: Manual
Change-Id: I3275647d0f9a6e3ce8b97a556f56723b49170c8e
(cherry picked from commit c6c38cd6)
parent 38c004eb
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.Manifest.permission.RECORD_AUDIO;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.PermissionChecker;
import android.media.permission.Identity;
@@ -132,7 +133,12 @@ public class SoundTriggerMiddlewarePermission implements ISoundTriggerMiddleware
     * Throws a {@link SecurityException} iff the originator has permission to receive data.
     */
    void enforcePermissionsForDataDelivery(@NonNull Identity identity, @NonNull String reason) {
        enforcePermissionForDataDelivery(mContext, identity, RECORD_AUDIO, reason);
        // START TEMP HACK
        enforcePermissionForPreflight(mContext, identity, RECORD_AUDIO);
        int hotwordOp = AppOpsManager.strOpToOp(AppOpsManager.OPSTR_RECORD_AUDIO_HOTWORD);
        mContext.getSystemService(AppOpsManager.class).noteOpNoThrow(hotwordOp, identity.uid,
                identity.packageName, identity.attributionTag, reason);
        // END TEMP HACK
        enforcePermissionForDataDelivery(mContext, identity, CAPTURE_AUDIO_HOTWORD,
                reason);
    }