'how to Boot android on just power (battery) detection?

So I have this broken phone, a Redmi Note 4 with custom ROM rooted. I use this for testing my apps or sometimes as a HD webcam, it does not have a battery inside. I made a DIY hack for a charger which is directly connected to the phone instead of the battery. Its power button is not working properly. Sometimes I have to press it too hard to switch on the phone so I came up with a solution to boot.

/system/etc/init/off_mode_charge.rc

on charger

setprop sys.powerctl reboot,leaving-off-mode-charging

it used to work but now since the last few days its not booting with usb. I tried another usb too but when the phone is turned on with the power button then usb works fine.

I want to boot the phone whenever power is detected at the place of battery or any other solution is welcome help me.

Earlier it used to boot automatically and get connected to wifi and since it's rooted I used.

su

setprop service.adb.tcp.port 5555

stop adbd

start adbd

In tasker. And use Scrcpy to see the phone screen remotely or to debug app. And also the phone does not have screen.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source