I need to use this for a Samsung Tablet.
Usually if the device is switched-off and the USB cable is being connected the display will wake up for some seconds showing
That's going to be a function of firmware at a very low level which, if the device is shut down, runs without any part of Android present.
On my S4 mini GT-i9291 the procedure listed above by Thorsten worked only with one modification: add the "su".
#!/system/bin/sh
su
mount -o remount,rw /system
/system/bin/lpm.orig &
while [ true ]; do
sleep 1
ps | grep lpm.orig && sleep 3 && /system/bin/reboot
chown root.shell /system/bin/lpm
done
Tks!!!!!
These answers led me to my solution. I'm using this on a Samsung Galaxy Tab S. For other tablets, the path to the system mount will be different. To find it, use this command in an adb shell.
cat /proc/mounts | grep system
One problem I came across was the tablet booting into recovery mode after I changed the lpm file, but that's because I mv'd the old one and created a new lpm file and didn't set the correct permissions and ownership. Using cp instead fixed this. My one-liner to set this up on a tablet is:
mount -o remount,rw /dev/block/platform/dw_mmc.0/by-name/SYSTEM /system && cp /system/bin/lpm /system/bin/lpm_orig && echo "#!/system/bin/sh\n/system/bin/reboot" > /system/bin/lpm
A member on XDA has posted a solution for this which seems to work on some Samsung devices.
The idea is to replace the script for the battery icon (which will appear of course as soon as the device is plugged in) with a custom script that will boot the phone. To make this work locate /system/bin/playlpm
. Rename the old playlpm
to playlpm.bak
and replace it with the following script:
#!/system/bin/sh
/system/bin/reboot
For more information read the thread on XDA
The change you'll need to make is in the bootloader.
That's the first thing that's started up, which comes long before the C environment gets initialized, or the kernel gets loaded, or even anything from the user space or from Android...
Bootloaders can vary significantly depending on the hardware they were written for, but there is little that's secret about them and you should be able to find the information you're looking for -- now that you know which keywords to use.
I have a rooted Samsung S4 mini. The following steps worked for me:
mount -o remount,rw /system
mv /system/bin/lpm /system/bin/lpm.orig
create /system/bin/lpm
as follows:
#!/system/bin/sh
/system/bin/lpm.orig &
while [ true ]; do
sleep 1
ps | grep lpm.orig && sleep 3 && /system/bin/reboot
done
chown root.shell /system/bin/lpm