MuntashirAkon / AppManager

A full-featured package manager and viewer for Android
https://muntashirakon.github.io/AppManager/
Other
4.73k stars 265 forks source link

Can't use root mode in versions 3.x.x #948

Open Zafrkant opened 1 year ago

Zafrkant commented 1 year ago

Please check before submitting an issue

Describe the bug

I'm using Xiaomi Mi 11i, Xiaomi EU 13.0.13.0, App Manager Debug 2130. I've tried multiple 3.x.x versions but results are the same, I can't use root mode. On v2.6.5.1 everything is working fine. Full system log will be provided.

To Reproduce

Expected behavior

No root access will be provided.

Screenshots

No response

Logs

Log is provided via Mega due to it's large size, GitHub: There was an error creating your Issue: body is too long, body is too long (maximum is 65536 characters). https://mega.nz/file/e5clkSSB#hvEJ_JSzxOQnmcPzXHC5uKnEfK8VOe4n3bifOGxyZL4

Device info

Additional context

No response

MuntashirAkon commented 1 year ago
617:696 E/vold: Failed to set project id on /data/media/0/Android/data/io.github.muntashirakon.AppManager.debug/: Operation not supported on transport endpoint
30553:30553 W/ContextImpl: Failed to ensure /storage/emulated/0/Android/data/io.github.muntashirakon.AppManager.debug/cache: android.os.ServiceSpecificException:  (code -1)
30745:30745 D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
30553:30689 E/RootService: main.jar: open failed: EROFS (Read-only file system)
java.io.FileNotFoundException: main.jar: open failed: EROFS (Read-only file system)
    at libcore.io.IoBridge.open(IoBridge.java:575)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:186)
    at io.github.muntashirakon.AppManager.ipc.RootServiceManager.lambda$startRootProcess$1(RootServiceManager.java:193)
    at io.github.muntashirakon.AppManager.ipc.RootServiceManager$$ExternalSyntheticLambda3.run(Unknown Source:9)
    at io.github.muntashirakon.AppManager.ipc.RootService.lambda$asRunnable$0(RootService.java:201)
    at io.github.muntashirakon.AppManager.ipc.RootService$$ExternalSyntheticLambda0.run(Unknown Source:2)
    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:920)
Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
    at libcore.io.Linux.open(Native Method)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
    at android.app.ActivityThread$AndroidOs.open(Unknown Source:15)
    at libcore.io.IoBridge.open(IoBridge.java:561)
    ... 9 more

It is failing because the internal storage in your device is set to read-only for App Manager which shouldn't happen. Check if any of the other software is messing with App Manager, examples include Xposed or similar frameworks and Storage Redirect. Also check if the path /storage/emulated/0/Android/data/io.github.muntashirakon.AppManager.debug/ exists.

Zafrkant commented 1 year ago

Muntashir thanks for answering.

After installation '/storage/emulated/0/Android/data/io.github.muntashirakon.AppManager.debug' is present on storage, containing empty FIles subdirectory. I'm not using Xposed, only App Ops with Sui Zygisk. I've tried to disable all Magisk modules (including Sui, BusyBox, CloudFlare, Twemoji), reboot and try to select root mode but unfortunately state is the same. Do you have idea how can I check what is making storage read-only?

Thanks in advance.

MuntashirAkon commented 1 year ago

Do you have idea how can I check what is making storage read-only?

Not sure. You could do onething: Run AM Debug in no-root mode, grant file permissions. Then open the app details page of AM Debug, navigate to Activities tab, find FmActivity and open it to see if it can display anything.

Zafrkant commented 1 year ago

Thank you for answer. I've did as you suggested and on click it is opening file manager on /storage/emulated/0 path. signal-2022-12-05-135343

unRekable commented 1 year ago

I have the same issue. I'm also using a Xiaomi device (Mi 11 Ultra). The error I have is the same: open failed erofs (read-only file system)

As path, I'm having the same as @Zafrkant when opening FmActivity. Btw. I disabled lsposed which didn't help. Besides that I only have Magisk installed and nothing that should block AM.

unRekable commented 1 year ago

By the way, in case it matters, when opening FmActivity, I don't have permissions to view /android/data - probably that's causing the problem?

unRekable commented 1 year ago

I've updated to Android 13 and MIUI 14 today - still the same issue. Any update on this @MuntashirAkon ?

Zafrkant commented 1 year ago

I've upgraded Xiaomi EU to v14.0.3.0, App Manager to v3.0.4 and it is working fine now.

unRekable commented 1 year ago

Hope it keeps working for you. Still doesn't work for me on MIUI 14 and Android 13. I will install the latest weekly and see. On Miui 13 and Android 12 one time it showed me root mode and asked me to select a storage for backups or something, don't entirely remember. Though, I think I disallowed root in first, restarted and allowed it then. Whatever, it just showed me the root mode for a short time, when swichting modes it didn't work anymore.

MuntashirAkon commented 1 year ago

Any update on this @MuntashirAkon ?

Sorry, no updates. If you're willing to help, I will publish some debug builds to figure out the issue first.

unRekable commented 1 year ago

Any update on this @MuntashirAkon ?

Sorry, no updates. If you're willing to help, I will publish some debug builds to figure out the issue first.

Sure, would appreciate to help figuring this out.

unRekable commented 1 year ago

Here's the log file/export - in case it helps you. Installed the latest build today.

https://file.io/0wcoXlniJ95j

unRekable commented 1 year ago

Can you build a debug build @MuntashirAkon ? Been waiting long 😄

Bladius2024 commented 1 year ago

Screenshot_20230224-064416_Solid Explorer

MuntashirAkon commented 1 year ago

Try 35d8c3b0aa0b8604a604fc39730c436a256dbd53

Bladius2024 commented 1 year ago

I don't understand what to check. There is nothing to download from the link provided

unRekable commented 1 year ago

I don't understand what to check. There is nothing to download from the link provided

Same. I never compiled into an apk file. If you can make a beta/test build, would be awesome @MuntashirAkon. Thanks!

MuntashirAkon commented 1 year ago

Read the docs: https://muntashirakon.github.io/AppManager/en/#subsec:binary-distribution-sources

unRekable commented 1 year ago

Downloaded the Debug Build from your telegram.

It crashes on start and cannot run. Here's the error log I could get: https://pastebin.com/FqJYKXqY

Thanks!

MuntashirAkon commented 1 year ago

Try#2: 77b1f5dd1889b3c9126dd9b69428fbad9982c28b

unRekable commented 1 year ago

Same. Re-installed. It tells me the key, then ask for root and after I give permission it crashes / closes the app.

https://pastebin.com/hxYZhyxe

MuntashirAkon commented 1 year ago

Same. Re-installed. It tells me the key, then ask for root and after I give permission it crashes / closes the app.

This is very weird. The shared storage clearly exists as per your previous comments, but App Manager is unable to use them somehow.

In a Terminal, run the following with root:

mount | grep Android/data
unRekable commented 1 year ago

![Uploading Screenshot_2023-02-28-18-59-17-564_com.termux.jpg…]()

MuntashirAkon commented 1 year ago

@unRekable: Screenshot was not uploaded properly.

unRekable commented 1 year ago

https://ibb.co/VjwwtP3

MuntashirAkon commented 1 year ago

Ah, it's a device mapper no. 33 (disk encryption?). Run the following command to check the mapping:

ls -l /dev/mapper/

Also, check if /dev/media is properly mounted:

mount | grep /dev/media

Run everything using root.

unRekable commented 1 year ago

/dev/mapper/ no such directory, hence it isn't mounted.

I think my device is encrypted yes. I always enter my pin to decrypt it in TWRP.

MuntashirAkon commented 1 year ago

/dev/mapper/ no such directory, hence it isn't mounted.

And the output of the other command?

MuntashirAkon commented 1 year ago

I think my device is encrypted yes. I always enter my pin to decrypt it in TWRP.

Use of dm-X usually means that the partitions are encrypted in this context. It's absolutely okay to /dev/mapper not containing anything as a result.

unRekable commented 1 year ago

/dev/mapper/ no such directory, hence it isn't mounted.

And the output of the other command?

The other command gave me no output It couldn't grep something

unRekable commented 1 year ago

https://ibb.co/VD43gpF

It's 1| I think (the output)

MuntashirAkon commented 1 year ago

Being relatively new in Android, I'm not particularly familiar with how storage works in Android. But /data/media should, at least, exist and I'm not sure why this isn't the case for you Android 13. Maybe @mirfatif can help regarding this.

unRekable commented 1 year ago

/data/media folder exists. Just /dev/media and /dev/mapper doesn't exist

unRekable commented 1 year ago

"mount | grep /data/media" also returns me 1|

mirfatif commented 1 year ago

@MuntashirAkon the provided info doesn't seem to be very helpful.

E/vold: Failed to set project id on ... seems to be an issue at the kernel / filesystem level. vold sets this to manage quotas.

A fresh install or clearing the app storage was tried?

W/ContextImpl: Failed to ensure ... indicates that you are using getExternalCacheDir() to open the file in the cache directory when E/RootService: main.jar: open failed: EROFS (Read-only file system) is thrown? Is it required to use the external cache directory? Did you try to use the files directory? Or maybe as a fallback use SAF to create a new directory in the root of the external storage?

But apparently the problem doesn't seem specifically with your app but the operating system b/c the standard APIs are broken. Or a framework mod is making them break.

MuntashirAkon commented 1 year ago

But apparently the problem doesn't seem specifically with your app but the operating system b/c the standard APIs are broken. Or a framework mod is making them break.

My thoughts exactly. /storage/emulated/0 exists and is readable yet being unable to write in the app's own cache directory seems highly unusual.

MuntashirAkon commented 1 year ago

I didn't pay much attention to the vold error which is emitted from here: https://cs.android.com/android/platform/superproject/+/master:system/vold/Utils.cpp;l=245;drc=b0f997deae8edd0a3f7e3ebfc8da5b62bbea10c1

But it seems it could be an issue with the ROM itself as per this comment: https://github.com/remote-android/redroid-doc/issues/42#issuecomment-1211496773

MuntashirAkon commented 1 year ago

ContextImpl#ensureExternalDirsExistOrFilter() initiates the call to the above-mentioned method in vold (via StorageManager or IMountService depending on Android version) which is failing. It has this interesting comment before the line that was failing:

Failing to mkdir() may be okay, since we might not have enough permissions; ask vold to create on our behalf.

MuntashirAkon commented 1 year ago

All issues seem to be coming from Xioami phones with A12 and 13 (Yet another Motorola-like situation (#880)?)

mirfatif commented 1 year ago

Xiaomi has a history of interesting bugs.

Bladius2024 commented 1 year ago

On RC1 app with root, crash on start

MuntashirAkon commented 1 year ago

On RC1 app with root, crash on start

This is expected. It's incredibly difficult for me to support a potentially broken ROM.

Bladius2024 commented 1 year ago

the ROM is not corrupted. Since the problem is on the original Xiaomi ROM and Xiapmi.eu as well as on the ArrowOS 13 ROM, it is not a rom issue.

MuntashirAkon commented 1 year ago

the ROM is not corrupted. Since the problem is on the original Xiaomi ROM and Xiapmi.eu as well as on the ArrowOS 13 ROM, it is not a rom issue.

Read the discussions above. vold (part of Android system) being unable to assign a project ID (permissions) for App Manager's cache directory (which, presumably, occurred due to /data/media/0 being non-existent) is clearly a sign of broken system. This isn't necessarily the ROM itself though, since we have plenty of MIUI 13 and 14 users who are using App Manager without any issues. This is likely something else. We did find a few interesting issues in the past. For example, Lineage OS 17.1 users were unable to uninstall App Manager from their device as the action itself was causing the Android installer to crash. We initially thought this to be an issue with LOS itself but later only to find out that it was an issue with external SD Card and a certain OpenGapps version. Some Samsung users still cannot uninstall App Manager because One UI's installer crashes when you click uninstall. But in this case, One UI itself is to be blamed.

Bladius2024 commented 1 year ago

puzzling. Is it possible that the Permissions system app that is reinstalled by default could be buggy in a particular version? MIUI 13 is only for Android 12 and MIUI 14 is for both Android 12 and Android 13. On MIUI 14 with A12 AppManager works for me, but does it also work on MIUI 14 with Android 13?

MuntashirAkon commented 1 year ago

does it also work on MIUI 14 with Android 13?

It does, yes.

unRekable commented 1 year ago

puzzling. Is it possible that the Permissions system app that is reinstalled by default could be buggy in a particular version? MIUI 13 is only for Android 12 and MIUI 14 is for both Android 12 and Android 13. On MIUI 14 with A12 AppManager works for me, but does it also work on MIUI 14 with Android 13?

Here it doesn't on A13 with MIUI 14 (Xiaomi.EU weekly version). I also have no idea what's causing it but my first guess was it cannot access the /android/media folder. Atleast it is empty when opening it with FmActivity.

I also don't use much on my phone, basically Magisk alpha (zygisk), AccA (for battery management), LSPosed (zygisk), Systemless Hosts from Magisk, and some stuff I installed (after the App Manager).

MuntashirAkon commented 1 year ago

I also have no idea what's causing it but my first guess was it cannot access the /android/media folder. Atleast it is empty when opening it with FmActivity.

It's the /data/media folder, accessible only via root for non-system users. This folder contains the shared storages, SD Card, etc. from all users so that the system can access all of the available storages without worrying about any potential privacy leaks. MIUI 14 has already received February updates in many devices, I think. If updating to the latest version does not work for you, you should consider disabling Magisk temporarily to sort out the issue (booting in safe mode, perhaps?). If it's not an issue with the ROM, then disabling Magisk should fix the issues.

Bladius2024 commented 1 year ago

Screenshot_20230308-101047_Root Browser DATA/MEDIA i have access

kryptobolt07 commented 1 year ago

puzzling. Is it possible that the Permissions system app that is reinstalled by default could be buggy in a particular version? MIUI 13 is only for Android 12 and MIUI 14 is for both Android 12 and Android 13. On MIUI 14 with A12 AppManager works for me, but does it also work on MIUI 14 with Android 13?

Here it doesn't on A13 with MIUI 14 (Xiaomi.EU weekly version). I also have no idea what's causing it but my first guess was it cannot access the /android/media folder. Atleast it is empty when opening it with FmActivity.

I also don't use much on my phone, basically Magisk alpha (zygisk), AccA (for battery management), LSPosed (zygisk), Systemless Hosts from Magisk, and some stuff I installed (after the App Manager).

This is unrelated to the issue but i would strongly would recommend you not to use any 3rd party magisk version especially magisk alpha the developer of magisk alpha has an history of trying to suggest unacceptable behaviour of magisk such as deafult crash reports being sent to the servers.