From 4d4d8e2f9fb7376cef7c41cd64a971f5e78879b9 Mon Sep 17 00:00:00 2001 From: Nate Myren Date: Thu, 19 Nov 2020 18:49:02 +0000 Subject: [PATCH] Allow self blames to be trusted Test: manual Fixes: 173659119 Change-Id: I6f413dd6430f096590dadf87dad32264523b13c3 --- .../core/java/com/android/server/appop/AppOpsService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 09937e3a74c14..9113d5cdd978f 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -3058,9 +3058,10 @@ public class AppOpsService extends IAppOpsService.Stub { // This is a workaround for R QPR, new API change is not allowed. We only allow the current // voice recognizer is also the voice interactor to noteproxy op. final boolean isTrustVoiceServiceProxy = isTrustedVoiceServiceProxy(proxyPackageName, code); + final boolean isSelfBlame = Binder.getCallingUid() == proxiedUid; final boolean isProxyTrusted = mContext.checkPermission( Manifest.permission.UPDATE_APP_OPS_STATS, -1, proxyUid) - == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy; + == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy || isSelfBlame; final int proxyFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXY : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY; @@ -3525,9 +3526,10 @@ public class AppOpsService extends IAppOpsService.Stub { // This is a workaround for R QPR, new API change is not allowed. We only allow the current // voice recognizer is also the voice interactor to noteproxy op. final boolean isTrustVoiceServiceProxy = isTrustedVoiceServiceProxy(proxyPackageName, code); + final boolean isSelfBlame = Binder.getCallingUid() == proxiedUid; final boolean isProxyTrusted = mContext.checkPermission( Manifest.permission.UPDATE_APP_OPS_STATS, -1, proxyUid) - == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy; + == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy || isSelfBlame; final int proxyFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXY : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY;