Rory-Reid / Basemix

An application for UK rat breeders
https://basemix.app
MIT License
0 stars 0 forks source link

Fix file system access on android 13 + #13

Closed Rory-Reid closed 9 months ago

Rory-Reid commented 1 year ago

Looks like one user might be affected by a possible bug in MAUI on android 13. It looks like Android 13 changes some stuff around how file system access permissions work and as a result, the framework just doesn't handle it right.

Seems to be that it simply does not ask for permissions to use the file system on-demand. Might have to request these permissions up front or maybe declare a fallback API until there's an official fix?

See:

Rory-Reid commented 1 year ago

The above implies that the issue was resolved and hotfixed in dotnet 7, as well as upcoming in 8. This means an SDK and maui workflow update should resolve this for me.

I've updated both locally, I just need to publish a build with the new framework and confirm if the issue is resolved for affected users.

Rory-Reid commented 1 year ago

Building with the latest version appears to have got past the initial issue, but frustratingly now the user is not being prompted to choose a file location whatsoever, and files are just saving in some random directory.

Rory-Reid commented 1 year ago

So, broadly this is a bigger issue than "Microsoft forgot to do something". Android 13 comes with API 33 which introduces significant privacy/security based tightening of the external file access permissions. The two permissions I use, as expected by MAUI CommunityToolkit, are READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.

Android have changed these to do nothing now, and the only one that works is MANAGE_EXTERNAL_STORAGE but that requires special permission from google to let your app use that if you want to publish on the android store.

I might be able to make a justification but it might also be the case that using the Storage Access Framework gives me what I need here instead. The issue is I use the Community Toolkit to handle file saving, and AFAICT that does not have a means of using that.

Rory-Reid commented 9 months ago

Found the MAUI Share API which works for me

Fixed in https://github.com/Rory-Reid/Basemix/commit/3e38d8bb84022683705b44213e7e86faca06b473