From e6c96ebb51efe69d3ae071c05d5726f66379da1b Mon Sep 17 00:00:00 2001 From: Jay Thomas Sullivan Date: Mon, 31 Jan 2022 18:38:18 -0800 Subject: Define new AUDIO/VIDEO/IMAGE permissions Define three new permissions: - READ_MEDIA_AUDIO: read audio files from external storage - READ_MEDIA_VIDEO: read video files from external storage - READ_MEDIA_IMAGE: read image files from external storage Also, define two new permission groups: - READ_MEDIA_AURAL - READ_MEDIA_VISUAL The permissions are assigned to permission groups as follows: READ_MEDIA_AURAL { READ_MEDIA_AUDIO } READ_MEDIA_VISUAL { READ_MEDIA_VIDEO READ_MEDIA_IMAGE } The motivation for this change is to support the "Media Permission Update for Android T" project. Bug: 201318587 Test: atest CtsPermissionTestCases CtsPermission3TestCases Change-Id: I1539ba4e401dac452e1b9717dc6c95035b28c18e --- core/api/current.txt | 5 ++ core/java/android/app/AppOpsManager.java | 6 +-- core/res/AndroidManifest.xml | 55 ++++++++++++++++++++++ .../res/drawable/perm_group_read_media_aural.xml | 26 ++++++++++ .../res/drawable/perm_group_read_media_visual.xml | 26 ++++++++++ core/res/res/values/strings.xml | 25 ++++++++++ 6 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 core/res/res/drawable/perm_group_read_media_aural.xml create mode 100644 core/res/res/drawable/perm_group_read_media_visual.xml diff --git a/core/api/current.txt b/core/api/current.txt index 19830c3990a1..dd0614648f8c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -135,6 +135,9 @@ package android { field public static final String READ_HOME_APP_SEARCH_DATA = "android.permission.READ_HOME_APP_SEARCH_DATA"; field @Deprecated public static final String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE"; field public static final String READ_LOGS = "android.permission.READ_LOGS"; + field public static final String READ_MEDIA_AUDIO = "android.permission.READ_MEDIA_AUDIO"; + field public static final String READ_MEDIA_IMAGE = "android.permission.READ_MEDIA_IMAGE"; + field public static final String READ_MEDIA_VIDEO = "android.permission.READ_MEDIA_VIDEO"; 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"; @@ -220,6 +223,8 @@ package android { field public static final String NEARBY_DEVICES = "android.permission-group.NEARBY_DEVICES"; field public static final String NOTIFICATIONS = "android.permission-group.NOTIFICATIONS"; field public static final String PHONE = "android.permission-group.PHONE"; + field public static final String READ_MEDIA_AURAL = "android.permission-group.READ_MEDIA_AURAL"; + field public static final String READ_MEDIA_VISUAL = "android.permission-group.READ_MEDIA_VISUAL"; field public static final String SENSORS = "android.permission-group.SENSORS"; field public static final String SMS = "android.permission-group.SMS"; field public static final String STORAGE = "android.permission-group.STORAGE"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index fdf37f6633ee..0d1bc05df67b 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -2363,11 +2363,11 @@ public class AppOpsManager { Manifest.permission.USE_BIOMETRIC, Manifest.permission.ACTIVITY_RECOGNITION, Manifest.permission.SMS_FINANCIAL_TRANSACTIONS, - null, + Manifest.permission.READ_MEDIA_AUDIO, null, // no permission for OP_WRITE_MEDIA_AUDIO - null, + Manifest.permission.READ_MEDIA_VIDEO, null, // no permission for OP_WRITE_MEDIA_VIDEO - null, + Manifest.permission.READ_MEDIA_IMAGE, null, // no permission for OP_WRITE_MEDIA_IMAGES null, // no permission for OP_LEGACY_STORAGE null, // no permission for OP_ACCESS_ACCESSIBILITY diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index b1ad3caf0d64..7df9ca73b0d5 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -977,6 +977,61 @@ android:permissionFlags="softRestricted|immutablyRestricted" android:protectionLevel="dangerous" /> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/res/res/drawable/perm_group_read_media_visual.xml b/core/res/res/drawable/perm_group_read_media_visual.xml new file mode 100644 index 000000000000..a5db2718c983 --- /dev/null +++ b/core/res/res/drawable/perm_group_read_media_visual.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 610c6a69822c..49a12d12ed21 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -880,6 +880,16 @@ access photos, media, and files on your device + + Music & other audio + + access audio files on your device + + + Photos & videos + + access images and video files on your device + Microphone @@ -1893,6 +1903,21 @@ Allows the app to read the contents of your shared storage. + + read audio files from shared storage + + Allows the app to read audio files from your shared storage. + + + read video files from shared storage + + Allows the app to read video files from your shared storage. + + + read image files from shared storage + + Allows the app to read image files from your shared storage. + modify or delete the contents of your shared storage -- cgit v1.2.3-59-g8ed1b From 7fd9adf992ef127d1473aca6b0a10b530ac0ca18 Mon Sep 17 00:00:00 2001 From: Jay Thomas Sullivan Date: Mon, 31 Jan 2022 18:38:46 -0800 Subject: Define splits for AUDIO/VIDEO/IMAGE permissions Define three permission splits: - READ_EXTERNAL_STORAGE to READ_MEDIA_AUDIO (targetSdk + + + + + + + + + -- cgit v1.2.3-59-g8ed1b