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.
The source I have used is: https://forum.xda-developers.com/galaxy-tab-a/development/recovery-official-twrp-gtaxlwifi-galaxy-t3437666
Installing TWRP
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
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.
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
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
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