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

Commit 27ffeb33 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Better translatable msgs for permission requests

Only for system permissions & groups for now and fall back to old system for
everything else.

Bug: 32070095
Test: Opened camera and saw new string
Change-Id: If25308b6cd7cddccaf63ea5ed6c10c037e3c1778
parent ee9a3655
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -11635,6 +11635,7 @@ package android.content.pm {
    field public int flags;
    field public int flags;
    field public java.lang.CharSequence nonLocalizedDescription;
    field public java.lang.CharSequence nonLocalizedDescription;
    field public int priority;
    field public int priority;
    field public int requestRes;
  }
  }
  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
@@ -11668,6 +11669,7 @@ package android.content.pm {
    field public java.lang.String group;
    field public java.lang.String group;
    field public java.lang.CharSequence nonLocalizedDescription;
    field public java.lang.CharSequence nonLocalizedDescription;
    field public int protectionLevel;
    field public int protectionLevel;
    field public int requestRes;
  }
  }
  public final class ProviderInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
  public final class ProviderInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
+6 −0
Original line number Original line Diff line number Diff line
@@ -3132,6 +3132,8 @@ public class PackageParser {
        perm.info.descriptionRes = sa.getResourceId(
        perm.info.descriptionRes = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_description,
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_description,
                0);
                0);
        perm.info.requestRes = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_request, 0);
        perm.info.flags = sa.getInt(
        perm.info.flags = sa.getInt(
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
                com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
        perm.info.priority = sa.getInt(
        perm.info.priority = sa.getInt(
@@ -3186,6 +3188,9 @@ public class PackageParser {
                com.android.internal.R.styleable.AndroidManifestPermission_description,
                com.android.internal.R.styleable.AndroidManifestPermission_description,
                0);
                0);


        perm.info.requestRes = sa.getResourceId(
                com.android.internal.R.styleable.AndroidManifestPermission_request, 0);

        perm.info.protectionLevel = sa.getInt(
        perm.info.protectionLevel = sa.getInt(
                com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel,
                com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel,
                PermissionInfo.PROTECTION_NORMAL);
                PermissionInfo.PROTECTION_NORMAL);
@@ -3260,6 +3265,7 @@ public class PackageParser {
        }
        }


        perm.info.descriptionRes = 0;
        perm.info.descriptionRes = 0;
        perm.info.requestRes = 0;
        perm.info.protectionLevel = PermissionInfo.PROTECTION_NORMAL;
        perm.info.protectionLevel = PermissionInfo.PROTECTION_NORMAL;
        perm.tree = true;
        perm.tree = true;


+14 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.content.pm;
package android.content.pm;


import android.annotation.StringRes;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.text.TextUtils;
import android.text.TextUtils;
@@ -33,6 +35,15 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
     */
     */
    public int descriptionRes;
    public int descriptionRes;


    /**
     * A string resource identifier (in the package's resources) used to request the permissions.
     * From the "request" attribute or, if not set, 0.
     *
     * @hide
     */
    @SystemApi
    public @StringRes int requestRes;

    /**
    /**
     * The description string provided in the AndroidManifest file, if any.  You
     * 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
     * probably don't want to use this, since it will be null if the description
@@ -64,6 +75,7 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
    public PermissionGroupInfo(PermissionGroupInfo orig) {
    public PermissionGroupInfo(PermissionGroupInfo orig) {
        super(orig);
        super(orig);
        descriptionRes = orig.descriptionRes;
        descriptionRes = orig.descriptionRes;
        requestRes = orig.requestRes;
        nonLocalizedDescription = orig.nonLocalizedDescription;
        nonLocalizedDescription = orig.nonLocalizedDescription;
        flags = orig.flags;
        flags = orig.flags;
        priority = orig.priority;
        priority = orig.priority;
@@ -106,6 +118,7 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
    public void writeToParcel(Parcel dest, int parcelableFlags) {
    public void writeToParcel(Parcel dest, int parcelableFlags) {
        super.writeToParcel(dest, parcelableFlags);
        super.writeToParcel(dest, parcelableFlags);
        dest.writeInt(descriptionRes);
        dest.writeInt(descriptionRes);
        dest.writeInt(requestRes);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
        dest.writeInt(flags);
        dest.writeInt(flags);
        dest.writeInt(priority);
        dest.writeInt(priority);
@@ -124,6 +137,7 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
    private PermissionGroupInfo(Parcel source) {
    private PermissionGroupInfo(Parcel source) {
        super(source);
        super(source);
        descriptionRes = source.readInt();
        descriptionRes = source.readInt();
        requestRes = source.readInt();
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        flags = source.readInt();
        flags = source.readInt();
        priority = source.readInt();
        priority = source.readInt();
+12 −0
Original line number Original line Diff line number Diff line
@@ -197,6 +197,15 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
     */
     */
    public int descriptionRes;
    public int descriptionRes;


    /**
     * A string resource identifier (in the package's resources) used to request the permissions.
     * From the "request" attribute or, if not set, 0.
     *
     * @hide
     */
    @SystemApi
    public int requestRes;

    /**
    /**
     * The description string provided in the AndroidManifest file, if any.  You
     * 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
     * probably don't want to use this, since it will be null if the description
@@ -272,6 +281,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        flags = orig.flags;
        flags = orig.flags;
        group = orig.group;
        group = orig.group;
        descriptionRes = orig.descriptionRes;
        descriptionRes = orig.descriptionRes;
        requestRes = orig.requestRes;
        nonLocalizedDescription = orig.nonLocalizedDescription;
        nonLocalizedDescription = orig.nonLocalizedDescription;
    }
    }


@@ -315,6 +325,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(flags);
        dest.writeInt(flags);
        dest.writeString(group);
        dest.writeString(group);
        dest.writeInt(descriptionRes);
        dest.writeInt(descriptionRes);
        dest.writeInt(requestRes);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
        TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
    }
    }


@@ -334,6 +345,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        flags = source.readInt();
        flags = source.readInt();
        group = source.readString();
        group = source.readString();
        descriptionRes = source.readInt();
        descriptionRes = source.readInt();
        requestRes = source.readInt();
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
    }
    }
}
}
+9 −0
Original line number Original line Diff line number Diff line
@@ -562,6 +562,7 @@
        android:icon="@drawable/perm_group_contacts"
        android:icon="@drawable/perm_group_contacts"
        android:label="@string/permgrouplab_contacts"
        android:label="@string/permgrouplab_contacts"
        android:description="@string/permgroupdesc_contacts"
        android:description="@string/permgroupdesc_contacts"
        android:request="@string/permgrouprequest_contacts"
        android:priority="100" />
        android:priority="100" />


    <!-- Allows an application to read the user's contacts data.
    <!-- Allows an application to read the user's contacts data.
@@ -592,6 +593,7 @@
        android:icon="@drawable/perm_group_calendar"
        android:icon="@drawable/perm_group_calendar"
        android:label="@string/permgrouplab_calendar"
        android:label="@string/permgrouplab_calendar"
        android:description="@string/permgroupdesc_calendar"
        android:description="@string/permgroupdesc_calendar"
        android:request="@string/permgrouprequest_calendar"
        android:priority="200" />
        android:priority="200" />


    <!-- Allows an application to read the user's calendar data.
    <!-- Allows an application to read the user's calendar data.
@@ -622,6 +624,7 @@
        android:icon="@drawable/perm_group_sms"
        android:icon="@drawable/perm_group_sms"
        android:label="@string/permgrouplab_sms"
        android:label="@string/permgrouplab_sms"
        android:description="@string/permgroupdesc_sms"
        android:description="@string/permgroupdesc_sms"
        android:request="@string/permgrouprequest_sms"
        android:priority="300" />
        android:priority="300" />


    <!-- Allows an application to send SMS messages.
    <!-- Allows an application to send SMS messages.
@@ -698,6 +701,7 @@
        android:icon="@drawable/perm_group_storage"
        android:icon="@drawable/perm_group_storage"
        android:label="@string/permgrouplab_storage"
        android:label="@string/permgrouplab_storage"
        android:description="@string/permgroupdesc_storage"
        android:description="@string/permgroupdesc_storage"
        android:request="@string/permgrouprequest_storage"
        android:priority="900" />
        android:priority="900" />


    <!-- Allows an application to read from external storage.
    <!-- Allows an application to read from external storage.
@@ -759,6 +763,7 @@
        android:icon="@drawable/perm_group_location"
        android:icon="@drawable/perm_group_location"
        android:label="@string/permgrouplab_location"
        android:label="@string/permgrouplab_location"
        android:description="@string/permgroupdesc_location"
        android:description="@string/permgroupdesc_location"
        android:request="@string/permgrouprequest_location"
        android:priority="400" />
        android:priority="400" />


    <!-- Allows an app to access precise location.
    <!-- Allows an app to access precise location.
@@ -791,6 +796,7 @@
        android:icon="@drawable/perm_group_phone_calls"
        android:icon="@drawable/perm_group_phone_calls"
        android:label="@string/permgrouplab_phone"
        android:label="@string/permgrouplab_phone"
        android:description="@string/permgroupdesc_phone"
        android:description="@string/permgroupdesc_phone"
        android:request="@string/permgrouprequest_phone"
        android:priority="500" />
        android:priority="500" />


    <!-- Allows read only access to phone state, including the phone number of the device,
    <!-- Allows read only access to phone state, including the phone number of the device,
@@ -942,6 +948,7 @@
        android:icon="@drawable/perm_group_microphone"
        android:icon="@drawable/perm_group_microphone"
        android:label="@string/permgrouplab_microphone"
        android:label="@string/permgrouplab_microphone"
        android:description="@string/permgroupdesc_microphone"
        android:description="@string/permgroupdesc_microphone"
        android:request="@string/permgrouprequest_microphone"
        android:priority="600" />
        android:priority="600" />


    <!-- Allows an application to record audio.
    <!-- Allows an application to record audio.
@@ -984,6 +991,7 @@
        android:icon="@drawable/perm_group_camera"
        android:icon="@drawable/perm_group_camera"
        android:label="@string/permgrouplab_camera"
        android:label="@string/permgrouplab_camera"
        android:description="@string/permgroupdesc_camera"
        android:description="@string/permgroupdesc_camera"
        android:request="@string/permgrouprequest_camera"
        android:priority="700" />
        android:priority="700" />


    <!-- Required to be able to access the camera device.
    <!-- Required to be able to access the camera device.
@@ -1013,6 +1021,7 @@
        android:icon="@drawable/perm_group_sensors"
        android:icon="@drawable/perm_group_sensors"
        android:label="@string/permgrouplab_sensors"
        android:label="@string/permgrouplab_sensors"
        android:description="@string/permgroupdesc_sensors"
        android:description="@string/permgroupdesc_sensors"
        android:request="@string/permgrouprequest_sensors"
        android:priority="800" />
        android:priority="800" />


    <!-- Allows an application to access data from sensors that the user uses to
    <!-- Allows an application to access data from sensors that the user uses to
Loading