zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
6.07k stars 410 forks source link

Allow android/data access even without root #611

Closed CodeCracker-oss closed 2 years ago

CodeCracker-oss commented 3 years ago

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 commented 3 years ago

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

CodeCracker-oss commented 3 years ago

@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 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

zhanghai commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

unilock commented 2 years ago

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 commented 2 years ago

@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.

unilock commented 2 years ago

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

zhanghai commented 2 years ago

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.

unilock commented 2 years ago

@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 commented 2 years ago

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 https://github.com/zhanghai/MaterialFiles/issues/523#issuecomment-1109345510 .

unilock commented 2 years ago

@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 commented 2 years ago

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.

unilock commented 2 years ago

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

zhanghai commented 2 years ago

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

unilock commented 2 years ago

@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 commented 2 years ago

Add Storage ➝ /Android/data worked for me,

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

ghost commented 2 years ago

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.

Manu99it commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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.

DerGoogler commented 1 year ago

If you above Android 13 there is no way to access Android/data or Android/obb. Is has a reason why the folders are restricted.

The only possible way is root.

CodeCracker-oss commented 1 year ago

@DerGoogler There is a way to do it via SAF, developer of Material Files just hasn't implemented it. Amaze File Manager works well for this case. Tested on my Pixel 6 Android 13, January 2023 security update

You can access it via adb as well, if you don't have or want root.

locuturus commented 1 year ago

@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.

You can create shortcuts that open DUI directly to any folder you want. But it's a bit of a manual process because no app developer has come along to make it easy.

One app you can use is Shortcut Maker, by Rushikesh Kamewar, from the Play Store. Other apps that let you build an android intent will also work.

Screenshot_20230411-085840

The above will open the folder containing downloaded podcasts for AntennaPod (assuming it exists).

The key takeaways are you are sending an action.VIEW intent, and the filepath is in the Data section. It expects a URI format and externalstorage is the document provider. %3A is like / for root of sdcard, and %2F is like / for every folder after sdcard. Mime type makes sure DUI sees the intent and the flags I chose are important to create a fresh window every time you use the shortcut. If you didn't know it already DUI can have many many windows and if you don't create a fresh one the last one you interacted with might grab the intent but not follow the path you gave it. The package name and class are optional. They skip the open-with dialogue. Otherwise some apps, like Material Files, will offer to open this kind of intent but they always fail.

locuturus commented 1 year ago

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

I wonder if I can help in any way? I find DUI to be pretty good for 80% of file manager tasks I do. What are you wanting to do with it? There are non-obvious tricks and methods sometimes. But for sure it lacks some seemingly basic stuff.

unOmni commented 11 months ago

Need some help. I had android/data working when i used external storage and then it directed it me straight to data. But now that i reset my phone, i can't get it to work anymore. Zarchive redirects me to data and obb by itself when i tried just now but nothing here.

Manu99it commented 11 months ago

Need some help. I had android/data working when i used external storage and then it directed it me straight to data. But now that i reset my phone, i can't get it to work anymore. Zarchive redirects me to data and obb by itself when i tried just now but nothing here.

Simply on Android 14 the method used before doesn't work anymore. If you updated from Android 13 to 14 then the app retain the permission to folders you previously permitted. If you install the app ex-novo, reset it, or you want to access a folder into android/data that you never permitted to, for now seems you can't. You can still access android/data with a PC or through ADB, or with the default file manager although lacking many features

unOmni commented 11 months ago

Need some help. I had android/data working when i used external storage and then it directed it me straight to data. But now that i reset my phone, i can't get it to work anymore. Zarchive redirects me to data and obb by itself when i tried just now but nothing here.

Simply on Android 14 the method used before doesn't work anymore. If you updated from Android 13 to 14 then the app retain the permission to folders you previously permitted. If you install the app ex-novo, reset it, or you want to access a folder into android/data that you never permitted to, for now seems you can't. You can still access android/data with a PC or through ADB, or with the default file manager although lacking many features

Forgot to say that I'm on Android 12 still.

Manu99it commented 11 months ago

@unOmni then you can try MiXplorer, Solid Explorer, Xplore, they should be able to access android/data

Edit: I must correct myself because I found the solution. Simply uninstall the updates of the default Files app. Doing so the functionality is restored even in Android 14!

unOmni commented 11 months ago

@unOmni then you can try MiXplorer, Solid Explorer, Xplore, they should be able to access android/data

Edit: I must correct myself because I found the solution. Simply uninstall the updates of the default Files app. Doing so the functionality is restored even in Android 14!

I tried that before just some hours ago but nothing worked. It's actually the reason a reset my phone just so I don't have to see the default Files app that appeared after removing it's updates.

Manu99it commented 11 months ago

@unOmni then you can try MiXplorer, Solid Explorer, Xplore, they should be able to access android/data Edit: I must correct myself because I found the solution. Simply uninstall the updates of the default Files app. Doing so the functionality is restored even in Android 14!

I tried that before just some hours ago but nothing worked. It's actually the reason a reset my phone just so I don't have to see the default Files app that appeared after removing it's updates.

So, just to be sure: 1) You've uninstalled any update of "File" app by going to Settings->Apps->All Apps->File->3 dot menu->Uninstall Updates

2) you used Solid Explorer/MiXplorer/Xplore to access android/data subfolders

3) you got no results?

unOmni commented 11 months ago

@unOmni then you can try MiXplorer, Solid Explorer, Xplore, they should be able to access android/data Edit: I must correct myself because I found the solution. Simply uninstall the updates of the default Files app. Doing so the functionality is restored even in Android 14!

I tried that before just some hours ago but nothing worked. It's actually the reason a reset my phone just so I don't have to see the default Files app that appeared after removing it's updates.

So, just to be sure:

  1. You've uninstalled any update of "File" app by going to Settings->Apps->All Apps->File->3 dot menu->Uninstall Updates
  2. you used Solid Explorer/MiXplorer/Xplore to access android/data subfolders
  3. you got no results?
  1. Yes
  2. I have just installed and started using Mixplorer, and it's working.
Manu99it commented 11 months ago
  1. Yes
  2. I have just installed and started using Mixplorer, and it's working.

Perfect! Unfortunately the Material Files dev hasn't implemented the workaround so you need to keep using MiXplorer. In case you want a more pleasant theme for MiXplorer I suggest you this: https://github.com/DerTyp7214/MixplorerThemeCreator

Or this one: https://github.com/jamal2362/MiX-Monet-Generator

unOmni commented 11 months ago
  1. Yes
  2. I have just installed and started using Mixplorer, and it's working.

Perfect! Unfortunately the Material Files dev hasn't implemented the workaround so you need to keep using MiXplorer. In case you want a more pleasant theme for MiXplorer I suggest you this: https://github.com/DerTyp7214/MixplorerThemeCreator

Or this one: https://github.com/jamal2362/MiX-Monet-Generator

Alright. I'll stick with MX for now.

td-gamer-alt commented 4 months ago

If the material files Devs listening right now then I have a way to do this Using Shizuki the root replacement

7heMech commented 3 months ago

Zarchiver also let's you use shizuku root mode would that be possible here?

fvydjt commented 2 months ago

I have discovered an another method to view files and subfolders under Android/data directly within the MaterialFiles app. Here are the steps:

  1. Download MT Manager, which can access Android/data through various methods, such as Shizuku authorization.

  2. Start a local FTP server, a free and built-in function within MT Manager.

  3. Add this FTP server to MaterialFiles, and you can then view Android/data within MaterialFiles.


P.S.

I've noticed that some people, like @DerGoogler, aren't fans of MT Manager, possibly due to its reputation.

I don't particularly like MT Manager either, but it's the easiest way to achieve this.

As an alternative, you can use other apps that can access Android/data and start a local server simultaneously, such as Termux. The server must support at least one of the following protocols: FTP, SFTP, or WebDAV.

Other less recommended but possible solutions include running MT Manager in a virtual machine like VMOS or using a cracked version of MT Manager (Telegram: @SlxshMods, @Modder_Hub, @Unpack_Dex).

DerGoogler commented 2 months ago
  1. MT Manager

Biggest red-flag

majiancy commented 1 week ago

TCL的SmartTV里连DocumentsUI都没有,怎么搞?现在Material Files只能看到系统目录,无法增加外部存储;adb shell可以看到/sdcard ,但无法cp任何文件,也无法chmod。