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

Commit 6531d27c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow permissions to have background permissions"

parents 9ea3a32e 4a6dff09
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1202,6 +1202,9 @@ package android.content.pm {
  }

  public class PermissionGroupInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    field public int backgroundRequestDetailResourceId;
    field public int backgroundRequestResourceId;
    field public int requestDetailResourceId;
    field public int requestRes;
  }

@@ -1209,6 +1212,7 @@ package android.content.pm {
    field public static final int FLAG_REMOVED = 2; // 0x2
    field public static final int PROTECTION_FLAG_OEM = 16384; // 0x4000
    field public static final int PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER = 65536; // 0x10000
    field public java.lang.String backgroundPermission;
    field public int requestRes;
  }

+1 −0
Original line number Diff line number Diff line
@@ -276,6 +276,7 @@ package android.content.pm {
  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    field public static final int PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER = 65536; // 0x10000
    field public static final int PROTECTION_FLAG_VENDOR_PRIVILEGED = 32768; // 0x8000
    field public java.lang.String backgroundPermission;
  }

  public final class ShortcutInfo implements android.os.Parcelable {
+21 −0
Original line number Diff line number Diff line
@@ -3100,6 +3100,14 @@ public class PackageParser {
                0);
        perm.info.requestRes = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_request, 0);
        perm.info.requestDetailResourceId = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_requestDetail, 0);
        perm.info.backgroundRequestResourceId = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_backgroundRequest,
                0);
        perm.info.backgroundRequestDetailResourceId = sa.getResourceId(
                com.android.internal.R.styleable
                        .AndroidManifestPermissionGroup_backgroundRequestDetail, 0);
        perm.info.flags = sa.getInt(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
        perm.info.priority = sa.getInt(
@@ -3154,6 +3162,19 @@ public class PackageParser {
        perm.info.requestRes = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermission_request, 0);

        if (sa.hasValue(
                com.android.internal.R.styleable.AndroidManifestPermission_backgroundPermission)) {
            if ("android".equals(owner.packageName)) {
                perm.info.backgroundPermission = sa.getNonResourceString(
                        com.android.internal.R.styleable
                                .AndroidManifestPermission_backgroundPermission);
            } else {
                Slog.w(TAG, owner.packageName + " defines permission '" + perm.info.name
                        + "' with a background permission. Only the 'android' package can do "
                        + "that.");
            }
        }

        perm.info.protectionLevel = sa.getInt(
                com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel,
                PermissionInfo.PROTECTION_NORMAL);
+45 −0
Original line number Diff line number Diff line
@@ -44,6 +44,42 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
    @SystemApi
    public @StringRes int requestRes;

    /**
     * A string resource identifier (in the package's resources) used as subtitle when requesting
     * only access while in the foreground.
     *
     * From the "requestDetail" attribute or, if not set, {@link
     * android.content.res.ResourceId#ID_NULL}.
     *
     * @hide
     */
    @SystemApi
    public @StringRes int requestDetailResourceId;

    /**
     * A string resource identifier (in the package's resources) used when requesting background
     * access. Also used when requesting both foreground and background access.
     *
     * From the "backgroundRequest" attribute or, if not set, {@link
     * android.content.res.ResourceId#ID_NULL}.
     *
     * @hide
     */
    @SystemApi
    public @StringRes int backgroundRequestResourceId;

    /**
     * A string resource identifier (in the package's resources) used as subtitle when requesting
     * background access.
     *
     * From the "backgroundRequestDetail" attribute or, if not set, {@link
     * android.content.res.ResourceId#ID_NULL}.
     *
     * @hide
     */
    @SystemApi
    public @StringRes int backgroundRequestDetailResourceId;

    /**
     * The description string provided in the AndroidManifest file, if any.  You
     * probably don't want to use this, since it will be null if the description
@@ -76,6 +112,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
        super(orig);
        descriptionRes = orig.descriptionRes;
        requestRes = orig.requestRes;
        requestDetailResourceId = orig.requestDetailResourceId;
        backgroundRequestResourceId = orig.backgroundRequestResourceId;
        backgroundRequestDetailResourceId = orig.backgroundRequestDetailResourceId;
        nonLocalizedDescription = orig.nonLocalizedDescription;
        flags = orig.flags;
        priority = orig.priority;
@@ -119,6 +158,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
        super.writeToParcel(dest, parcelableFlags);
        dest.writeInt(descriptionRes);
        dest.writeInt(requestRes);
        dest.writeInt(requestDetailResourceId);
        dest.writeInt(backgroundRequestResourceId);
        dest.writeInt(backgroundRequestDetailResourceId);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
        dest.writeInt(flags);
        dest.writeInt(priority);
@@ -138,6 +180,9 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
        super(source);
        descriptionRes = source.readInt();
        requestRes = source.readInt();
        requestDetailResourceId = source.readInt();
        backgroundRequestResourceId = source.readInt();
        backgroundRequestDetailResourceId = source.readInt();
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        flags = source.readInt();
        priority = source.readInt();
+18 −0
Original line number Diff line number Diff line
@@ -284,6 +284,21 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
    @SystemApi
    public int requestRes;

    /**
     * Some permissions only grant access while the app is in foreground. Some of these permissions
     * allow to add background capabilities by adding another permission.
     *
     * If this is such a permission, this is the name of the permission adding the background
     * access.
     *
     * From the "backgroundPermission" attribute or, if not set null
     *
     * @hide
     */
    @SystemApi
    @TestApi
    public String backgroundPermission;

    /**
     * The description string provided in the AndroidManifest file, if any.  You
     * probably don't want to use this, since it will be null if the description
@@ -373,6 +388,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        protectionLevel = orig.protectionLevel;
        flags = orig.flags;
        group = orig.group;
        backgroundPermission = orig.backgroundPermission;
        descriptionRes = orig.descriptionRes;
        requestRes = orig.requestRes;
        nonLocalizedDescription = orig.nonLocalizedDescription;
@@ -436,6 +452,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(protectionLevel);
        dest.writeInt(flags);
        dest.writeString(group);
        dest.writeString(backgroundPermission);
        dest.writeInt(descriptionRes);
        dest.writeInt(requestRes);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
@@ -475,6 +492,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        protectionLevel = source.readInt();
        flags = source.readInt();
        group = source.readString();
        backgroundPermission = source.readString();
        descriptionRes = source.readInt();
        requestRes = source.readInt();
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
Loading