From 5349aa6e59b894d0e7d507b59e9fb013e9f2b59d Mon Sep 17 00:00:00 2001 From: Petru Lingurar Date: Fri, 22 Feb 2019 15:43:13 +0000 Subject: [PATCH] Bug 1507531 - FilePicker will request WRITE_EXTERNAL_STORAGE; r=JanH "Prior to Android 8.0 (API level 26), if an app requested a permission at runtime and the permission was granted, the system would also incorrectly grant the app the rest of the permissions that belonged to the same permission group, and that were registered in the manifest. For apps targeting Android 8.0, this behavior has been corrected. The app is granted only the permissions it has explicitly requested. However, once the user grants a permission to the app, all subsequent requests for permissions in that permission group are automatically granted." https://developer.android.com/about/versions/oreo/android-8.0-changes#rmp Our FilePicker can delegate other applications to record media files (photo/audio/video) which are then to be sent to websites. They must be saved locally before the upload, scenario that wasn't possible anymore on Oreo+ because of the change in how Android handles runtime permissions. As a way to get around this one could grant the "Storage" permission from System Settings which would grant the app both READ and WRITE access. But for actually being prepared to handle all situations our FilePicker must ask for the WRITE_EXTERNAL_STORAGE permission at runtime. Differential Revision: https://phabricator.services.mozilla.com/D20821 --HG-- extra : moz-landing-system : lando --- .../android/base/java/org/mozilla/gecko/FilePicker.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/java/org/mozilla/gecko/FilePicker.java b/mobile/android/base/java/org/mozilla/gecko/FilePicker.java index 48fc919a5b83..b6b7856372b6 100644 --- a/mobile/android/base/java/org/mozilla/gecko/FilePicker.java +++ b/mobile/android/base/java/org/mozilla/gecko/FilePicker.java @@ -114,13 +114,13 @@ public class FilePicker implements BundleEventListener { private static String[] getPermissionsForMimeType(final String mimeType) { if (mimeType.startsWith("audio/")) { - return new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }; + return new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }; } else if (mimeType.startsWith("image/")) { - return new String[] { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE }; + return new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }; } else if (mimeType.startsWith("video/")) { - return new String[] { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE }; + return new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }; } - return new String[] { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE }; + return new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }; } private static boolean hasPermissionsForMimeType(final String mimeType, final String[] availPermissions) {