diff options
| author | 2021-06-03 15:36:13 -0700 | |
|---|---|---|
| committer | 2021-06-03 17:01:26 -0700 | |
| commit | 39c56f4be24cb60b13e2c8fd05c9298c292d2c75 (patch) | |
| tree | 5a30aa85f2d1cee4e559f2bb64a1828b5d952802 | |
| parent | 1de80b1d70535e5e0f8861c7f054414d1704ca4e (diff) | |
TEMP add app ops debug logs
Bug: 190073375
Bug: 189484870
Test: build
Change-Id: Id9133066fa58b158e2a3e00d12af9e92407caccb
| -rw-r--r-- | services/core/java/com/android/server/appop/AppOpsService.java | 38 | ||||
| -rw-r--r-- | services/core/java/com/android/server/policy/AppOpsPolicy.java | 22 |
2 files changed, 56 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index fdb3d8ca371c..a68364e943cf 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -3351,10 +3351,21 @@ public class AppOpsService extends IAppOpsService.Stub { boolean shouldCollectMessage) { RestrictionBypass bypass; try { - bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName); + boolean isLocOrActivity = code == AppOpsManager.OP_FINE_LOCATION + || code == AppOpsManager.OP_FINE_LOCATION_SOURCE + || code == AppOpsManager.OP_ACTIVITY_RECOGNITION + || code == AppOpsManager.OP_ACTIVITY_RECOGNITION_SOURCE; + bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName, + isLocOrActivity); + boolean wasNull = attributionTag == null; if (bypass != null && bypass.getIsAttributionTagNotFound()) { attributionTag = null; } + if (attributionTag == null && isLocOrActivity + && packageName.equals("com.google.android.gms")) { + Slog.i("AppOpsDebug", "null tag on location or activity op " + code + + " for " + packageName + ", was overridden: " + !wasNull, new Exception()); + } } catch (SecurityException e) { Slog.e(TAG, "noteOperation", e); return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag, @@ -3861,10 +3872,20 @@ public class AppOpsService extends IAppOpsService.Stub { int attributionChainId, boolean dryRun) { RestrictionBypass bypass; try { - bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName); + boolean isLocOrActivity = code == AppOpsManager.OP_FINE_LOCATION + || code == AppOpsManager.OP_FINE_LOCATION_SOURCE + || code == AppOpsManager.OP_ACTIVITY_RECOGNITION + || code == AppOpsManager.OP_ACTIVITY_RECOGNITION_SOURCE; + bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName, + isLocOrActivity); if (bypass != null && bypass.getIsAttributionTagNotFound()) { attributionTag = null; } + if (attributionTag == null && isLocOrActivity + && packageName.equals("com.google.android.gms")) { + Slog.i("AppOpsDebug", "null tag on location or activity op " + + code + " for " + packageName, new Exception()); + } } catch (SecurityException e) { Slog.e(TAG, "startOperation", e); return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag, @@ -4418,7 +4439,7 @@ public class AppOpsService extends IAppOpsService.Stub { */ private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName, @Nullable String attributionTag) { - return verifyAndGetBypass(uid, packageName, attributionTag, null); + return verifyAndGetBypass(uid, packageName, attributionTag, null, false); } /** @@ -4433,7 +4454,7 @@ public class AppOpsService extends IAppOpsService.Stub { * @return {@code true} iff the package is privileged */ private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName, - @Nullable String attributionTag, @Nullable String proxyPackageName) { + @Nullable String attributionTag, @Nullable String proxyPackageName, boolean extraLog) { if (uid == Process.ROOT_UID) { // For backwards compatibility, don't check package name for root UID. return null; @@ -4475,6 +4496,15 @@ public class AppOpsService extends IAppOpsService.Stub { AndroidPackage pkg = pmInt.getPackage(packageName); if (pkg != null) { isAttributionTagValid = isAttributionInPackage(pkg, attributionTag); + if (packageName.equals("com.google.android.gms") && extraLog) { + if (isAttributionTagValid && attributionTag != null) { + Slog.i("AppOpsDebug", "tag " + attributionTag + " found in " + + packageName); + } else { + Slog.i("AppOpsDebug", "tag " + attributionTag + " missing from " + + packageName); + } + } pkgUid = UserHandle.getUid(userId, UserHandle.getAppId(pkg.getUid())); bypass = getBypassforPackage(pkg); diff --git a/services/core/java/com/android/server/policy/AppOpsPolicy.java b/services/core/java/com/android/server/policy/AppOpsPolicy.java index 607bc569ad64..f39d618f9377 100644 --- a/services/core/java/com/android/server/policy/AppOpsPolicy.java +++ b/services/core/java/com/android/server/policy/AppOpsPolicy.java @@ -225,13 +225,21 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat if (isDatasourceAttributionTag(uid, packageName, attributionTag, mLocationTags)) { return resolvedCode; + } else if (packageName.equals("com.google.android.gms")) { + Log.i("AppOpsDebugRemapping", "NOT remapping " + packageName + " code " + + code + " for tag " + attributionTag); } } else { resolvedCode = resolveArOp(code); if (resolvedCode != code) { if (isDatasourceAttributionTag(uid, packageName, attributionTag, mActivityRecognitionTags)) { + Log.i("AppOpsDebugRemapping", "remapping " + packageName + " code " + + code + " to " + resolvedCode + " for tag " + attributionTag); return resolvedCode; + } else if (packageName.equals("com.google.android.gms")) { + Log.i("AppOpsDebugRemapping", "NOT remapping " + packageName + + " code " + code + " for tag " + attributionTag); } } } @@ -334,8 +342,22 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat if (appIdTags != null) { final ArraySet<String> packageTags = appIdTags.get(packageName); if (packageTags != null && packageTags.contains(attributionTag)) { + if (packageName.equals("com.google.android.gms")) { + Log.i("AppOpsDebugRemapping", packageName + " tag " + + attributionTag + " in " + packageTags); + } return true; } + if (packageName.equals("com.google.android.gms")) { + Log.i("AppOpsDebugRemapping", packageName + " tag " + attributionTag + + " NOT in " + packageTags); + } + } else { + if (packageName.equals("com.google.android.gms")) { + Log.i("AppOpsDebugRemapping", "no package tags for uid " + uid + + " package " + packageName); + } + } return false; } |