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

Commit afe2823f authored by Narayan Kamath's avatar Narayan Kamath
Browse files

AppOpsService: Add a special case for OP_RECORD_AUDIO_HOTWORD.

When OP_RECORD_AUDIO_HOTWORD is used with startOp, we make sure
we also check the state of OP_RECORD_AUDIO. The former is used
for attribution purposes only.

Test: manual.
Bug: 162547999

Change-Id: I72478c82233fe796738d360ed9b7f7bb9cafb7b0
parent 987c2978
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import static android.app.AppOpsManager.OP_FLAG_TRUSTED_PROXIED;
import static android.app.AppOpsManager.OP_NONE;
import static android.app.AppOpsManager.OP_NONE;
import static android.app.AppOpsManager.OP_PLAY_AUDIO;
import static android.app.AppOpsManager.OP_PLAY_AUDIO;
import static android.app.AppOpsManager.OP_RECORD_AUDIO;
import static android.app.AppOpsManager.OP_RECORD_AUDIO;
import static android.app.AppOpsManager.OP_RECORD_AUDIO_HOTWORD;
import static android.app.AppOpsManager.OpEventProxyInfo;
import static android.app.AppOpsManager.OpEventProxyInfo;
import static android.app.AppOpsManager.RestrictionBypass;
import static android.app.AppOpsManager.RestrictionBypass;
import static android.app.AppOpsManager.SAMPLING_STRATEGY_BOOT_TIME_SAMPLING;
import static android.app.AppOpsManager.SAMPLING_STRATEGY_BOOT_TIME_SAMPLING;
@@ -3403,6 +3404,18 @@ public class AppOpsService extends IAppOpsService.Stub {
            return AppOpsManager.MODE_IGNORED;
            return AppOpsManager.MODE_IGNORED;
        }
        }


        // As a special case for OP_RECORD_AUDIO_HOTWORD, which we use only for attribution
        // purposes and not as a check, also make sure that the caller is allowed to access
        // the data gated by OP_RECORD_AUDIO.
        //
        // TODO: Revert this change before Android 12.
        if (code == OP_RECORD_AUDIO_HOTWORD) {
            int result = checkOperation(OP_RECORD_AUDIO, uid, packageName);
            if (result != AppOpsManager.MODE_ALLOWED) {
                return result;
            }
        }

        RestrictionBypass bypass;
        RestrictionBypass bypass;
        try {
        try {
            bypass = verifyAndGetBypass(uid, packageName, attributionTag);
            bypass = verifyAndGetBypass(uid, packageName, attributionTag);