Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READ/WRITE permissions not being set #258

Closed
anotherlab opened this issue Mar 12, 2023 · 2 comments
Closed

READ/WRITE permissions not being set #258

anotherlab opened this issue Mar 12, 2023 · 2 comments
Labels
bug Default bug tag for tracking by-design This issue is by design

Comments

@anotherlab
Copy link

Steps to reproduce

In WSA build 2301:
Write a .NET MAUI application that:
Sets the READ/WRITE permissions in the Platforms\Android\AndroidManifest.xml with the following syntax

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

And uses the CommunityToolkit.MAUI folder picker with the following syntax

CancellationTokenSource source = new();
CancellationToken cancellationToken = source.Token;

var folderPickerResult = await FolderPicker.PickAsync(cancellationToken);

if (folderPickerResult.IsSuccessful) {
  await Toast.Make($"Folder picked: Name - {folderPickerResult.Folder.Name}, Path - {folderPickerResult.Folder.Path}", ToastDuration.Long).Show(cancellationToken);
}
else {
  await Toast.Make($"Folder is not picked, {folderPickerResult.Exception.Message}").Show(cancellationToken);
}

I have taken the sample .NET MAUI project and replaced the sample code with a button that will invoke the filepicker. This projects can be cloned from https://github.com/anotherlab/wsapermissions

✔️ Expected Behavior

Expected to get a "Allow XYZ to access photos and media on your device?" prompt, followed by a folder picker showing the same folder structure that would come up on an Android device or emulator.

This code works as expected for Android devices and emulators.

❌ Actual Behavior

Permissions prompt does not appear and call to FolderPicker.PickAsync comes back a FolderPickerResult.object with the IsSuccessful property set to false and the Exception.Message property set to "Storage permission is not granted."

If you set the permissions via adb with the syntax like the following:

adb -s 127.0.0.1:58526 shell pm grant com.companyname.wsapermissions android.permission.READ_EXTERNAL_STORAGE

Then the folderpicker comes up in the expected folder. You are still not prompted to give the app permissions until you actually pick a folder.

Other Software

Using .NET MAUI 7 with Visual Studio 17.6.0 on Windows 11

Please specify the version of Windows Subsystem for Android

2301.40000.7.0

@anotherlab anotherlab added bug Default bug tag for tracking triage-needed For issues raised to be triaged and prioritized by internal Microsoft teams labels Mar 12, 2023
@nieubank
Copy link

nieubank commented Mar 12, 2023

Thanks for reporting this issue. There is a change for apps targeting Android 13 related to granular media permissions that could be in play here.

Have you tried reproducing this on an Android 13 device, e.g. Pixel or otherwise?

@anotherlab
Copy link
Author

anotherlab commented Mar 12, 2023

I just tested on a Samsung Galaxy S22 running Android 13 and saw the same issue. I tried adding the granular media permissions as described by Google, but that didn't change the problem. But it's not a WSA "thing", it's a CommunityToolkit thing. !I'll file this in that repo It was reported and requires a fix to MAUI and this one can be closed as works as designed.

@jaholme jaholme added by-design This issue is by design and removed triage-needed For issues raised to be triaged and prioritized by internal Microsoft teams labels Mar 13, 2023
@jaholme jaholme closed this as completed Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Default bug tag for tracking by-design This issue is by design
Projects
None yet
Development

No branches or pull requests

3 participants