[ G U I D E ] [ Magisk ] Auto booting android when charger connected

This tutorial has the potential to cause your phone to bootloop. Please ensure you have backed up your original boot.img before proceeding.

1. A rooted Android device with Magisk installed.
2. A good understanding of the steps involved.

Step 1: Prepare the file for injection into boot.img

Create a file named init.custom.rc in your working directory. For example: /sdcard/autoboot/files/init.custom.rc .

on charger
 setprop ro.bootmode "normal"
 setprop sys.powerctl "reboot"

Step 2: Locate and extract your boot.img

There are various methods to do this, including ADB, Fastboot, or TWRP. You can click here about this. As an example, you can use the following command:

dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/autoboot/boot.img

Execute this command in a recovery terminal or through ADB shell.

Step 3: Prepare to inject the custom init.rc

We need to unpack the boot.img, add init.custom.rc to it, and then repack it as a new boot.img.

Go to your working directory:

cd /sdcard/autoboot

Execute the following commands:

/data/adb/magisk/magiskboot unpack boot.img
/data/adb/magisk/magiskboot cpio ramdisk.cpio \
"mkdir 0700 overlay.d" \
"add 0700 overlay.d/init.custom.rc files/init.custom.rc"
/data/adb/magisk/magiskboot repack boot.img boot_patched_autoboot.img
/data/adb/magisk/magiskboot cleanup

Step 4: Flash the patched boot.img

You can flash the modified boot image using a shell, Fastboot, or TWRP. As an example, you can use the following command:

dd if=boot_patched_autoboot.img of=/dev/block/bootdevice/by-name/boot

Now, power off your phone, connect the USB charger, and wait, your phone will boot automatic

If you have any questions, please feel free to comment below.

source : https://xdaforums.com/t/g-u-i-d-e-magisk-auto-booting-android-when-charger-connected.4629561/#google_vignette

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights