diff options
| author | 2020-08-28 13:25:31 +0100 | |
|---|---|---|
| committer | 2020-08-28 14:36:25 +0100 | |
| commit | afe2823fd23bb1143473258239f61a7c2a0771df (patch) | |
| tree | c26403d0515e58a811e4d07f90b6ae592e57628f | |
| parent | 987c297857e77a2ee7381b20f4ef6e2e55daa471 (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/appop/AppOpsService.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index c5bdb9edd069..1d23e72b299a 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -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_PLAY_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.RestrictionBypass; import static android.app.AppOpsManager.SAMPLING_STRATEGY_BOOT_TIME_SAMPLING; @@ -3400,7 +3401,19 @@ public class AppOpsService extends IAppOpsService.Stub { verifyIncomingOp(code); String resolvedPackageName = resolvePackageName(uid, packageName); if (resolvedPackageName == null) { - 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; |