Skip to content

Instantly share code, notes, and snippets.

@brozikcz
Created November 22, 2016 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brozikcz/754558d08ae2c543c25cf31946711391 to your computer and use it in GitHub Desktop.
Save brozikcz/754558d08ae2c543c25cf31946711391 to your computer and use it in GitHub Desktop.
bash script for dozing android device
#!/bin/bash
adb shell dumpsys deviceidle |grep "mScreenOn=true" > /dev/null
if [ "$?" -eq "0" ]; then
adb shell input keyevent POWER
sleep 2
fi
adb shell dumpsys battery |grep "USB powered: true" > /dev/null
if [ "$?" -eq "0" ]; then
adb shell dumpsys battery unplug
fi
stat=$(adb shell dumpsys deviceidle |grep "mState=IDLE")
until [[ $stat == *"IDLE"* && $stat != *"IDLE_"* ]]; do
stat=$(adb shell dumpsys deviceidle step)
echo -e $stat
done
echo "Welcome to dreamland!"
@brozikcz
Copy link
Author

Or use adb shell dumpsys deviceidle force-idle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment