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

Commit aa7d64b8 authored by Hai Zhang's avatar Hai Zhang Committed by Android (Google) Code Review
Browse files

Merge changes from topics "role-permission", "role-permission-internal"

* changes:
  Add internal as a new permission protection level.
  Add role as a new permission protection flag.
parents 82f20411 b9893a60
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12456,6 +12456,7 @@ package android.content.pm {
    field public static final int PROTECTION_FLAG_SETUP = 2048; // 0x800
    field @Deprecated public static final int PROTECTION_FLAG_SYSTEM = 16; // 0x10
    field public static final int PROTECTION_FLAG_VERIFIER = 512; // 0x200
    field public static final int PROTECTION_INTERNAL = 4; // 0x4
    field @Deprecated public static final int PROTECTION_MASK_BASE = 15; // 0xf
    field @Deprecated public static final int PROTECTION_MASK_FLAGS = 65520; // 0xfff0
    field public static final int PROTECTION_NORMAL = 0; // 0x0
+1 −0
Original line number Diff line number Diff line
@@ -2296,6 +2296,7 @@ package android.content.pm {
    field public static final int PROTECTION_FLAG_OEM = 16384; // 0x4000
    field public static final int PROTECTION_FLAG_RECENTS = 33554432; // 0x2000000
    field public static final int PROTECTION_FLAG_RETAIL_DEMO = 16777216; // 0x1000000
    field public static final int PROTECTION_FLAG_ROLE = 67108864; // 0x4000000
    field public static final int PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER = 65536; // 0x10000
    field public static final int PROTECTION_FLAG_WELLBEING = 131072; // 0x20000
    field @Nullable public final String backgroundPermission;
+25 −1
Original line number Diff line number Diff line
@@ -65,12 +65,20 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
    @Deprecated
    public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3;

    /**
     * System-level value for {@link #protectionLevel}, corresponding
     * to the <code>internal</code> value of
     * {@link android.R.attr#protectionLevel}.
     */
    public static final int PROTECTION_INTERNAL = 4;

    /** @hide */
    @IntDef(flag = false, prefix = { "PROTECTION_" }, value = {
            PROTECTION_NORMAL,
            PROTECTION_DANGEROUS,
            PROTECTION_SIGNATURE,
            PROTECTION_SIGNATURE_OR_SYSTEM,
            PROTECTION_INTERNAL,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Protection {}
@@ -261,6 +269,15 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
    @SystemApi
    public static final int PROTECTION_FLAG_RECENTS = 0x2000000;

    /**
     * Additional flag for {@link #protectionLevel}, corresponding to the <code>role</code> value of
     * {@link android.R.attr#protectionLevel}.
     *
     * @hide
     */
    @SystemApi
    public static final int PROTECTION_FLAG_ROLE = 0x4000000;

    /** @hide */
    @IntDef(flag = true, prefix = { "PROTECTION_FLAG_" }, value = {
            PROTECTION_FLAG_PRIVILEGED,
@@ -285,6 +302,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
            PROTECTION_FLAG_COMPANION,
            PROTECTION_FLAG_RETAIL_DEMO,
            PROTECTION_FLAG_RECENTS,
            PROTECTION_FLAG_ROLE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ProtectionFlags {}
@@ -317,7 +335,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
     * </pre>
     *
     * <p></p>Base permission types are {@link #PROTECTION_NORMAL},
     * {@link #PROTECTION_DANGEROUS}, {@link #PROTECTION_SIGNATURE}
     * {@link #PROTECTION_DANGEROUS}, {@link #PROTECTION_SIGNATURE}, {@link #PROTECTION_INTERNAL}
     * and the deprecated {@link #PROTECTION_SIGNATURE_OR_SYSTEM}.
     * Flags are listed under {@link android.R.attr#protectionLevel}.
     *
@@ -479,6 +497,9 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
            case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
                protLevel.append("signatureOrSystem");
                break;
            case PermissionInfo.PROTECTION_INTERNAL:
                protLevel.append("internal");
                break;
            default:
                protLevel.append("????");
                break;
@@ -546,6 +567,9 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        if ((level & PermissionInfo.PROTECTION_FLAG_RECENTS) != 0) {
            protLevel.append("|recents");
        }
        if ((level & PermissionInfo.PROTECTION_FLAG_ROLE) != 0) {
            protLevel.append("|role");
        }
        return protLevel.toString();
    }

+5 −3
Original line number Diff line number Diff line
@@ -112,10 +112,12 @@ public class ParsedPermissionUtils {
            if ((permission.protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTANT) == 0
                    && (permission.protectionLevel & PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY)
                    == 0
                    && (permission.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE) !=
                    PermissionInfo.PROTECTION_SIGNATURE) {
                    && (permission.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
                    != PermissionInfo.PROTECTION_SIGNATURE
                    && (permission.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
                    != PermissionInfo.PROTECTION_INTERNAL) {
                return input.error("<permission>  protectionLevel specifies a non-instant flag "
                        + "but is not based on signature type");
                        + "but is not based on signature or internal type");
            }
        }

+5 −0
Original line number Diff line number Diff line
@@ -226,6 +226,9 @@
             to share specific features explicitly because they are being built
             together. -->
        <flag name="signatureOrSystem" value="3" />
        <!-- <strong>Base permission type</strong>: a permission that is managed internally by the
             system and only granted according to the protection flags. -->
        <flag name="internal" value="4" />
        <!-- Additional flag from base permission type: this permission can also
             be granted to any applications installed as privileged apps on the system image.
             Please avoid using this option, as the
@@ -306,6 +309,8 @@
        <!-- Additional flag from base permission type: this permission will be granted to the
             recents app. -->
        <flag name="recents" value="0x2000000" />
        <!-- Additional flag from base permission type: this permission is managed by role. -->
        <flag name="role" value="0x4000000" />
    </attr>

    <!-- Flags indicating more context for a permission group. -->
Loading