Rooting Android for Turning on when Power is Detected

Another great piece of information shared by a member of our community (Rene) on how to root your tablet so that it will automatically turn on when it detects a charge from the USB connection.  This is super handy when the tablet is totally shut down (powered off or out of battery).  The steps below are performed on a Samsung Galaxy Tab A (2016) on Android version 8.1.0 (Oreo).

As usual, from Rene and Workshop 12,  we make the following disclaimer:  Neither party is responsible for any damage you may encounter when following this guide. It is your own responsibility. You can brick your device. Rene has done the changes on his own tablet with the help of the online information he could find, and these are the steps he has taken. 

1) You need a new boot loader on your tablet. I have used TWRP

The source I have used is: https://forum.xda-developers.com/galaxy-tab-a/development/recovery-official-twrp-gtaxlwifi-galaxy-t3437666

Installing TWRP

  • In your ROM, go to Settings -> About device. Tap 7 times on Build number to enable Developer options.
  • Now go to Settings -> Developer options. (above About device) You need to enable OEM unlock, otherwise you might end up with boot problems or be unable to flash later on.
  • Make sure your don’t have Factory Reset Protection enabled in your Google account or you may never be able to boot again! More information: https://support.google.com/nexus/answer/6172890?hl=en
  • Extract the latest version of ODIN to your computer.
  • Install Samsung Mobile Phone Drivers for Odin to find your device.
  • Download the latest .tar image of TWRP for gtaxlwifi.
  • Reboot your device into Download mode. To do this, select reboot from the power menu and hold the [Volume Down] + [Home] buttons while your device reboots. Once you reach the Download mode warning screen, press [Volume Up] to continue.
  • Open Odin and place that TWRP tar file in the [AP] slot, under Options tab disable Auto Reboot, then press [Start].
  • Once the flash is complete (Odin should tell you in the log, and progress bar on phone should stop), you can hold [Volume Up] + [Home] + [Power] buttons until you reach recovery mode. If you end up in stock recovery, start again from download mode step.
  • At this point, you will reach the screen asking you if you want to allow system modifications. You will want to swipe to allow, otherwise the OS will replace TWRP once you boot!

2) Install Magisk

Source: https://topjohnwu.github.io/Magisk/install.html
Another Source: https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445

Install Magisk through TWRP

  • Download the Magisk installer zip
  • Reboot to custom recovery (To do this, select reboot from the power menu and hold the [Volume Up] + [Home] buttons while your device reboots).
  • Flash the zip and reboot. Watch the video https://www.youtube.com/watch?v=1RQNJfpBMs0; he is explaining it pretty well.
  • Check whether Magisk Manager is installed on the tablet. If for some reason it isn’t installed automatically, manually install the APK; you can find it in the play store.

In my case; I had the problem that I couldn’t boot; and got the error:

Verification failed! Unable to restart your device. The integrity verification has failed. You must need to reset your device to factory default settings. This will erase all your data.

What I did was erasing the /data folder; which resets the system to factory. So I had to redo all the settings again.

3) So; now to get the “boot when my tablet is empty” part

Edit the LPM file in /system/bin/
Source: https://www.instructables.com/id/AutoBoot-Android-When-Charger-Connected/

Because the /system filesystem is read only; you first have to make it editable. I have done it on my Mac; but windows/linux/MacOS are all good.
Source: https://www.xda-developers.com/install-adb-windows-macos-linux/

In the fist steps you have already activated the developer mode (In your ROM, go to Settings -> About device. Tap 7 times on Build number to enable Developer options.)

Go into the developer options and allow USB debugging.

Go to https://www.xda-developers.com/install-adb-windows-macos-linux/ and start at Microsoft Windows ADB Setup or How to Install ADB on macOS; on these pages it is explained well.

Make /system filesystem Writable
Source: https://android.stackexchange.com/questions/110927/how-to-mount-system-rewritable-or-read-only-rw-ro

What I did was open terminal on my mac; typed

  • adb shell
  • su
  • mount -o rw,remount /system

3) Ok; this was all preparation. Now the part we wanted

Edit the LPM file
Source: https://www.instructables.com/id/AutoBoot-Android-When-Charger-Connected/

What I did on the mac:

Log into adb
First make a copy of the lpm file (just in case) cp /system/bin/lpm /system/bin/lpm_backup

  • type: vi /system/bin/lpm
  • type: :1,$d (to delete all the contents of this file; mind the 🙂
  • type i (to get into edit mode)
  • type or paste:
    #!/system/bin/sh
    su
    /system/bin/reboot
  • type: :wq!

If all did go well, the file is now saved and you are back in the adb prompt. You can now try to turn off your tablet, put in a charger and see if it boots up.

Good luck 🙂

 

%d bloggers like this: