Is it possible to make such patch as a Magisk module so that no boot.img patching is required? I'm not too familiar with android modding and wondering if Magisk is loaded at all at this stage? Any help would be very appreciated.
I've read that guide multiple times (before asking the question), but I don't see my answer there. The last section about modifying rc files requires flashing ramdisk and if I understand correctly does not work with modules. So the answer is no?
I meant that I want to apply this modification with just a magisk module (zip).I didn't say there is an answer... you can figure out and tell us. btw what do you mean, Magisk is loaded [...] no boot.img patching is required? Isn't that oxymoronic?![]()
on charger
exec u:r:magisk:s0 -- /system/bin/reboot
Hello all, I've been googling and searching for 2 weeks now trying to figure out how to get my Samsung TabS6 Lite tablet to power on when plugged in. I bought it to install into a dash mounted tablet for my car, and this thread eventually got me there. I wanted to say what I did in case it would help others.
First of all, fastboot oem off-mode-charge 0 did nothing for me. I spent a lot of time trying different PCs/Cables/Drivers etc and though I never found exact confirmation, I suspect Samsung just doesn't allow this functionality in their bootloader.
First I'm using the standard rom except with Magisk having it rooted.
In Magisk I had to go into the settings and let superuser be for "Apps and ADB" and I had to reboot.
Then with ADB on my windows PC I could execute "su" in ADB Shell which let me do the rest of this.
ADB Shell commands
su
mount -o rw,remount /
(i couldn't mount the system directory, but I found a helpful tip somewhere that said mount the root and you can write to the system directory.)
cd system/etc/init
(now i have to create a text file. There's probably a lot better ways to do this, but ultimately I did it this way and could be done all through command prompt in windows, essentially we're creating a .rc file that turns off off mode charging.)
cat > off_mode_charge.rc
(this starts the creation of a text file called "off_mode_charge.rc" I don't think the name of the .rc matters just has to be in the init directory and .rc extension, the next line you'll be typing the lines of the .rc file)
# /system/etc/init/off_mode_charge.rc
(thats the first line, then press enter to do the second line)
on charger
(second line)
setprop sys.powerctl reboot,leaving-off-mode-charging
(third line, with 5 spaces, don't know if the spaces matter thats just how it was formatted when I found it on stack exchange)
Then press Control D to end the file. You should now have an .rc file called off_mode_charge.rc in your init directory and this file essentially tells the system to power on when plugged in. Apparently, all the inits are called at bootloader step. The charge animation still comes up at first, but then it will boot there after.
Finally give that file permissions (don't know if this is necessary but I did it and it worked)
chmod 0755 off_mode_charge.rc
chown root.shell off_mode_charge.rc
Finally set the root system to read only again
mount -o ro,remount /
And that along with a Tasker script to shutdown the tablet when it loses charge has it working for me. I'm just posting this as guest as I'm not a contributor here but I found a lot of this through a combination of
android.stackexchange.com/questions/20021/automatically-power-on-android-when-the-charger-is-connected/221384#221384
and the information posted here.
Hi @leahcimx , I'm here in Feb23 also trying to re-purpose a Galaxy Tab A ( SM-T295 ) into a piggyback head unit to drop onto my Volvo C70. I'm an newbie to Tasker/Autoinput and drafting a task to auto-shutdown, but I'm here looking for support to set up the device to auto-start on USB power. I've got a very rough grasp of doing adb commands on a PC but not smart enough to take it further and in need of spoonfeeding assistance to get me over the line. Can you or anyone else reading help me ???Hello all, I've been googling and searching for 2 weeks now trying to figure out how to get my Samsung TabS6 Lite tablet to power on when plugged in. I bought it to install into a dash mounted tablet for my car, and this thread eventually got me there. I wanted to say what I did in case it would help others.
First of all, fastboot oem off-mode-charge 0 did nothing for me. I spent a lot of time trying different PCs/Cables/Drivers etc and though I never found exact confirmation, I suspect Samsung just doesn't allow this functionality in their bootloader.
First I'm using the standard rom except with Magisk having it rooted.
In Magisk I had to go into the settings and let superuser be for "Apps and ADB" and I had to reboot.
Then with ADB on my windows PC I could execute "su" in ADB Shell which let me do the rest of this.
ADB Shell commands
su
mount -o rw,remount /
(i couldn't mount the system directory, but I found a helpful tip somewhere that said mount the root and you can write to the system directory.)
cd system/etc/init
(now i have to create a text file. There's probably a lot better ways to do this, but ultimately I did it this way and could be done all through command prompt in windows, essentially we're creating a .rc file that turns off off mode charging.)
cat > off_mode_charge.rc
(this starts the creation of a text file called "off_mode_charge.rc" I don't think the name of the .rc matters just has to be in the init directory and .rc extension, the next line you'll be typing the lines of the .rc file)
# /system/etc/init/off_mode_charge.rc
(thats the first line, then press enter to do the second line)
on charger
(second line)
setprop sys.powerctl reboot,leaving-off-mode-charging
(third line, with 5 spaces, don't know if the spaces matter thats just how it was formatted when I found it on stack exchange)
Then press Control D to end the file. You should now have an .rc file called off_mode_charge.rc in your init directory and this file essentially tells the system to power on when plugged in. Apparently, all the inits are called at bootloader step. The charge animation still comes up at first, but then it will boot there after.
Finally give that file permissions (don't know if this is necessary but I did it and it worked)
chmod 0755 off_mode_charge.rc
chown root.shell off_mode_charge.rc
Finally set the root system to read only again
mount -o ro,remount /
And that along with a Tasker script to shutdown the tablet when it loses charge has it working for me. I'm just posting this as guest as I'm not a contributor here but I found a lot of this through a combination of
android.stackexchange.com/questions/20021/automatically-power-on-android-when-the-charger-is-connected/221384#221384
and the information posted here.
Hi, OK status of now is I have TWRP and root & Magisk etc and believe I need to swap out a file 'lpm' in system/bin folder. I'm able navigate there using the TWRP explorer and make a copy of the file plus rename to lpm.old.
erm...that #207 post is a foreign language to me.
unpackimg.bat
I wish I knew whether I did have a magisk_patched.img or not. Understanding where to find it would be a good start.if you don't have magisk_patched.img on PC, you can create TWRP backup of boot partition and use the boot.emmc.win from TWRP/BACKUPS/
managed to sort it cheers, The only thing I couldn't work out is why it wouldn't restore with TWRP it kept saying failed under restored :-( I did however manage to restore it with fastboot and it is working great cheers, i will have 10 to do is there a way i can take a back up of my stock rom with all the apps installed and restore this or is it best to just do each separately, sorry if its not in the right post
#!/system/bin/sh
/system/bin/reboot
I think I'm in the same boat as @fritz.barnes. I've tried every combination of suggestion here but there's something weird going on.
I have a Samsung Galaxy Tab A 10.1 (2019) with unlocked bootloader, TWRP, and root (Magisk).
It appears as if anytime i replace /system/bin/lpm and put in the suggested shell scripts to trigger a reboot, it appears this isn't running at all or incurring some kind of exception.
I was initially really confused because there were other people saying that the script appeared to be working but that it was booting them into recovery/TWRP, and that appeared to be what was happening to me. But after going through so many scenarios, I think there was a reason for that.
1. When I first made the change to /system/bin/lpm after being in USB debugging and from ADB shell, when I turned the tablet off with cord unplugged, then plugged in cord, I got stuck at the initial lightning charge screen that doesn't have the real battery %, etc.
2. When this just got stuck forever and didn't reboot (regularly or into TWRP), I held POWER + VOL DOWN to reboot, then POWER + VOL UP to get back into TWRP. After getting into TWRP, mounting system, and making the similar changes to /system/bin/lpm, it "appeared" to be working in that after powering off with cord unplugged, it would start up when cord plugged in but go immediately into TWRP.
3. I realized later after trying multiple different versions of this file that all kept going into TWRP, if I rebooted regularly into system first with TWRP, then powered off with cord unplugged, then plugged cord in, I was still stuck at the initial lightning charge screen that doesn't have the real battery %, etc.
After all that, I'm assuming the initial lightning charge screen has nothing to do with /system/bin/lpm, and that this shows regardless of what /system/bin/lpm is. But compared to the original /system/bin/lpm behavior of in a few seconds showing correct battery %, my attempts at the shell script /system/bin/lpm probably just appear to be doing nothing (not rebooting) and just keeping me at the initial lightning charge screen.
As I said, I tried multiple different versions of the script throughout this thread and nothing has seemed to work. I have created the file or copied the file in different ways and also verified EOL characters, etc.
Does anyone have any idea what's going on with my situation (and possibly with @fritz.barnes having the same or similar issue that I do) or how to debug this? Is there something that has been altered with reboots by TWRP that requires any sort of Android property to be set or anything? I'm not an Android developer, but I see this in the TWRP source in terms of doing a system reboot, but I'm not fully sure what's going on here.
Code:case rb_system: Update_Intent_File("s"); sync(); check_and_run_script("/sbin/rebootsystem.sh", "reboot system"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,"); #elif defined(ANDROID_RB_RESTART) return android_reboot(ANDROID_RB_RESTART, 0, 0); #else return reboot(RB_AUTOBOOT); #endif
Thanks!
---------- Post added at 09:48 PM ---------- Previous post was at 09:21 PM ----------
Not sure if I'm normally supposed to reply to my own post here, but I have some more information that seems interesting.
If I take the original /system/bin/lpm, make a copy and then use the copy as /system/bin/lpm (and move the original to a different file, i.e. /system/bin/lpm.bak), the copied version of the original binary also seems to not work and keep me at the initial lightning charge screen. I am making sure to chmod 0755 and chown root.shell any copied files as you can see below. The original file has timestamp of 2008-12-31, and this specific file appears to be the only one that will work (and go to the normal charge indicator screen).
![]()
Not sure if this will further help diagnosis anything, but what's going on here? Why with a copy of the original lpm binary does this also result in me being stuck at the initial lightning charge screen? Any ideas?
I'd be willing to send a $50 bounty via Venmo to whoever can help me get this working.
from my own experience, if something get stuck, it means the comand in tge lpm file is wrong, you have to try different command.
i have successfully auto boot 4 different phone, S4, Mate 7, zenphone6, redmi 6a, they all need to use different command, eventhough i only changing the same file. in my case in init.rc and some by just changing kpoc file.
Sent from my Redmi Note 7 using Tapatalk
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