d4rken-org / sdmaid

SD Maid is an Android app that helps you manage files and apps.
https://play.google.com/store/apps/details?id=eu.thedarken.sdm
1.53k stars 754 forks source link

Android/data access on Android 11 (SAF Workaround) #4571

Closed d4rken closed 3 years ago

d4rken commented 3 years ago

While no one knows when Google will open the registration to get an exemption for file managers from Scoped storage (see #3875), we can do what X-Plore did and while we are on targetSdkVersion 29 use the SAF to read Android/data.

This is a huge change as it will require a whole new way of read access, but not an insurmountable task. SD Maid already has a common hub for I/O operations (SmartIO) that acts as an indirection for file operations, which first checks what type of path the operation targets, then returns a type NORMAL/ROOT/SAF/NONE, and then generates a reader/writer for that type, depending on which type was determined. Due to the long standing restrictions on external storage, SD Maid has a WRITER for type SAF, but not a READER. That's what we will have to add. I expect it to be quite slow in comparison to normal (Java based access) or root (through shells), but better than nothing right :shrug: ?

This will need manual access being granting by selecting the path similar to how external storage access is currently granted. We can probably reuse the same setup step. Though I like that X-Plore did, the screenshot they added, maybe we should do that too?

Added "Help / Wanted Label", what other apps than X-Plore use the SAF to read the primary storage (/storage/emulated/0)?

d4rken commented 3 years ago

Should work now for CorpseFinder, SystemCleaner and AppCleaner, not yet for StorageAnalyzer, Duplicates and Explorer copy/move.