Sample Header Ad - 728x90

Shutdown android device after disconnect charger

1 vote
0 answers
645 views
I need shutdown android system after disconnect charger. I have android 6.0.1 (rooted), and I'm looking for to power off phone, when it's not charging. I'm looking for programming solution. I have power on phone when I start charging phone. To do it I changed init.rc file. Now I looking for which file I can change, to achive power off phone after disconneted charger. I have this code in init.rc:
on charger
    setprop ro.bootmode "normal"
    setprop sys.powerctl "reboot"
To test, I added this to function "on charge"r too: sleep 300 /system/bin/busybox poweroff -f and finally I have:
on charger
    setprop ro.bootmode "normal"
    setprop sys.powerctl "reboot"
    sleep 300
    /system/bin/busybox poweroff -f
but it didn't work. I tested:
/system/bin/setprop sys.powerctl shutdown
/system/bin/svc power shutdown
/system/bin/busybox poweroff -f
Phone never shutdown after connect charger (this was only test, I need shutdown after disconnect charger, not after connect, but why this commands didn't work?).
Asked by Krzysztof Em (31 rep)
Aug 21, 2022, 07:28 PM
Last activity: Aug 22, 2022, 08:32 PM