Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug][Android] MediaPicker permission for storage read doesn't work as intended on Android #1656

Closed
McFlemchSoda opened this issue Jan 26, 2021 · 5 comments · Fixed by #1658
Labels
bug Something isn't working

Comments

@McFlemchSoda
Copy link

I found this closed issue which exactly represents the issue with MediaPicker now: #1537

Recap and quoting the closed issue:
"When using the MediaPicker on Android (Android 8 & 10) I noticed that the permission prompt for the storage read permission didn't work properly: When choosing "Deny" from the prompt the file system is still opened, even though it shouldn't. From reading the source code it seems that the permission is only asked, but nothing is done with the result (line 25): await Permissions.RequestAsync<Permissions.StorageRead>();."

Feels like an unfortunate copy/paste bug.

Steps to Reproduce

  1. Bind the MediaPicker.PickPhotoAsync() method to a button.
  2. Run the application on an Android device (I did this on a Samsung with Android 8 & 10).
  3. Press the button that has PickPhotoAsync bound to
  4. From the permission prompt select "Deny"

Expected Behavior

Photo system doesn't open.

Actual Behavior

Photo system opens, even though it shouldn't have the right permission. User is still able to navigate the file system and pick files from it.

Basic Information

  • Version with issue: Xamarin.Essentials 1.6.0
  • Last known good version:
  • IDE: VS for Mac
  • Platform Target Frameworks:
    • Android: 8 & 10
  • Android Support Library Version:
  • Nuget Packages: Xamarin.Essentials 1.6.0
  • Affected Devices: Sansumg Galaxy S8 Android 8 & Samsung A50 Android 10

Workaround

I'm working around this issue by prompting the permission request myself before we use the MediaPicker. If the user denies, the user won't be able to use this functionality.

@McFlemchSoda McFlemchSoda added the bug Something isn't working label Jan 26, 2021
@McFlemchSoda McFlemchSoda changed the title [Bug] MediaPicker permission for storage read doesn't work as intended on Android [Bug][Android] MediaPicker permission for storage read doesn't work as intended on Android Jan 26, 2021
@mattleibow
Copy link
Contributor

This was fixed in the new 1.6.1 release.

Duplicate of #1649

@McFlemchSoda
Copy link
Author

@mattleibow When I look at that issue, and looking at the PR changes, it only changes it for FilePicker, not for MediaPicker. The same needs to be done for MediaPicker. Or am I missing something? PR files changed: https://github.com/xamarin/Essentials/pull/1651/files
Issue in MediaPicker: https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs

@mattleibow mattleibow reopened this Jan 26, 2021
mattleibow added a commit that referenced this issue Jan 26, 2021
@mattleibow mattleibow mentioned this issue Jan 26, 2021
5 tasks
@mattleibow
Copy link
Contributor

We can just pretend this did not happen...

mattleibow added a commit that referenced this issue Jan 27, 2021
CartBlanche pushed a commit to CartBlanche/Essentials that referenced this issue Sep 21, 2021
@mcblacksea
Copy link

As far as I can see issue still exists, once Permissions was Denied by user
for the await MediaPicker.PickPhotoAsync(..):

image

@andycnguyen
Copy link

I'm still finding this issue as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants