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

Commit 519167ea authored by Nate Myren's avatar Nate Myren Committed by Automerger Merge Worker
Browse files

Merge "TEMP add app ops debug logs" into sc-dev am: 1428a68f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14829490

Change-Id: I1a8cca2fac2f75ddd96c3046d53a33c43c433202
parents bbf6c49f 1428a68f
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -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);
+22 −0
Original line number Diff line number Diff line
@@ -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;
    }