The Wayback Machine - https://web.archive.org/web/20221103024719/https://github.com/zhanghai/MaterialFiles/issues/611
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

Allow android/data access even without root #611

Closed
dhammel opened this issue Oct 29, 2021 · 32 comments
Closed

Allow android/data access even without root #611

dhammel opened this issue Oct 29, 2021 · 32 comments
Assignees
Labels
duplicate This issue or pull request already exists question Further information is requested
Milestone

Comments

@dhammel
Copy link

dhammel commented Oct 29, 2021

Hello,

when I was messing with my new pixel 6 prior to rooting it, I realized MaterialFiles (unlike Amaze File Manager), doesn't have access to Apps External Storage, located (on pixel's at least): /storage/emulated/0/Android/data

this now either requires root, or to trigger it via SAF which would prompt a system dialog used to select that folder, to give MaterialFiles access to it, no root needed. It's the method amaze file manager uses.

Would you be open to implement SAF, to address this issue for non-root users?

@zhanghai
Copy link
Owner

zhanghai commented Oct 29, 2021

Another duplicate - Please use Add storage -> External storage.

@zhanghai zhanghai self-assigned this Oct 29, 2021
@zhanghai zhanghai added duplicate This issue or pull request already exists question Further information is requested labels Oct 29, 2021
@dhammel
Copy link
Author

dhammel commented Oct 29, 2021

@zhanghai

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

I was referring to using SAF to directly grant it access to Android/data, no need of manually going into different section of the app, even if above did work.

I've already seen an issue thread mentioning Add Storage -> External storage method.

@tp0
Copy link

tp0 commented Nov 1, 2021

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

Works for me. Only Android/media folder is visible, but I can select the parent Android folder.

@Hk-178
Copy link

Hk-178 commented Dec 10, 2021

How to acces SAF?. Pls help

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

Works for me. Only Android/media folder is visible, but I can select the parent Android folder.

@zhanghai
Copy link
Owner

zhanghai commented Dec 10, 2021

How to acces SAF?. Pls help

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

Works for me. Only Android/media folder is visible, but I can select the parent Android folder.

Hamburger menu > Add storage > External storage > Navigate to Android folder and grant access.

@Hk-178
Copy link

Hk-178 commented Dec 10, 2021

How to acces SAF?. Pls help

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

Works for me. Only Android/media folder is visible, but I can select the parent Android folder.

Hamburger menu > Add storage > External storage > Navigate to Android folder and grant access.

A million thanks ❤️‍🔥

@widmannt
Copy link

widmannt commented Feb 2, 2022

How to acces SAF?. Pls help

That has never worked for me. Once DocumentsProvider appears, browsing into Android folder, only shows 1 folder named media, with a message above saying Can't use this folder.

Works for me. Only Android/media folder is visible, but I can select the parent Android folder.

Hamburger menu > Add storage > External storage > Navigate to Android folder and grant access.

Unfortunately, this doesn't work for me in Android 12. I can't grant access to the Android folder (and the data subfolder isn't shown either). Please see the screenshot below. The message is saying something along the lines of "This folder can't be used. In order to protect your data, please select another folder."

screenshot

@Hk-178
Copy link

Hk-178 commented Feb 2, 2022

You can use the folder "Android'
On the sidebar, when u open Android folder after giving access , inside it there will be the data sub folder.

@widmannt
Copy link

widmannt commented Feb 3, 2022

You can use the folder "Android' On the sidebar, when u open Android folder after giving access , inside it there will be the data sub folder.

I can't give access to the Android folder. It doesn't let me, the button at the bottom of the screen is grayed out.

If someone knows of another workaround, please let me know. However it seems that the method of using 'Add storage' -> 'External storage' doesn't work in Android 12 because of new security/privacy restrictions. Neither Android nor Android/data can be accessed this way on my device.

As @dhammel pointed out, Amaze file manager can access Android/data in Android 12 using the SAF, I tested on my device as well. Apparently they call the SAF directly to request access to the Android/data subfolder. Android seems to be forbidden, and Android/data is hidden in DocumentsProvider, but the user can grant access when the app directly asks for the subfolder.

(Additionally I noticed that Amaze file manager needs 'Special app access' -> 'Access to all files'. Maybe this is required to make it work in Android 12?)

I'd appreciate if @zhanghai could verify my findings and maybe reopen the issue if appropriate. Also I'm happy to provide more information and test things out if that would help in any way.

@zhanghai
Copy link
Owner

zhanghai commented Feb 5, 2022

Oh, so Amaze is already directly asking the folder. I'll do the same then.

@zhanghai zhanghai added this to the v1.4.0 milestone Feb 5, 2022
@zhanghai
Copy link
Owner

zhanghai commented Feb 5, 2022

Added into the codebase and will be available in the next release. Note that there are other issues to resolve in order to release a new version, including #384, so it will not come very quickly.

data

@Hk-178
Copy link

Hk-178 commented Feb 5, 2022

https://drive.google.com/file/d/1hFjDjUsJ6rjCv4tqyhUIthBEkVFagQTV/view?usp=drivesdk
Take a look at this vid. I added /android/data folder to the side bar and i can open it and access the data

@zhanghai
Copy link
Owner

zhanghai commented Feb 6, 2022

It is known that some version of DocumentsUI allows adding sdcard/Android, some later version disallowed it, and then some later version allowed all directories (when the app targets a lower SDK version) again. I'm adding this to help people who are having an unfortunate version of DocumentsUI.

@widmannt
Copy link

widmannt commented Feb 6, 2022

That's great news! Thank you for your awesome work!

@klutzies
Copy link

klutzies commented May 8, 2022

Doesn't seem to be working on Android 13 Beta 1. When trying to open /storage/emulated/0/Android/data, instead of opening DUI, Material Files simply gives a "permission denied" error.

Screenshot_20220508-101230

@zhanghai
Copy link
Owner

zhanghai commented May 8, 2022

@unilock You are opening the directory directly in your screenshot, which is expected to not work. You need to use "Add storage" in navigation drawer, and then select "Android/data".

Note that even this is expected to stop working on a future Android version or security update.

@klutzies
Copy link

klutzies commented May 9, 2022

@zhanghai Doing so opens DUI at /sdcard, and navigating to /sdcard/Android shows only media, as expected.

@zhanghai
Copy link
Owner

zhanghai commented May 9, 2022

Then you've got the security fix and there's no good way around it. You can still use DUI to manage those files though.

@klutzies
Copy link

klutzies commented May 9, 2022

@zhanghai ZArchiver can access /Android/data, though, after directly opening the directory in DUI.
Maybe I broke something since I first installed Material Files - I'd reinstall it, but I don't want to lose my settings :)

Any plans for a settings backup feature...?

@zhanghai
Copy link
Owner

zhanghai commented May 11, 2022

I tried ZArchiver, and when openning Android/data inside it, it sent me to DUI with the path Android/data/ru.zdevs.zarchiver. If I select that folder in DUI, ZArchiver tells me I've selected the wrong directory. If I go up one level to Android/data, the "Use this folder" button in DUI is grey out, and the same for Android or SD card root.

So I don't think ZArchiver has any magic here either - you probably just have granted the access before your DUI is updated with security fix, and if you clear data for ZArchiver so that it loses the previously granted access, it probably won't be able to get the access back now.

For the same reason, I don't think reinstalling Material Files will do you any good for this DUI restriction. That being said, the intructions for backing up settings for this app can be found at #523 (comment) .

@klutzies
Copy link

klutzies commented May 13, 2022

@zhanghai

if you clear data for ZArchiver so that it loses the previously granted access, it probably won't be able to get the access back now.

ZArchiver's workaround still works; I just tested it again after clearing its app data, on Android 13 Beta 2. Example (after opening the app for the first time):
https://mega.nz/file/U9k01LwL#svvxdMVKaCKEwWWGZz1WqM5HAmtsRSoipCWTq-3aSP4

Resetting Material Files' app data didn't help, either. Same problem as in one of my previous comments - selecting "Add storage..." -> "Android/data" opens DUI at /sdcard (well, /storage/emulated/0, really).

@zhanghai
Copy link
Owner

zhanghai commented May 13, 2022

I see, ZArchiver probably hacked around the previous imperfect security fix that prevents opening DUI with Android/data, instead it opened Android/data/ru.zdevs.zarchiver and asked the user to navigate up to Android/data and select. You will probably get the proper fix that disables this hack upon the final T release as well (as in my previous comment), so I don't think it's worth implementing such a hack in this app.

@klutzies
Copy link

klutzies commented May 13, 2022

@zhanghai Fair enough. I guess the only "official" way to access Andorid/data would be via MTP / ADB then?

@zhanghai
Copy link
Owner

zhanghai commented May 13, 2022

I think so (it's not intended to be readable to third-party file managers), but you can also just use DocumentsUI directly.

@klutzies
Copy link

klutzies commented May 16, 2022

@zhanghai Ohh, I didn't know you could open DUI directly. Thanks!
(For those wondering, I used Activity Launcher to create a shortcut on my home screen to com.android.documentsui.files.FilesActivity.)

@VivekThummar52
Copy link

VivekThummar52 commented May 20, 2022

Add Storage ➝ /Android/data worked for me,

Now i can see all the nested folders inside data folder, Thank You @zhanghai !!

@ghost
Copy link

ghost commented Jul 2, 2022

Why can't I just grant access to the folders android/data and android/obb when I try to access them on android 11 Lineage OS for microg like other file explorers? Using add external storage option and navigating to android/data and android/obb and granting access works fine for internal storage but not SD card. Why is this the case? Hope I'm not a bother and thanks for all your hard work.

@TSIOJeft
Copy link

TSIOJeft commented Aug 6, 2022

Android 13 can't choose android/data folder?

@Manu99it
Copy link

Manu99it commented Aug 27, 2022

FV file explorer manager (that with blue icon on Play store) implemented an awesome trick for Android 13: select the app before and then it request the subfolder access. It's annoying that you need to do it for every app, but without root seems the only possibility for now. If you could implement it, would be awesome

@zhanghai zhanghai reopened this Aug 27, 2022
@zhanghai
Copy link
Owner

zhanghai commented Aug 27, 2022

The subdirectory hack is a known issue and has been reported, so it will be fixed in the future. I'm tired of playing such a cat & mouse game so if you want to access Android/data, please just use the built-in DocumentsUI for that.

@Manu99it
Copy link

Manu99it commented Aug 27, 2022

The subdirectory hack is a known issue and has been reported, so it will be fixed in the future. I'm tired of playing such a cat & mouse game so if you want to access Android/data, please just use the built-in DocumentsUI for that.

I can understand. Documents UI however is just horrible for serious file management

@FastenM
Copy link

FastenM commented Sep 4, 2022

@zhanghai Ohh, I didn't know you could open DUI directly. Thanks! (For those wondering, I used Activity Launcher to create a shortcut on my home screen to com.android.documentsui.files.FilesActivity.)

Adding this shortcut doesn't launch the android data path for me but rather the download folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
10 participants