Commit 3153bedb authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Photo Picker: Fix crash when denying Storage permission.

Bug: 950024, 656015
Change-Id: Id0f9a491ab3e5260f41a01c0a5ace1ed66c0c97e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572123
Auto-Submit: Finnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652165}
parent 44be77d3
......@@ -155,15 +155,12 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback, PhotoPick
new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION));
List<String> missingPermissions = new ArrayList<>();
if (shouldUsePhotoPicker()) {
if (BuildInfo.isAtLeastQ()) {
String newImagePermission = "android.permission.READ_MEDIA_IMAGES";
if (!window.hasPermission(newImagePermission)) {
missingPermissions.add(newImagePermission);
}
} else if (!window.hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
missingPermissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
String storagePermission = BuildInfo.isAtLeastQ()
? "android.permission.READ_MEDIA_IMAGES"
: Manifest.permission.READ_EXTERNAL_STORAGE;
boolean shouldUsePhotoPicker = shouldUsePhotoPicker();
if (shouldUsePhotoPicker) {
if (!window.hasPermission(storagePermission)) missingPermissions.add(storagePermission);
} else {
if (((mSupportsImageCapture && shouldShowImageTypes())
|| (mSupportsVideoCapture && shouldShowVideoTypes()))
......@@ -183,9 +180,17 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback, PhotoPick
missingPermissions.toArray(new String[missingPermissions.size()]);
window.requestPermissions(requestPermissions, (permissions, grantResults) -> {
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] == PackageManager.PERMISSION_DENIED && mCapture) {
onFileNotSelected();
return;
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
if (mCapture) {
onFileNotSelected();
return;
}
if (shouldUsePhotoPicker
&& requestPermissions[i].equals(storagePermission)) {
onFileNotSelected();
return;
}
}
}
launchSelectFileIntent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment