Skip to content

Instantly share code, notes, and snippets.

@mohamad-supangat
Last active January 6, 2024 03:29
Show Gist options
  • Save mohamad-supangat/b7723a720b17dbec61b7a6e5b7fa4770 to your computer and use it in GitHub Desktop.
Save mohamad-supangat/b7723a720b17dbec61b7a6e5b7fa4770 to your computer and use it in GitHub Desktop.
Auto start boot in charging conencted

lineage os 14.1

init.rc

on charger
  class_start charger
  class_stop charger
  trigger late-init

some android phone

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

On I9500 runing linage OS 16 modify the init.rc

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

with code /ramdisk/sbin/charger

  1. Extracted Boot image through TWRP (Backup> select boot > swiped to Backup)
  2. Rename boot.emmc.win to boot.img
  3. Copy boot.img to the root dir of the program Android.Image.Kitchen, and run "unpackimg.bat"
  4. Open up folder /ramdisk/sbin/ and rename "charger" to "charger_orig"
  5. Create "charger" and put in

Code:

#!/system/bin/sh
#Skip offline charge and start device if enough juice on battery. If low on battery do offline charge
CAPACITY=$(cat /sys/class/power_supply/battery/capacity)
MIN_CAPACITY=5
if [ $CAPACITY -gt $MIN_CAPACITY ]
  then
    sleep 1
    /system/bin/reboot
fi
/sbin/charger_orig
  1. Go back to the root of Android.Image.Kitchen and run "repackimg.bat"
  2. Take "image-new.img" and copy to phone
  3. Install img with TWRP (install>install image> select above "image-new.img" >select boot > swiped to install)
@mohamad-supangat
Copy link
Author

#!/system/bin/sh
#Skip offline charge and start device if enough juice on battery. If low on battery do offline charge
CAPACITY=$(cat /sys/class/power_supply/battery/capacity)
MIN_CAPACITY=5
if [ $CAPACITY -gt $MIN_CAPACITY ]
  then
    sleep 1
    /sbin/reboot
fi
/sbin/charger_orig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment