Amazefilemanager: Android 11, Can't access /storage/emulated/0/android/data

Created on 17 Oct 2020  路  6Comments  路  Source: TeamAmaze/AmazeFileManager

App isn't fully capable of the scoped storage API calls for accessing said directory as a file manager.

  • Device: Pixel 3a
  • OS: Android 11
  • Rooted: No
  • Version: 3.5.0

I can't access files saved with apps like Telegram which store downloads in such a location. They don't even show up as recent files in anything else but the built-in file manager in Android (not google files, I have that disabled)

There should be a n actual API call specifically for file managers to access that location but as I'm not completely savvy on the inner workings of modern Android APIs I don't exactly know what it's called. This should probably be looked into heavily when building for Android 11 since the scoped storage API is mandatory now, and it should be seamless to Android 10 users already using the app.

Screenshot_20201017-061026
Screenshot_20201017-061111

Area-FileOperations Issue-Bug

All 6 comments

@SudosFTW I'd like to +1 to this... I'm expecting comments from @TranceLove here as he worked on the current implementation.

Best case scenario, you would want to ditch java.io.File at all and use content:// URI to even internal/external storages, so you won't need to maintain 2 sets of APIs.

But this is too a big task (that I may want to Kotlintize and refactor the whole HybridFile system) that perhaps too big to fit in 3.5 timeline as well.

@TranceLove I mean, no need to ditch File API at all.. just ways to fix the Android/data/ directories not being accessible right now. Even when we're explicitly giving Read / write permissions with the Uri.

As stated in https://developer.android.com/about/versions/11/privacy/storage:

Access to app-specific directories on external storage

On Android 11, apps can no longer access files in any other app's dedicated, app-specific directory within external storage.

Although, there were cases claimed that java.io.File APIs can still access these storage without problems. We probably need some kind of fallback mechanism so that when accessing files using content:// URI fails, we may try using java.io.File instead.

Meanwhile, may try to see if adding android:requestLegacyExternalStorage="true" to AndroidManifest.xml can be a band-it fix.

Will try make a case for this. Though getting Android 11 scoped storage work with Amaze is still a long battle...

Tried some little tests today with Pixel 4 emulator running stock Android 11. Even with opt-out of scoped storage with the 2 methods

  • no actions at all (compile with SDK 28, no extra flag in AndroidManifest.xml), that user will see Amaze is allowed to manage all files

Screenshot_1603265044

  • adding android:requestLegacyExternalStorage="true" and upgrade SDK to either 29 or 30 (which is required by setting this flag)

contents of data directory is still not visible. Not other apps too - only Android's own DocumentUI can get through.

Though some point in the future we shall be asking Google for MANAGE_EXTERNAL_STORAGE permission via app review anyway, I'm afraid users of Android 11 not using Google Play may be left behind unless Google reaches some kind of agreements with third-party app stores, since this permission shall only benefit apps distributed by Google Play.

Also check https://developer.android.com/training/data-storage for a quick table of file accessibility in Android 11.

Related crashes

Rename:

2020-11-16 03:34:28.529 5634-5935/com.amaze.filemanager.debug E/ActivityThread: Rename recovery failed 
    android.system.ErrnoException: rename failed: EXDEV (Cross-device link)
        at libcore.io.Linux.rename(Native Method)
        at libcore.io.ForwardingOs.rename(ForwardingOs.java:190)
        at libcore.io.BlockGuardOs.rename(BlockGuardOs.java:350)
        at libcore.io.ForwardingOs.rename(ForwardingOs.java:190)
        at android.app.ActivityThread$AndroidOs.rename(ActivityThread.java:7581)
        at java.io.UnixFileSystem.rename(UnixFileSystem.java:368)
        at java.io.File.renameTo(File.java:1412)
        at com.amaze.filemanager.asynchronous.asynctasks.MoveFiles.doInBackground(MoveFiles.java:109)
        at com.amaze.filemanager.asynchronous.asynctasks.MoveFiles.doInBackground(MoveFiles.java:59)
        at android.os.AsyncTask$3.call(AsyncTask.java:394)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)

Copy:

2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Android/data/DummyFile: open failed: EACCES (Permission denied)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:492)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.filesystem.FileUtil.isWritable(FileUtil.java:754)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.utils.MainActivityHelper.checkFolder(MainActivityHelper.java:420)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.asynchronous.asynctasks.PrepareCopyTask.finishCopying(PrepareCopyTask.java:325)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.asynchronous.asynctasks.PrepareCopyTask.onEndDialog(PrepareCopyTask.java:275)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.asynchronous.asynctasks.PrepareCopyTask.onEndDialog(PrepareCopyTask.java:269)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.asynchronous.asynctasks.PrepareCopyTask.onPostExecute(PrepareCopyTask.java:186)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.amaze.filemanager.asynchronous.asynctasks.PrepareCopyTask.onPostExecute(PrepareCopyTask.java:64)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.os.AsyncTask.finish(AsyncTask.java:771)
2020-11-16 03:34:56.761 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.os.AsyncTask.access$900(AsyncTask.java:199)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.os.Looper.loop(Looper.java:223)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7656)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.Linux.open(Native Method)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
2020-11-16 03:34:56.762 5634-5634/com.amaze.filemanager.debug W/System.err:     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7542)
2020-11-16 03:34:56.763 5634-5634/com.amaze.filemanager.debug W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:478)
2020-11-16 03:34:56.763 5634-5634/com.amaze.filemanager.debug W/System.err:     ... 17 more
Was this page helpful?
0 / 5 - 0 ratings