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
This commit is contained in:
Philip P. Moltmann
2017-07-06 13:54:46 -07:00
parent ee9a365514
commit 27ffeb33fb
7 changed files with 72 additions and 0 deletions

View File

@@ -11635,6 +11635,7 @@ package android.content.pm {
field public int flags;
field public java.lang.CharSequence nonLocalizedDescription;
field public int priority;
field public int requestRes;
}
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.CharSequence nonLocalizedDescription;
field public int protectionLevel;
field public int requestRes;
}
public final class ProviderInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {

View File

@@ -3132,6 +3132,8 @@ public class PackageParser {
perm.info.descriptionRes = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestPermissionGroup_description,
0);
perm.info.requestRes = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestPermissionGroup_request, 0);
perm.info.flags = sa.getInt(
com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
perm.info.priority = sa.getInt(
@@ -3186,6 +3188,9 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestPermission_description,
0);
perm.info.requestRes = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestPermission_request, 0);
perm.info.protectionLevel = sa.getInt(
com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel,
PermissionInfo.PROTECTION_NORMAL);
@@ -3260,6 +3265,7 @@ public class PackageParser {
}
perm.info.descriptionRes = 0;
perm.info.requestRes = 0;
perm.info.protectionLevel = PermissionInfo.PROTECTION_NORMAL;
perm.tree = true;

View File

@@ -16,6 +16,8 @@
package android.content.pm;
import android.annotation.StringRes;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -33,6 +35,15 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
*/
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
* 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) {
super(orig);
descriptionRes = orig.descriptionRes;
requestRes = orig.requestRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
flags = orig.flags;
priority = orig.priority;
@@ -106,6 +118,7 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
public void writeToParcel(Parcel dest, int parcelableFlags) {
super.writeToParcel(dest, parcelableFlags);
dest.writeInt(descriptionRes);
dest.writeInt(requestRes);
TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
dest.writeInt(flags);
dest.writeInt(priority);
@@ -124,6 +137,7 @@ public class PermissionGroupInfo extends PackageItemInfo implements Parcelable {
private PermissionGroupInfo(Parcel source) {
super(source);
descriptionRes = source.readInt();
requestRes = source.readInt();
nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
flags = source.readInt();
priority = source.readInt();

View File

@@ -197,6 +197,15 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
*/
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
* 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;
group = orig.group;
descriptionRes = orig.descriptionRes;
requestRes = orig.requestRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
}
@@ -315,6 +325,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
dest.writeInt(flags);
dest.writeString(group);
dest.writeInt(descriptionRes);
dest.writeInt(requestRes);
TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
}
@@ -334,6 +345,7 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
flags = source.readInt();
group = source.readString();
descriptionRes = source.readInt();
requestRes = source.readInt();
nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
}
}

View File

@@ -562,6 +562,7 @@
android:icon="@drawable/perm_group_contacts"
android:label="@string/permgrouplab_contacts"
android:description="@string/permgroupdesc_contacts"
android:request="@string/permgrouprequest_contacts"
android:priority="100" />
<!-- Allows an application to read the user's contacts data.
@@ -592,6 +593,7 @@
android:icon="@drawable/perm_group_calendar"
android:label="@string/permgrouplab_calendar"
android:description="@string/permgroupdesc_calendar"
android:request="@string/permgrouprequest_calendar"
android:priority="200" />
<!-- Allows an application to read the user's calendar data.
@@ -622,6 +624,7 @@
android:icon="@drawable/perm_group_sms"
android:label="@string/permgrouplab_sms"
android:description="@string/permgroupdesc_sms"
android:request="@string/permgrouprequest_sms"
android:priority="300" />
<!-- Allows an application to send SMS messages.
@@ -698,6 +701,7 @@
android:icon="@drawable/perm_group_storage"
android:label="@string/permgrouplab_storage"
android:description="@string/permgroupdesc_storage"
android:request="@string/permgrouprequest_storage"
android:priority="900" />
<!-- Allows an application to read from external storage.
@@ -759,6 +763,7 @@
android:icon="@drawable/perm_group_location"
android:label="@string/permgrouplab_location"
android:description="@string/permgroupdesc_location"
android:request="@string/permgrouprequest_location"
android:priority="400" />
<!-- Allows an app to access precise location.
@@ -791,6 +796,7 @@
android:icon="@drawable/perm_group_phone_calls"
android:label="@string/permgrouplab_phone"
android:description="@string/permgroupdesc_phone"
android:request="@string/permgrouprequest_phone"
android:priority="500" />
<!-- 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:label="@string/permgrouplab_microphone"
android:description="@string/permgroupdesc_microphone"
android:request="@string/permgrouprequest_microphone"
android:priority="600" />
<!-- Allows an application to record audio.
@@ -984,6 +991,7 @@
android:icon="@drawable/perm_group_camera"
android:label="@string/permgrouplab_camera"
android:description="@string/permgroupdesc_camera"
android:request="@string/permgrouprequest_camera"
android:priority="700" />
<!-- Required to be able to access the camera device.
@@ -1013,6 +1021,7 @@
android:icon="@drawable/perm_group_sensors"
android:label="@string/permgrouplab_sensors"
android:description="@string/permgroupdesc_sensors"
android:request="@string/permgrouprequest_sensors"
android:priority="800" />
<!-- Allows an application to access data from sensors that the user uses to

View File

@@ -1508,6 +1508,7 @@
<attr name="logo" />
<attr name="permissionGroup" />
<attr name="description" />
<attr name="request" />
<attr name="protectionLevel" />
<attr name="permissionFlags" />
</declare-styleable>
@@ -1535,6 +1536,7 @@
<attr name="banner" />
<attr name="logo" />
<attr name="description" />
<attr name="request" />
<attr name="permissionGroupFlags" />
<attr name="priority" />
</declare-styleable>

View File

@@ -643,46 +643,73 @@
<string name="permgrouplab_contacts">Contacts</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_contacts">access your contacts</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_contacts">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access your contacts</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_location">Location</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_location">access this device\'s location</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_location">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access this device\'s location</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_calendar">Calendar</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_calendar">access your calendar</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_calendar">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access your calendar</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_sms">SMS</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_sms">send and view SMS messages</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_sms">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to send and view SMS messages</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_storage">Storage</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_storage">access photos, media, and files on your device</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_storage">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access photos, media, and files on your device</string>
<!-- Title of a category of application permissioncds, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_microphone">Microphone</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_microphone">record audio</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_microphone">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to record audio</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_camera">Camera</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_camera">take pictures and record video</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_camera">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to take pictures and record video</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_phone">Phone</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_phone">make and manage phone calls</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_phone">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to make and manage phone calls</string>
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_sensors">Body Sensors</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_sensors">access sensor data about your vital signs</string>
<!-- Message shown to the user when the apps requests permission from this group -->
<string name="permgrouprequest_sensors">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access sensor data about your vital signs</string>
<!-- Title for the capability of an accessibility service to retrieve window content. -->
<string name="capability_title_canRetrieveWindowContent">Retrieve window content</string>