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

[bug] android 10: file system permission errors #338

Closed
Quackdoc opened this issue Sep 30, 2022 · 9 comments
Closed

[bug] android 10: file system permission errors #338

Quackdoc opened this issue Sep 30, 2022 · 9 comments
Assignees
Labels
bug Something isn't working critical Critical issue

Comments

@Quackdoc
Copy link

Describe the bug
No SAF accsess

To Reproduce
Install on android requiring SAF (roms that use scoped storage

Steps to reproduce the behavior:

  1. Add new folder for searching

Expected behavior

Open SAF prompt

Screenshots

SmartSelect_20220930-185435 (1)

Platform (please complete the following information)

  • OS: [e.g. Windows, Linux, Android]
  • Version Android 11

App version

Please confirm that you're on the latest version available.

  • Version: [e.g. v0.3.0]
    v0.3.3
@Quackdoc Quackdoc added the bug Something isn't working label Sep 30, 2022
@Quackdoc Quackdoc changed the title [ANDROID] [ANDROID] No Storage accsess framework support means cannot add folder Sep 30, 2022
@alexmercerind
Copy link
Member

alexmercerind commented Oct 1, 2022

Hi!
Before proceeding to the actual answer, I wanna clarify that Harmonoid is 100% compatible with scoped storage (Android 10 or higher). It's well tested, all the way back from Android 5.0 to latest Android 13.0.
Harmonoid is one of the only music players on Android which give fine control over folder selection for music library indexing.

Device: Redmi Note 10S (secret), ROM: Pixel Experience 12.0 GSI, Android: Android 12.0 (API Level 31).
See how native SAF picker cannot select root folder or "Downloads" folder.

Custom directory picker in Harmonoid SAF directory picker

Harmonoid still uses SAF picker for .lrc file picker, and that's fine because we just need to contents of that file & cache for future.

But for picking folder for music library, SAF does not allow to select the:

  • Storage's root folder.
  • Downloads folder.
  • Other app's private directories.

It's because SAF gives the permission along the way.
So, only way around this was to create a custom file picker, which just allows to pick the folder & return it's exact path.

It works with both SAF & non-SAF Android versions, because there's no permission management at-all.

If we use newer READ_EXTERNAL_STORAGE (Android 10 to Android 12), only media files are shown in this file picker.
If we use READ_MEDIA_AUDIO (Android 13), only music/audio files are shown. A dedicated section in Harmonoid's Settings is present for requesting images aswell.
On older Android versions (non scoped-storage), everything shows.


My best guess will be that the ROM developers messed up something.
It's not really a good idea to break the universal APIs & contracts that apps depend upon.

Thanks!

@alexmercerind alexmercerind added the in triage The reported bug is under triage label Oct 1, 2022
@alexmercerind
Copy link
Member

For further details, Harmonoid uses this to get the root-dir path of available storages (internal & SD card) on an Android:

val volumes: List<String> = context.getExternalFilesDirs(null).map { file -> file.absolutePath.split("/Android/")[0] }

@Quackdoc
Copy link
Author

Quackdoc commented Oct 1, 2022

Interesting, I can provide logs for stock S9+ if you think that will help, and can confirm the same issue on a stock LG I think V30?

I can confirm that opening a single music file using the open file or URL link does work on Samsung.

if it's a perms thing, I wonder if there's an ADB command I can run?

@Quackdoc
Copy link
Author

Quackdoc commented Oct 1, 2022

Does seem to be some kind of permissions issue. not sure if there is a good fix for it or not

FileSystemException: Directory listing failed, path = '/storage/emulated/0/' (OS Error: Permission denied, errno = 13)

EDIT: not a fix but I allowed harmonoid to use LEGACY_STORAGE and it works, if anyone is looking for an easy way to do this, app manager from fdroid can easily do this in "APP OPS" section

@alexmercerind
Copy link
Member

I'm not certain about this, but I think even not having legacy storage access will allow to iterate over directories.
It just won't show the non-media files (or non-audio files on SDK 32+).

@alexmercerind alexmercerind removed the in triage The reported bug is under triage label Oct 1, 2022
@alexmercerind
Copy link
Member

alexmercerind commented Oct 1, 2022

Since, current implementation is very coupled with Directory/ File paths (to share code with Windows & Linux), I don't think there's much that can be done.

I just tested on my friend's Samsung device. Maybe, Samsung did some special treatment to their OS for storage access & permissions.

@alexmercerind alexmercerind added the critical Critical issue label Oct 1, 2022
@alexmercerind alexmercerind changed the title [ANDROID] No Storage accsess framework support means cannot add folder android 10: file system permission errors Oct 1, 2022
@alexmercerind alexmercerind changed the title android 10: file system permission errors [bug] android 10: file system permission errors Oct 1, 2022
@alexmercerind
Copy link
Member

alexmercerind commented Oct 1, 2022

Thanks for the report once again!
I've tested on variety of Android devices now... Samsung, Xiaomi, Oppo & Huawei with both Android 10 & 11+.

The issue is only present on Android 10 specifically (because scoped storage was newly enforced in it & had some issues).

Expect the fix to be rolling out soon.

Interesting, I can provide logs for stock S9+ if you think that will help, and can confirm the same issue on a stock LG I think V30 ?

https://www.gsmarena.com/samsung_galaxy_s9+-8967.php shows Android 10.0.
https://www.gsmarena.com/lg_v30-8712.php shows Android 9.0.

Are both of your devices bugging with app? Android 9.0 has no scoped storage.

@Quackdoc
Copy link
Author

Quackdoc commented Oct 1, 2022

My phone is indeed Android 10 my bad I was testing it on an Android 11 image in qemu and had made a mistake due to that being a separate issue that I haven't quite figured out yet.

I'm not sure what Android version the other phone is. since it's my father's. I thought it was a V30 but if you say it's limited to Android 10, which I do believe. then it's probably a v50 which has Android 9 through 11, so there's a strong chance that was android 10 as well.

@alexmercerind
Copy link
Member

Hi @Quackdoc, the issue has been fixed. You may download & install the updated APK: https://harmonoid.com/downloads.

Google Play version will take some time (maybe ~1 day) to update after review.
I won't recommend uninstalling & it'd cause you to lose your playlists.
Thanks!

alexmercerind added a commit that referenced this issue Dec 3, 2022
* `android:requestLegacyExternalStorage` is present for supporting Android 10 (API level 29) specifically.
* Harmonoid is completely scoped storage friendly for Android 11+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical Critical issue
Projects
None yet
Development

No branches or pull requests

2 participants