зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
ef97797c28
Коммит
5349aa6e59
|
@ -114,13 +114,13 @@ public class FilePicker implements BundleEventListener {
|
||||||
|
|
||||||
private static String[] getPermissionsForMimeType(final String mimeType) {
|
private static String[] getPermissionsForMimeType(final String mimeType) {
|
||||||
if (mimeType.startsWith("audio/")) {
|
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/")) {
|
} 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/")) {
|
} 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) {
|
private static boolean hasPermissionsForMimeType(final String mimeType, final String[] availPermissions) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче