[Ohrrpgce] [ohrrpgce/ohrrpgce] Can't browse for .rpgs on Android 8+ (Issue #1226)

Ralph Versteegen notifications at github.com
Tue Nov 2 19:23:18 PDT 2021


Prifurin reported on Android 9 that (when using the generic ohrrpgce-game.apk) you can no longer browse directories (on external storage); you have have to put .rpg files inside ohrrpgce-game's data directory. Seems to affect Android 8+.

In AndroidManifest we request only WRITE_EXTERNAL_STORAGE, not READ_EXTERNAL_STORAGE. Actually, for packaged games we should not be requesting WRITE_EXTERNAL_STORAGE at all, as it's disconcerting for users, only for ohrrpgce-game.apk.

However Android 8 [changes this](https://developer.android.com/about/versions/oreo/android-8.0-changes#rmp), so requesting only WRITE_EXTERNAL_STORAGE is now broken:
>Prior to Android 8.0 (API level 26), if an app requested a permission at runtime and the permission was granted, the system also incorrectly granted 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.

Also, [WRITE_EXTERNAL_STORAGE docs](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE):
>Starting in API level 19 [Android 4.4], this permission is not required to read/write files in your application-specific directories returned by Context.getExternalFilesDir(String) and Context.getExternalCacheDir(). 

Which apparently is a different thing from "scoped storage":

> By default, apps targeting Android 10 and higher are given scoped access into external storage, or scoped storage. Such apps can see the following types of files within an external storage device without needing to request any storage-related user permissions:
> *   Files in the app-specific directory, accessed using getExternalFilesDir().
> ...

Additionally, there's [a whole article](https://developer.android.com/about/versions/11/privacy/storage) about changes to storage permissions and scoped storage in Android 11/API 30. Looking through it I think the main difference might be that if you play an .rpg on external storage, the engine will now fail to create a .saves directory next to it (so should fallback to internal storage). It also seems like it may no longer be necessary to request READ_EXTERNAL_STORAGE, which is great, except I we still need to do so to support older versions.

For example in the [Data Storage](https://developer.android.com/training/data-storage#permissions) docs:
> On earlier versions of Android, apps needed to declare the READ_EXTERNAL_STORAGE permission to access any file outside the app-specific directories on external storage. Also, apps needed to declare the WRITE_EXTERNAL_STORAGE permission to write to any file outside the app-specific directory.

> More recent versions of Android rely more on a file's purpose than its location for determining an app's ability to access, and write to, a given file. In particular, if your app targets Android 11 (API level 30) or higher, the WRITE_EXTERNAL_STORAGE permission doesn't have any effect on your app's access to storage. 


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ohrrpgce/ohrrpgce/issues/1226
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20211102/5ac7fa62/attachment.html>


More information about the Ohrrpgce mailing list