Is it possible to automatically power on the device once the charger is connected given that the device is initially turned off?
The battery charging graphic is displayed by
/system/bin/playlpm file on Samsung devices.
If you are root, you can edit this file to:
And be sure to add those permissions to the file:
chmod 0755 /system/bin/playlpm chown root.shell /system/bin/playlpm
Your device will now boot when plugged
fastboot oem off-mode-charge 0 is the genuine method if your device supports. It's Google's recommended method but not all OEMs/vendors implement the command in bootloader. Or on some devices it's reset on next reboot. If
off-mode-charge is disabled, bootloader won't pass
androidboot.mode=charger commandline parameter to kernel when charger is inserted, so device boots normally.
ro.bootmode property is set to
charger on boot,
init doesn't continue the normal boot process. Instead limited number of services are started and charging animation is displayed. So you can instruct
init to reboot the device whenever charger mode is detected. Create a new
.rc file or edit any existing one:
# /system/etc/init/off_mode_charge.rc on charger setprop sys.powerctl reboot,leaving-off-mode-charging
on charger exec - -- /system/bin/reboot leaving-off-mode-charging
But if SELinux is enforcing, stock policy may not let
/system/bin/reboot. So use Magisk's context (or whatever rooting solution you use):
on charger exec u:r:magisk:s0 -- /system/bin/reboot
Don't forget to set permissions on
*.rc file (
It's also possible to continue boot process instead of restarting the device by replacing
class_start charger with
trigger late-init in
on charger #class_start charger trigger late-init
Or by setting property
on charger setprop sys.boot_from_charger_mode 1
- This method should work on all devices irrespective of OEM as it doesn't depend on vendor-specific charging binaries like
kpoc_chargerand so on.
- Also replacing binaries of important services like
healthd- which take care of a lot of things related to battery, storage etc. - is not a good idea. In this case if the service runs both in
normalmode, device may get into bootloop.
- On non-System-as-Root devices it's not necessary to modify
/systempartition (e.g. if you don't want to break
dm-verityfor OTA updates to work). Simply unpack
- Though unnecessary, it's also possible to execute an
.rcfile. For reference see How to run an executable on boot? and How to power off when charger is removed?.
fastboot oem off-mode-charge 0
Otherwise, you can either hijack the charging binary (not guaranteed to be possible on all devices, but just requires root) or patch your ramdisk (theoretically universal, but will require an unlocked bootloader).
- Most(?) AOSP-based roms:
Once found, you can just replace it with a script such as that above by IET_DEMO.
Touching the kernel is instead something I don't feel like explaining and recommending if you don't know what you are doing.
Just for the records then, I'd just like to underline that offline charging exists because the boot process is fairly energy intensive, and especially on older phones without even fast charging the power draw from the system could be higher than that on the plug.
For some older Samsung devices, this can be accomplished through NoMoarPowah!:
NoMoarPowah! can automatically reboot into Android when charging is done. Either when fully charged, or when the battery level reaches 15% and Android has enough juice to run.
You need root and you probably don't want to do it unless you really know what you're doing, since I would expect this to modify important system files.
It looks like this has been removed from the Play Store, but you can probably find the APK hosted elsewhere. (I don't have a trusted link offhand.)
If you want to do the opposite, shutdown when charge, use this: "Auto ShutDown when no charge" https://play.google.com/store/apps/details?id=com.zeroFactorial.probattle good for my car's device and also had button broken
Kernel is loaded at a later stage in the boot-up process, so any modifications to it would not have any effect for when the device is powered off.
This functionality really depends on each device's hardware, most likely in the bootloader (more knowledgeable editors feel free to correct me.) For example, my Motorola Atrix 4G phone begins booting up when I connect a charger, while my Samsung Galaxy Tab does not - it displays the "Battery Charging" graphic and requires being powered on manually.