Open xiongyihui opened 7 years ago
It looks like KEYCOD_WAKEUP is just for sdk > 19, so take a look to this:
awake_screen() {
androidSdkVersion="$(adb shell getprop ro.build.version.sdk)"
if [ "androidSdkVersion" -gt 19 ]; then
echo "Awaking android device."
adb_all shell input keyevent 224 # KEYCODE_WAKEUP just for < Android 19
else
echo "Checking if its needed to turn on the screen."
adb shell dumpsys power | grep -i 'Display Power: state=OFF'
if [ $? -eq 0 ]; then
echo "Screen is off. Wake up the phone"
adb shell input keyevent 26 # KEYCODE_POWER will turn of if it is turned on
fi
fi
}
awake_screen
Android adb is quite powerful. It can be used to install apps, download files, emulate finger touch, capture screen and etc. Here I use it to do a task at 8 AM and 6 PM every day automatically. The task includes: