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

Commit 855f5bef authored by William Loh's avatar William Loh Committed by Android (Google) Code Review
Browse files

Merge "Introduce maxSdkVersion attribute for the permission tag"

parents e0e55721 a1f01675
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2084,6 +2084,11 @@
        <attr name="protectionLevel" />
        <attr name="permissionFlags" />
        <attr name="knownCerts" />
        <!-- Optional: specify the maximum version of the Android OS for which the
             application wishes to create the permission.  When running on a version
             of Android higher than the number given here, the permission will not
             be created.  -->
        <attr name="maxSdkVersion" />
    </declare-styleable>

    <!-- The <code>permission-group</code> tag declares a logical grouping of
+7 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.parsing.result.ParseResult;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.util.ArrayMap;
import android.util.Slog;

@@ -53,8 +54,7 @@ public class ParsedPermissionUtils {
        String tag = "<" + parser.getName() + ">";
        ParseResult<ParsedPermissionImpl> result;

        TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestPermission);
        try {
        try (TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestPermission)) {
            result = ParsedComponentUtils.parseComponent(
                    permission, tag, pkg, sa, useRoundIcon, input,
                    R.styleable.AndroidManifestPermission_banner,
@@ -68,6 +68,11 @@ public class ParsedPermissionUtils {
                return input.error(result);
            }

            int maxSdkVersion = sa.getInt(R.styleable.AndroidManifestPermission_maxSdkVersion, -1);
            if ((maxSdkVersion != -1) && (maxSdkVersion < Build.VERSION.SDK_INT)) {
                return input.success(null);
            }

            if (sa.hasValue(
                    R.styleable.AndroidManifestPermission_backgroundPermission)) {
                if ("android".equals(packageName)) {
@@ -135,8 +140,6 @@ public class ParsedPermissionUtils {
                            + " restricted: " + permission.getName());
                }
            }
        } finally {
            sa.recycle();
        }

        permission.setProtectionLevel(
+5 −1
Original line number Diff line number Diff line
@@ -1231,7 +1231,11 @@ public class ParsingPackageUtils {
        if (result.isError()) {
            return input.error(result);
        }
        return input.success(pkg.addPermission(result.getResult()));
        ParsedPermission permission = result.getResult();
        if (permission != null) {
            pkg.addPermission(permission);
        }
        return input.success(pkg);
    }

    private static ParseResult<ParsingPackage> parsePermissionTree(ParseInput input,