summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nate Myren <ntmyren@google.com> 2022-11-01 19:54:47 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-11-01 19:54:47 +0000
commit1a2f6fcaaa2f7f44f4feac6a3e972d96f7bb99d6 (patch)
treebcf3c0058f483d7e0c31ccd0e4fbf15a870a52d7
parentfa16d9b0833c1b7133c199da0389d3c9c59fe5fa (diff)
parentb7f175ccd9b2fb4485c84a91816a7750330fdc72 (diff)
Merge "Add READ_MEDIA_VISUAL_USER_SELECTED permission and appop"
-rw-r--r--core/api/current.txt1
-rw-r--r--core/api/system-current.txt1
-rw-r--r--core/java/android/app/AppOpsManager.java25
-rw-r--r--core/res/AndroidManifest.xml12
-rw-r--r--core/res/res/values/strings.xml5
5 files changed, 42 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index b42face946a8..dcf495d49700 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -143,6 +143,7 @@ package android {
field public static final String READ_MEDIA_AUDIO = "android.permission.READ_MEDIA_AUDIO";
field public static final String READ_MEDIA_IMAGES = "android.permission.READ_MEDIA_IMAGES";
field public static final String READ_MEDIA_VIDEO = "android.permission.READ_MEDIA_VIDEO";
+ field public static final String READ_MEDIA_VISUAL_USER_SELECTED = "android.permission.READ_MEDIA_VISUAL_USER_SELECTED";
field public static final String READ_NEARBY_STREAMING_POLICY = "android.permission.READ_NEARBY_STREAMING_POLICY";
field public static final String READ_PHONE_NUMBERS = "android.permission.READ_PHONE_NUMBERS";
field public static final String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 76d577e5f4e7..352b4f98edd3 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -587,6 +587,7 @@ package android.app {
field public static final String OPSTR_READ_MEDIA_AUDIO = "android:read_media_audio";
field public static final String OPSTR_READ_MEDIA_IMAGES = "android:read_media_images";
field public static final String OPSTR_READ_MEDIA_VIDEO = "android:read_media_video";
+ field public static final String OPSTR_READ_MEDIA_VISUAL_USER_SELECTED = "android:read_media_visual_user_selected";
field public static final String OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO = "android:receive_ambient_trigger_audio";
field public static final String OPSTR_RECEIVE_EMERGENCY_BROADCAST = "android:receive_emergency_broadcast";
field public static final String OPSTR_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO = "android:receive_explicit_user_interaction_audio";
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 1b972e0cb81a..267e5b699241 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -1360,9 +1360,17 @@ public class AppOpsManager {
*/
public static final int OP_RUN_LONG_JOBS = AppProtoEnums.APP_OP_RUN_LONG_JOBS;
+ /**
+ * Notify apps that they have been granted URI permission photos
+ *
+ * @hide
+ */
+ public static final int OP_READ_MEDIA_VISUAL_USER_SELECTED =
+ AppProtoEnums.APP_OP_READ_MEDIA_VISUAL_USER_SELECTED;
+
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- public static final int _NUM_OP = 123;
+ public static final int _NUM_OP = 124;
/** Access to coarse location information. */
public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1833,6 +1841,14 @@ public class AppOpsManager {
@SystemApi
public static final String OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO =
"android:receive_ambient_trigger_audio";
+ /**
+ * Notify apps that they have been granted URI permission photos
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final String OPSTR_READ_MEDIA_VISUAL_USER_SELECTED =
+ "android:read_media_visual_user_selected";
/**
* Record audio from near-field microphone (ie. TV remote)
@@ -1948,6 +1964,7 @@ public class AppOpsManager {
OP_MANAGE_MEDIA,
OP_TURN_SCREEN_ON,
OP_RUN_LONG_JOBS,
+ OP_READ_MEDIA_VISUAL_USER_SELECTED,
};
static final AppOpInfo[] sAppOpInfos = new AppOpInfo[]{
@@ -2329,7 +2346,11 @@ public class AppOpsManager {
"RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO").setDefaultMode(
AppOpsManager.MODE_ALLOWED).build(),
new AppOpInfo.Builder(OP_RUN_LONG_JOBS, OPSTR_RUN_LONG_JOBS, "RUN_LONG_JOBS")
- .setPermission(Manifest.permission.RUN_LONG_JOBS).build()
+ .setPermission(Manifest.permission.RUN_LONG_JOBS).build(),
+ new AppOpInfo.Builder(OP_READ_MEDIA_VISUAL_USER_SELECTED,
+ OPSTR_READ_MEDIA_VISUAL_USER_SELECTED, "READ_MEDIA_VISUAL_USER_SELECTED")
+ .setPermission(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)
+ .setDefaultMode(AppOpsManager.MODE_ALLOWED).build()
};
/**
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index d8ecb5c65384..16e0a5967e78 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1150,6 +1150,18 @@
android:description="@string/permdesc_readMediaImages"
android:protectionLevel="dangerous" />
+ <!-- Allows an application to read image or video files from external storage that a user has
+ selected via the permission prompt photo picker. Apps can check this permission to verify that
+ a user has decided to use the photo picker, instead of granting access to
+ {@link #READ_MEDIA_IMAGES or #READ_MEDIA_VIDEO}. It does not prevent apps from accessing the
+ standard photo picker manually.
+ <p>Protection level: dangerous -->
+ <permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
+ android:permissionGroup="android.permission-group.UNDEFINED"
+ android:label="@string/permlab_readVisualUserSelect"
+ android:description="@string/permdesc_readVisualUserSelect"
+ android:protectionLevel="dangerous" />
+
<!-- Allows an application to write to external storage.
<p><strong>Note: </strong>If your app targets {@link android.os.Build.VERSION_CODES#R} or
higher, this permission has no effect.
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 509de3364f0e..1f459c6f623d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1933,6 +1933,11 @@
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. "shared storage" refers to a storage space on the device that all apps with this permission can read from. [CHAR LIMIT=none] -->
<string name="permdesc_readMediaImages">Allows the app to read image files from your shared storage.</string>
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. "shared storage" refers to a storage space on the device that all apps with this permission can read from. [CHAR LIMIT=none] -->
+ <string name="permlab_readVisualUserSelect">read user selected image and video files from shared storage</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. "shared storage" refers to a storage space on the device that all apps with this permission can read from. [CHAR LIMIT=none] -->
+ <string name="permdesc_readVisualUserSelect">Allows the app to read image and video files that you select from your shared storage.</string>
+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. "shared storage" refers to a storage space on the device that all apps with this permission can write to. [CHAR LIMIT=none] -->
<string name="permlab_sdcardWrite">modify or delete the contents of your shared storage</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. "shared storage" refers to a storage space on the device that all apps with this permission can write to. [CHAR LIMIT=none] -->