phhusson / treble_experimentations

Notes about tinkering with Android Project Treble
3.37k stars 657 forks source link

cant access adb root #2645

Open dzwdev opened 1 month ago

dzwdev commented 1 month ago

Current Behavior:

i have Huawei P10 VTR-L09 with EMUI 9.1 i have installed: SuperiorOS_A13-arm64-bgS-slim_20240401.img android 13 this gsi have superuser like described here: Touchscreen Issue i need to access adb shell as root so as to stop aptouch when i try: adb root i get: adbd cannot run as root in production builds

i tried: adb insecure apk i get: could not patch adbd i flashed magisk from recovery but it is not working, if it was working: there is a module to fix that.

what to do to fix this?

1q23lyc45 commented 1 month ago

The "bgS" or "bgZ" version comes with SuperSU, which has limitations. Please try "bvN" or "bgN" and use Magisk to obtain the root.

Additionally, the GSI system you are currently using may have bugs. I suggest using AOSP GSI from this repository, LineageOS GSI, PixelExperience GSI, or other "userdebug" GSIs. Here is a Pixel Experience GSI that I personally tested, which can be used with 'adb root ': https://github.com/ponces/treble_build_pe/releases/tag/v313

dzwdev commented 1 month ago

what is a userdebug GSI?

1q23lyc45 commented 1 month ago

what is a userdebug GSI?

GSI compiled from source code (such as LineageOS GSI) is usually userdebug GSI, but GSI ported using erfan GSI tool (such as HarmonyOS GSI) is generally not userdebug GSI, but user GSI. Only userdebug GSI supports the adb root feature.

(However, your one is a special case. I remember I once flashed the SuperiorOS Android 11 BVN GSI, which is userdebug GSI and can also be used with adb root, but I lost that image. I suggest using bvN GSI instead of bgN, bgS, or bgZ. If GMS is needed, you can consider using Pixel Experience GSI. The link I provided shows that this GSI is bvN but includes the fully GMS component. Alternatively, you can install GMS by separately flashing a Magisk module.)

adb shell "cat /system/build.prop |grep build.type"

ro.system.build.type=userdebug
ro.build.type=userdebug

The two lines returned are userdebug GSI.

If running adb root results in adbd cannot run as root in production builds, then it must be user GSI.

dzwdev commented 4 weeks ago

what is a userdebug GSI?

GSI compiled from source code (such as LineageOS GSI) is usually userdebug GSI, but GSI ported using erfan GSI tool (such as HarmonyOS GSI) is generally not userdebug GSI, but user GSI. Only userdebug GSI supports the adb root feature.

(However, your one is a special case. I remember I once flashed the SuperiorOS Android 11 BVN GSI, which is userdebug GSI and can also be used with adb root, but I lost that image. I suggest using bvN GSI instead of bgN, bgS, or bgZ. If GMS is needed, you can consider using Pixel Experience GSI. The link I provided shows that this GSI is bvN but includes the fully GMS component. Alternatively, you can install GMS by separately flashing a Magisk module.)

adb shell "cat /system/build.prop |grep build.type"

ro.system.build.type=userdebug
ro.build.type=userdebug

The two lines returned are userdebug GSI.

If running adb root results in adbd cannot run as root in production builds, then it must be user GSI.

i tried this version: PixelOS_treble_arm64_bN_slim-14.0-20240724 but it goes into bootloop. and almost versions i tested i get bootloop with them.

1q23lyc45 commented 4 weeks ago

i tried this version: PixelOS_treble_arm64_bN_slim-14.0-20240724 but it goes into bootloop. and almost versions i tested i get bootloop with them.

Updating GSI requires formatting the data partition, otherwise it may not boot up and you may have forgotten. I often make this mistake. If it still can't turn on, you can first flash a GSI to rescue brick. Additionally, Pixel Experience is not PixelOS, and these two systems are not the same. https://github.com/ponces/treble_build_pe/releases/download/v313/PixelExperience_arm64-ab-vndklite-11.0-20211009-UNOFFICIAL.img.xz This Android 11 GSI (Pixel Experience) is the GSI I I am currently using, you can use it to rescue brick. Pay attention to formatting the data after flashing, don't forget, otherwise it won't start. Please do not use Android 14, your underlying is not compatible. The bottom layer of EMUI9 only supports Android 13 at the highest level. I tried to flash your GSI on Vivo Y52s (Android 10) and Redmi 5 (Android 9), but it got stuck on the second screen either. I guess this GSI itself is not very good.

You can read this article about flashing GSI on Huawei phones. Please note that this is in Chinese, so please bring your own translator.

dzwdev commented 4 weeks ago

i tried this version: PixelOS_treble_arm64_bN_slim-14.0-20240724 but it goes into bootloop. and almost versions i tested i get bootloop with them.

Updating GSI requires formatting the data partition, otherwise it may not boot up and you may have forgotten. I often make this mistake. If it still can't turn on, you can first flash a GSI to rescue brick. Additionally, Pixel Experience is not PixelOS, and these two systems are not the same. https://github.com/ponces/treble_build_pe/releases/download/v313/PixelExperience_arm64-ab-vndklite-11.0-20211009-UNOFFICIAL.img.xz This Android 11 GSI (Pixel Experience) is the GSI I I am currently using, you can use it to rescue brick. Pay attention to formatting the data after flashing, don't forget, otherwise it won't start. Please do not use Android 14, your underlying is not compatible. The bottom layer of EMUI9 only supports Android 13 at the highest level. I tried to flash your GSI on Vivo Y52s (Android 10) and Redmi 5 (Android 9), but it got stuck on the second screen either. I guess this GSI itself is not very good.

You can read this article about flashing GSI on Huawei phones. Please note that this is in Chinese, so please bring your own translator.

thank you very much, i really appreciate your help. almost gsi i have tested are android 14. and i always make a data reset via the stock recovery. so i will try another android 13 gsi. https://github-wiki-see.page/m/phhusson/treble_experimentations/wiki/Generic-System-Image-%28GSI%29-list i will try: pixel experience plus so.

dzwdev commented 4 weeks ago

and for the TWRP recovery: i did not find a 3.2.0 twrp for p10 so i used honor9 twrp but i find some problems with it so i tried: mate9 twrp but when i try to flash system gsi from it it cant flash to system and it gives me option to flash to system image partition. so i'm confused about that.

1q23lyc45 commented 4 weeks ago

and for the TWRP recovery: i did not find a 3.2.0 twrp for p10 so i used honor9 twrp but i find some problems with it so i tried: mate9 twrp but when i try to flash system gsi from it it cant flash to system and it gives me option to flash to system image partition. so i'm confused about that.

You can just flash directly to the system image partition, that's how I did it. Please backup your user data. Actually, as long as you can access TWRP, you can use any version of TWRP. However, it is recommended to use TWRP that is compatible with your own model for fewer bugs. https://www.123pan.com/s/tMz8Vv-ujdsh.html There is TWRP for your model in this link, using "华为 P10 EMUI9" should suffice.

dzwdev commented 4 weeks ago

and for the TWRP recovery: i did not find a 3.2.0 twrp for p10 so i used honor9 twrp but i find some problems with it so i tried: mate9 twrp but when i try to flash system gsi from it it cant flash to system and it gives me option to flash to system image partition. so i'm confused about that.

You can just flash directly to the system image partition, that's how I did it. Please backup your user data. Actually, as long as you can access TWRP, you can use any version of TWRP. However, it is recommended to use TWRP that is compatible with your own model for fewer bugs. https://www.123pan.com/s/tMz8Vv-ujdsh.html There is TWRP for your model in this link, using "华为 P10 EMUI9" should suffice.

thank you. i will give it a try and what about booting directly to recovery partition to get magisk root? to avoid clicking on specefic keys if i need to restart or to power on the phone?

dzwdev commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines.

edit: after restarting the recovery it is in english

another problen with it: i cant push a file from adb like in other twrps it always gives error

1q23lyc45 commented 4 weeks ago

Try this https://www.123pan.com/s/tMz8Vv-G0Esh.html but make sure to back up the 'kernel' partition first. After decompression, simply flash the img to the kernel partition and boot the phone normally. Install the apk in the zip file after startup.

dzwdev commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines

Try "重启" to recovery and try again. If it still doesn't work, just flash back to the TWRP you used before. I am a Chinese, so this TWRP was also found on the CSDN forum in China.There may be an English bug, but I can't do anything about it.

since the data is encrypted: i cant access it via usb while in twrp usually i send files via: adb push file tmp then i flash the file from tmp or data folder now i get: 08-21 04:17:52.804 169080 169080 E adb : usb_libusb.cpp:571 failed to open device: Access denied (insufficient permissions) when i try adb push

1q23lyc45 commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines

Try "重启" to recovery and try again. If it still doesn't work, just flash back to the TWRP you used before. I am a Chinese, so this TWRP was also found on the CSDN forum in China.There may be an English bug, but I can't do anything about it.

since the data is encrypted: i cant access it via usb while in twrp usually i send files via: adb push file tmp then i flash the file from tmp or data folder now i get: 08-21 04:17:52.804 169080 169080 E adb : usb_libusb.cpp:571 failed to open device: Access denied (insufficient permissions) when i try adb push

I'm sorry, but my habit is to decrypt the data partition directly after flashing the device. I haven't seen any bugs caused by encryption. And I have a habit of adb push xxx /sdcard. I really don't know how to do it. Flash back to the TWRP you used before, or disable data forced encryption, or adb shell setenforce 0

dzwdev commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines

Try "重启" to recovery and try again. If it still doesn't work, just flash back to the TWRP you used before. I am a Chinese, so this TWRP was also found on the CSDN forum in China.There may be an English bug, but I can't do anything about it.

since the data is encrypted: i cant access it via usb while in twrp usually i send files via: adb push file tmp then i flash the file from tmp or data folder now i get: 08-21 04:17:52.804 169080 169080 E adb : usb_libusb.cpp:571 failed to open device: Access denied (insufficient permissions) when i try adb push

I'm sorry, but my habit is to decrypt the data partition directly after flashing the device. I haven't seen any bugs caused by encryption. And I have a habit of adb push xxx /sdcard. I really don't know how to do it. Flash back to the TWRP you used before, or disable data forced encryption, or adb shell setenforce 0

till now i couldnt find a working way to decrypt the data, i'm in EMUI 9.1 the english documentation of this phone seems to be poor comparing to chines one

1q23lyc45 commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines

Try "重启" to recovery and try again. If it still doesn't work, just flash back to the TWRP you used before. I am a Chinese, so this TWRP was also found on the CSDN forum in China.There may be an English bug, but I can't do anything about it.

since the data is encrypted: i cant access it via usb while in twrp usually i send files via: adb push file tmp then i flash the file from tmp or data folder now i get: 08-21 04:17:52.804 169080 169080 E adb : usb_libusb.cpp:571 failed to open device: Access denied (insufficient permissions) when i try adb push

I'm sorry, but my habit is to decrypt the data partition directly after flashing the device. I haven't seen any bugs caused by encryption. And I have a habit of adb push xxx /sdcard. I really don't know how to do it. Flash back to the TWRP you used before, or disable data forced encryption, or adb shell setenforce 0

till now i couldnt find a working way to decrypt the data, i'm in EMUI 9.1 the english documentation of this phone seems to be poor comparing to chines one

The process of removing encryption is quite complicated. If you can flash back the old TWRP, you can flash back the old one. However, the issue with ADB connection on your end is due to computer permissions. Resolve according to this article (translate it yourself): https://blog.csdn.net/u010164190/article/details/140956117

dzwdev commented 4 weeks ago

"华为 P10 EMUI9" the english option inside that twrp seems not working. i changed it but still in chines

Try "重启" to recovery and try again. If it still doesn't work, just flash back to the TWRP you used before. I am a Chinese, so this TWRP was also found on the CSDN forum in China.There may be an English bug, but I can't do anything about it.

since the data is encrypted: i cant access it via usb while in twrp usually i send files via: adb push file tmp then i flash the file from tmp or data folder now i get: 08-21 04:17:52.804 169080 169080 E adb : usb_libusb.cpp:571 failed to open device: Access denied (insufficient permissions) when i try adb push

I'm sorry, but my habit is to decrypt the data partition directly after flashing the device. I haven't seen any bugs caused by encryption. And I have a habit of adb push xxx /sdcard. I really don't know how to do it. Flash back to the TWRP you used before, or disable data forced encryption, or adb shell setenforce 0

till now i couldnt find a working way to decrypt the data, i'm in EMUI 9.1 the english documentation of this phone seems to be poor comparing to chines one

The process of removing encryption is quite complicated. If you can flash back the old TWRP, you can flash back the old one. However, the issue with ADB connection on your end is due to computer permissions. Resolve according to this article (translate it yourself): https://blog.csdn.net/u010164190/article/details/140956117

thank you. i will give it a try. (that website requires login to read the full text and it accepts few countried in phone registration and alternative registration is closed)

1q23lyc45 commented 4 weeks ago

Let me help you translate it. I don't know if this method is effective.

# lsusb
Bus 001 Device 015: ID 1234:5678 Intel Corp xxx

Here, 1234 and 5678 may not necessarily be the VID and PID of your phone. Please find the corresponding device for your phone, such as one with "Huawei", "P10", "VTR-L09", or "Android", which should be your phone, and then record the VID and PID.

# sudo vim /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678", MODE="0666"

Add as above. Replace 1234 and 5678 with VID and PID for your phone. Then, unplug and replug the device. If it still doesn't work, restart the computer, or try using ADB on Windows.

dzwdev commented 4 weeks ago

Let me help you translate it. I don't know if this method is effective.

# lsusb
Bus 001 Device 015: ID 1234:5678 Intel Corp xxx

Here, 1234 and 5678 may not necessarily be the VID and PID of your phone. Please find the corresponding device for your phone, such as one with "Huawei", "P10", "VTR-L09", or "Android", which should be your phone, and then record the VID and PID.

# sudo vim /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678", MODE="0666"

Add as above. Replace 1234 and 5678 with VID and PID for your phone. Then, unplug and replug the device. If it still doesn't work, restart the computer, or try using ADB on Windows.

worked 10/10 thank you very much

dzwdev commented 4 weeks ago

flashed PE-Plus_A13-RO-arm64-bgN-slim_20240629.img successfully from that new twrp and booted successfully

dzwdev commented 4 weeks ago

i go to twrp:

edit: even the fatboot is not working, when i try to boot into it via volum down+power it takes me to twrp (erecovery)

i think the phone is bricked because of huawei bootloader failed to verify the patched magisk partition? i think i had to regenerate a new one and dont flash the old one, is this right? is there any solution from twrp since i can boot in it?

1q23lyc45 commented 4 weeks ago

If it can enter TWRP, it will not become a real brick and can be saved. First, flash back the backup kernel and recovery_ramdisk partition. Then try to boot. You may have reversed the recovery and recovery_ramdisk partitions. If it still doesn't boot, please try unlocking BL again with PotatoNV, make sure to check Anti Relock (Disable FBLOCK), and then turn on the device again. Finally, if it still doesn't boot, try entering Fastboot through TWRP and see if it's possible. If it's possible, flash the backed up kernel and recovery_ramdisk again, and you should be able to boot. It is suspected that the KernelSU kernel is incompatible with your phone. Please use Magisk, but do not use the official version or Alpha version for patching, please use Kitsune Mask, Otherwise, it cannot be boot.

dzwdev commented 4 weeks ago

when i choose to reboot to bootloader from twrp: it takes me to twrp again and if i try the same thing while holding the volume down button and usb in pc it takes me to fastboot: all is unlocked i tried from fastboot to flash STOCK: RECOVERY_VBMETA.img RECOVERY_RAMDISK.img RECOVERY_VENDOR.img KERNEL and VENDOR.img from twrp but i'm in the same situation: cant boot the system and cant enter to stock recovery neither from twrp not with keys. i think i dont need to reflash the bootloader with potatoNV. but i'm confused and dont know how to fix this

dzwdev commented 3 weeks ago

i keep trying several times flashing and rebooting to recovery and finally it booted normally, i wiped the data and the system is now booting again. i'm not sure if the problem occurs because of the kernel flahing or the modified magisk recovery_ramdisk? because i flashed theme both before the problem starts.

dzwdev commented 3 weeks ago

Please use Magisk, but do not use the official version or Alpha version for patching, please use Kitsune Mask, Otherwise, it cannot be boot.

why do you think that using Kitsune Magisk is better?

dzwdev commented 3 weeks ago

i tried with the original magisk and it worked. i used this module: Android12_GSI_Fix_For_Huawei_P10.zip to fix the touchscreen and it worked. one problem now is that i need every time to hold keys to boot with magisk enabled.

1q23lyc45 commented 3 weeks ago

Please use Magisk, but do not use the official version or Alpha version for patching, please use Kitsune Mask, Otherwise, it cannot be boot.

why do you think that using Kitsune Magisk is better?

I use the Kitsune Mask because some phones with the original Magisk 25 version or above will freeze the first screen and cannot enter the system. After a period of time, they will automatically restart to TWRP. For example, my Redmi 5 and my Vivo Y52s are like this, but Kitsune Mask doesn't have this issue.

In addition, Kitsune Mask has a special feature: "Magisk Hide" and "SuList", which can hide root permissions for specified apps or only allow specified apps to detect root permissions.

Do not use Magisk and KernelSU simultaneously as they may conflict.

one problem now is that i need every time to hold keys to boot with magisk enabled.

Additionally, there is no solution, because it is a Huawei system limitation.

1q23lyc45 commented 3 weeks ago

This is a possible, but unverified solution. Please note that it is highly likely to cause the phone to become a brick so it is important to backup it first. First, backup the 'ramdisk' partition.

~1.Backup ramdisk.img and push it to the phone /sdcard directory~ ~2. Download and install the latest version of Kitsune Mask on your mobile phone, find RAMDISK.img in Kitsune Mask and create a patch, generate Download/magisk_ctched-xxx.img and copy the file to your computer.~ ~3. adb reboot bootloader to enter fastboot~ ~4. Then execute fastboot flash ramdisk magisk_patched-xxx.img~ ~5. fastboot reboot~ ~6. You should have Magisk and root permissions directly when booting up.~

7. If the phone turns into a brick, please flash back the backed up ramdisk.img.

dzwdev commented 3 weeks ago

i may give that i try and report the result. the two gsi i tested: superioros and pixelexperience plus detect the fingerprint sensor and i can add fingers from theme, but when the screen is off and i put the finger in sensor it seems not to detect it and does not unlock the screen. is this a global gsi problem with huawei?

1q23lyc45 commented 3 weeks ago

i may give that i try and report the result. the two gsi i tested: superioros and pixelexperience plus detect the fingerprint sensor and i can add fingers from theme, but when the screen is off and i put the finger in sensor it seems not to detect it and does not unlock the screen. is this a global gsi problem with huawei?

As long as you can add a fingerprint and use it to unlock the screen when the screen lights up, there is no problem with the GSI you are currently using. I think what you mentioned may be a proprietary feature of emui. My Vivo phone, whether using the official system or GSI, does not have the feature you mentioned. However, Xiaomi phones have the feature you mentioned under MIUI, neither GSI nor third-party ROMs, but fingerprints can unlock the screen lock.

1q23lyc45 commented 3 weeks ago

Also, could you send me a copy of the Magisk module that you fixes touch? I have two phones, one is Vivo Y52s and the other is Xiaomi Redmi 5, using the same GSI. My Vivo Y52s also has a touch bug, but Redmi 5 doesn't. Thank you very much.

dzwdev commented 3 weeks ago

i may give that i try and report the result. the two gsi i tested: superioros and pixelexperience plus detect the fingerprint sensor and i can add fingers from theme, but when the screen is off and i put the finger in sensor it seems not to detect it and does not unlock the screen. is this a global gsi problem with huawei?

As long as you can add a fingerprint and use it to unlock the screen when the screen lights up, there is no problem with the GSI you are currently using. I think what you mentioned may be a proprietary feature of emui. My Vivo phone, whether using the official system or GSI, does not have the feature you mentioned. However, Xiaomi phones have the feature you mentioned under MIUI, neither GSI nor third-party ROMs, but fingerprints can unlock the screen lock.

dzwdev commented 3 weeks ago

i find this page: https://github.com/Coconutat/android_kernel_huawei_vtr_emui9_KernelSU it is a modified kernel for p10 i did not find a list of the full kernelsu features, why someone will change to this kernel? what benefits he get?

1q23lyc45 commented 3 weeks ago

i find this page: https://github.com/Coconutat/android_kernel_huawei_vtr_emui9_KernelSU it is a modified kernel for p10 i did not find a list of the full kernelsu features, why someone will change to this kernel? what benefits he get?

For KernelSU, I don't think there are any special advantages, it's just that KernelSU has a stronger effect on hiding roots than Kitsune Mask. If you don't even know Kitsune Mask, don't use KernelSU, it's useless.

One more thing to add: Kitsune Mask has MagiskHide and SUList. If some apps detect root and crash, these two functions can hide root permissions for these apps, and you can open them.