Automatically turn on your Android phone when charging is connected

Good day to all. There is a phone from which I would like to make a video recorder for my car. I wrote a program that will record videos, save them, etc. But how to make the phone turn on when you connect a USB charging cable that is plugged into a 220B socket?

ROOT access is full. The phone model is ZTE Blade Q Lux 3G PRO. Android 4.4.2.

On the Internet, I read articles on how to do this on phones Samsung. As it is said here in in one of the answers, you need to change the contents of the files /system/bin/playlpm or /system/bin/lpm, but neither file exists in my phone. As far as I understand the principle, you need to find a file that starts the animation of the battery

enter a description of the image here

And add lines to enable the system:

#!/system/bin/sh

/system/bin/reboot

I tried to change all the content to these lines in the following files:

  • /system/bin/bootanimation
  • /system/bin/ipod
  • /system/bin/chcon

To no avail. Maybe some other files need to be changed? Or do you even need to dig in another folder? Tell me.


When I tried to do this trick with the file /system/bin/chcon, the button to disable the display stopped working. That is, in short, as I turned on the phone, so the display works, does not turn off and does not respond to the off button. Only after after restoring the previous file, everything became normal after restarting the phone. So I conclude that automatic activation is possible to implement. Each system file really runs scripts, each of its own, and each is responsible for itself. It is only necessary to understand where the desired animation file of the phone's battery charge is and where it is necessary to enter the enable command in it.

Author: nick, 2016-07-20

2 answers

In order for the phone to start when charging is connected, follow these steps:

  • Download and install the program Adb Run on your computer. It is necessary to establish a connection to the phone via a USB wire.
  • Download and install the Bootimg program on your computer. It is necessary to edit the phone's firmware file boot.img. The program patch should be C:\Users\Admin\.
  • Download the firmware (ZIP archive) to your computer. Get a file from the archive boot.img and put it in the folder with the program Bootimg. Open the system console (Start menu -> cmd). Enter the following command:

    bootimg --unpack-bootimg
    

Open the created folder initrd, find the files init.rc and init.charging.rc in it. Open them. In each of them we find the following lines:

service ipod /system/bin/ipod
    user root
    group root

And after them we write below:

    class_start core
    class_start main
    class_start default

Save and close both files. Go back to the console. Write the following command:

bootimg --repack-bootimg

Run the Adb Run program. By default, it is set to C:\adb\. Select item 5, then 0. The phone should enter Fastboot mode. Then select item 1, and then 1. The console should display at least two lines:

List of devices attached
0123456789ABCDEF    device

If you only see this:

List of devices attached

Then you may have the following errors:

  • Not enabled USB debugging in developer mode
  • The USB cable is not connected correctly or may be damaged
  • In the device manager (Right-click on the "My" shortcut computer"; Properties; Device Manager) the phone is displayed as an unknown device, for example, as in the screenshot here

Then select item 5, then 0. Wait for the message FASTBOOT mode.. or something like that to appear on the phone screen. Select item 7, then 1, and then write:

fastboot flash boot C:\Users\Admin\boot-new.img

Waiting for the console to display Done... at the end if the installation is successful boot.img. Then we write again in the console:

fastboot reboot

Closing the Adb Run program (console). Disconnect the phone from the computer. After loading the phone, turn it off. Connect the phone to the 220V charging, and, within 10 seconds, the phone will turn on itself. That's all done.

If you have any errors or something went wrong, I ask you to write in the comments. I will be happy to help!


I want to give people more advice: If the first attempt to perform the procedure did not work for any reason, try a few more times to carefully perform all of the above the listed actions.


If the Android version is 4.4 or higher, then errors may occur and perhaps nothing will work. As I, for example, was answered by the support of the ZTE corporation to the question "is it possible to somehow implement the auto-off of the phone when..." I was told that you see this feature is not available on this launcher. And I realized that the only way to solve the problem is to roll back the Android version from 4.4 to 4.2.

 6
Author: nick, 2016-07-27 14:48:38

If I remember correctly, this feature depends on the loader, such as TWRP. But in older versions, when you connect the USB charging, the download starts and ends only on the bootloader itself. To start the android further, you need to manually select system reboot. Dig in that direction.

 3
Author: Jack Black, 2016-07-20 11:51:14