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

Commit 6ee7c7d9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Avoid a SecurityExcetion crash" into sc-dev am: d0bcac4e

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

Change-Id: I5eedda1add8bc287e5a1f3372f4deb8dc86f6903
parents cbcb4a66 d0bcac4e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3058,11 +3058,24 @@ public class AppOpsManager {
         */
        public boolean isRecordAudioRestrictionExcept;

        /**
         * Is attribution tag not null and not contained in the package attributions
         */
        public boolean isAttributionTagNotFound = false;

        public RestrictionBypass(boolean isPrivileged, boolean isRecordAudioRestrictionExcept) {
            this.isPrivileged = isPrivileged;
            this.isRecordAudioRestrictionExcept = isRecordAudioRestrictionExcept;
        }

        public void setIsAttributionTagNotFound(boolean isAttributionTagNotFound) {
            this.isAttributionTagNotFound = isAttributionTagNotFound;
        }

        public boolean getIsAttributionTagNotFound() {
            return this.isAttributionTagNotFound;
        }

        public static RestrictionBypass UNRESTRICTED = new RestrictionBypass(true, true);
    }

+11 −1
Original line number Diff line number Diff line
@@ -3303,6 +3303,9 @@ public class AppOpsService extends IAppOpsService.Stub {
        RestrictionBypass bypass;
        try {
            bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
            if (bypass != null && bypass.getIsAttributionTagNotFound()) {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            Slog.e(TAG, "noteOperation", e);
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
@@ -3795,6 +3798,9 @@ public class AppOpsService extends IAppOpsService.Stub {
        RestrictionBypass bypass;
        try {
            bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
            if (bypass != null && bypass.getIsAttributionTagNotFound()) {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            Slog.e(TAG, "startOperation", e);
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
@@ -3942,6 +3948,9 @@ public class AppOpsService extends IAppOpsService.Stub {
        RestrictionBypass bypass;
        try {
            bypass = verifyAndGetBypass(uid, packageName, attributionTag);
            if (bypass != null && bypass.getIsAttributionTagNotFound()) {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            Slog.e(TAG, "Cannot finishOperation", e);
            return;
@@ -4402,6 +4411,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                } else if (pkg != null) {
                    msg = "attributionTag " + attributionTag + " not declared in manifest of "
                            + packageName;
                    bypass.setIsAttributionTagNotFound(true);
                } else {
                    msg = "package " + packageName + " not found, can't check for "
                            + "attributionTag " + attributionTag;
@@ -4413,7 +4423,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                            userId) && mPlatformCompat.isChangeEnabledByUid(
                                    SECURITY_EXCEPTION_ON_INVALID_ATTRIBUTION_TAG_CHANGE,
                            callingUid) && !foundInProxy) {
                        throw new SecurityException(msg);
                        Slog.e(TAG, msg);
                    } else {
                        Slog.e(TAG, msg);
                    }