From 2b90ab41057b591dd73b09a6b2fd2ac3c2b8bf5b Mon Sep 17 00:00:00 2001 From: Nate Myren Date: Mon, 24 Oct 2022 14:55:28 -0700 Subject: Add READ_MEDIA_VISUAL_USER_SELECTED permission and appop Bug: 25178384 Test: atest PermissionPolicyTest Merged-In: I4dadcad364d0a646619e50165c06d5b4be6d6726 Change-Id: I4dadcad364d0a646619e50165c06d5b4be6d6726 --- core/api/current.txt | 1 + core/api/system-current.txt | 1 + core/java/android/app/AppOpsManager.java | 20 +++++++++++++++++++- core/res/AndroidManifest.xml | 12 ++++++++++++ core/res/res/values/strings.xml | 5 +++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/api/current.txt b/core/api/current.txt index c8a43db2f9c2..805dd5222666 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -140,6 +140,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 0126199add0c..42b2de099403 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -571,6 +571,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_EMERGENCY_BROADCAST = "android:receive_emergency_broadcast"; field public static final String OPSTR_REQUEST_DELETE_PACKAGES = "android:request_delete_packages"; field public static final String OPSTR_REQUEST_INSTALL_PACKAGES = "android:request_install_packages"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index cb64173b7809..53f48fbb554f 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1343,9 +1343,17 @@ public class AppOpsManager { public static final int OP_RECEIVE_AMBIENT_TRIGGER_AUDIO = AppProtoEnums.APP_OP_RECEIVE_AMBIENT_TRIGGER_AUDIO; + /** + * 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 = 121; + public static final int _NUM_OP = 122; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; @@ -1815,6 +1823,14 @@ public class AppOpsManager { */ 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"; /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; @@ -1906,6 +1922,7 @@ public class AppOpsManager { OP_USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER, OP_SCHEDULE_EXACT_ALARM, OP_MANAGE_MEDIA, + OP_READ_MEDIA_VISUAL_USER_SELECTED, }; /** @@ -2038,6 +2055,7 @@ public class AppOpsManager { OP_ESTABLISH_VPN_MANAGER, // OP_ESTABLISH_VPN_MANAGER OP_ACCESS_RESTRICTED_SETTINGS, // OP_ACCESS_RESTRICTED_SETTINGS OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, // RECEIVE_SOUNDTRIGGER_AUDIO + OP_READ_MEDIA_VISUAL_USER_SELECTED, // READ_MEDIA_VISUAL_USER_SELECTED }; /** diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 1a5ce3aeaeba..b93012b1edac 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1146,6 +1146,18 @@ android:description="@string/permdesc_readMediaImages" android:protectionLevel="dangerous" /> + + + Allows the app to read image files from your shared storage. + + read user selected image and video files from shared storage + + Allows the app to read image and video files that you select from your shared storage. + modify or delete the contents of your shared storage -- cgit v1.2.3-59-g8ed1b