From 727e0e78bc9fbe6831daebc15eeceb70b0132504 Mon Sep 17 00:00:00 2001 From: Stanislav Zholnin Date: Tue, 11 Feb 2020 17:45:22 +0000 Subject: [PATCH] Fix HistoricalAppOps collection. Pullers were moved to frameworks/base because of migration, thus they call AppOpsService.getHistoricalOps() with SYSTEM_UID and PID. In addition, for stack trace reporting we need to call getHistoricalOps() from system process. Test: atest UidAtomTests#testAppOps Change-Id: I8ed66c0eb912f6af108e53287f030c871423948d --- .../core/java/com/android/server/appop/AppOpsService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 06561f57f4956..6911e640a0c73 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -56,7 +56,6 @@ import static android.app.AppOpsManager.resolveFirstUnrestrictedUidState; import static android.content.Intent.ACTION_PACKAGE_REMOVED; import static android.content.Intent.EXTRA_REPLACING; import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS; -import static android.os.Process.STATSD_UID; import static com.android.server.appop.AppOpsService.ModeCallback.ALL_OPS; @@ -1890,9 +1889,9 @@ public class AppOpsService extends IAppOpsService.Stub { ActivityManagerInternal ami = LocalServices.getService(ActivityManagerInternal.class); boolean isCallerInstrumented = ami.isUidCurrentlyInstrumented(Binder.getCallingUid()); - boolean isCallerStatsCollector = Binder.getCallingUid() == STATSD_UID; + boolean isCallerSystem = Binder.getCallingPid() == Process.myPid(); - if (!isCallerStatsCollector && !isCallerInstrumented) { + if (!isCallerSystem && !isCallerInstrumented) { mHandler.post(() -> callback.sendResult(new Bundle())); return; }