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

Commit fa2b7ede authored by Kiran Ramachandra's avatar Kiran Ramachandra Committed by Automerger Merge Worker
Browse files

RESTRICT AUTOMERGE Added limitations for attributions to handle invalid cases...

RESTRICT AUTOMERGE Added limitations for attributions to handle invalid cases am: 63d122cf am: d3611d09

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



Change-Id: I5400dfc85c65f391317b42b913985577d2187f95
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a66ffda2 d3611d09
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -3462,6 +3462,10 @@ public class AppOpsService extends IAppOpsService.Stub {
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
                    packageName);
        }
        if (proxyAttributionTag != null
                && !isAttributionTagDefined(packageName, proxyPackageName, proxyAttributionTag)) {
            proxyAttributionTag = null;
        }

        synchronized (this) {
            final Ops ops = getOpsLocked(uid, packageName, attributionTag,
@@ -3976,6 +3980,10 @@ public class AppOpsService extends IAppOpsService.Stub {
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
                    packageName);
        }
        if (proxyAttributionTag != null
                && !isAttributionTagDefined(packageName, proxyPackageName, proxyAttributionTag)) {
            proxyAttributionTag = null;
        }

        boolean isRestricted = false;
        int startType = START_TYPE_FAILED;
@@ -4715,6 +4723,36 @@ public class AppOpsService extends IAppOpsService.Stub {
        return false;
    }

    /**
     * Checks to see if the attribution tag is defined in either package or proxyPackage.
     * This method is intended for ProxyAttributionTag validation and returns false
     * if it does not exist in either one of them.
     *
     * @param packageName Name of the package
     * @param proxyPackageName Name of the proxy package
     * @param attributionTag attribution tag to be checked
     *
     * @return boolean specifying if attribution tag is valid or not
     */
    private boolean isAttributionTagDefined(@Nullable String packageName,
                                            @Nullable String proxyPackageName,
                                            @Nullable String attributionTag) {
        if (packageName == null) {
            return false;
        } else if (attributionTag == null) {
            return true;
        }
        PackageManagerInternal pmInt = LocalServices.getService(PackageManagerInternal.class);
        if (proxyPackageName != null) {
            AndroidPackage proxyPkg = pmInt.getPackage(proxyPackageName);
            if (proxyPkg != null && isAttributionInPackage(proxyPkg, attributionTag)) {
                return true;
            }
        }
        AndroidPackage pkg = pmInt.getPackage(packageName);
        return isAttributionInPackage(pkg, attributionTag);
    }

    /**
     * Get (and potentially create) ops.
     *
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.util.List;
public class ParsedAttributionImpl implements ParsedAttribution, Parcelable {

    /** Maximum amount of attributions per package */
    static final int MAX_NUM_ATTRIBUTIONS = 10000;
    static final int MAX_NUM_ATTRIBUTIONS = 1000;

    /** Tag of the attribution */
    private @NonNull String tag;