Due to the battery life of the Android phone is not plugged into the USB, so put the case into the sh file, then push to the phone, execute.
But there's a problem, if the case has a long sleep operation, turn off the phone screen so that Linux goes to sleep and pauses the execution of the code.
Continue execution from the paused state until you manually press the Power key to light the screen. This can seriously affect automated testing, so here are two ways to make your phone go into sleep mode, even if it's black screen:
The first is implemented through Java code:
1 //first define a mwakelock2PowerManager pm =(PowerManager) Getsystemservice (context.power_service);3 4Mwakelock = Pm.newwakelock (Powermanager.partial_wake_lock, This5 6 . GetClass (). GetName ());7 8 9 Ten //keep waking up, then call One A Mwakelock.acquire (); - - the - //Resume normal sleep - -Mwakelock.release ();
The second is relatively simple and is implemented through the ADB command:
On the ADB shell side, writing a variable to/sys/power/wake_lock will allow Linux to wake up and the black screen will not sleep.
echo AAA >/sys/power/wake_lock
Turn off always wake up, put the value of just write in/sys/power/wake_unlock can
echo AAA >/sys/power/wake_unlock
Android backend Linux keeps waking up without going to sleep