Skip to content

Instantly share code, notes, and snippets.

@linakis
Last active February 12, 2016 11:57
Show Gist options
  • Save linakis/15a52c3562a4541bd131 to your computer and use it in GitHub Desktop.
Save linakis/15a52c3562a4541bd131 to your computer and use it in GitHub Desktop.
Android screenshots - Demo Mode for the Android System UI.
#!/bin/sh
CMD=$1
if [[ $ADB == "" ]]; then
ADB=adb
fi
if [[ $CMD != "on" && $CMD != "off" ]]; then
echo "Usage: $0 [on|off] [hhmm] [screenshot_path]" >&2
exit
fi
if [[ "$2" != "" ]]; then
HHMM="$2"
fi
if [[ "$3" != "" ]]; then
SCREENSHOT_PATH="$3"
fi
$ADB root || exit
$ADB shell settings put global sysui_demo_allowed 1
if [ $CMD == "on" ]; then
$ADB shell am broadcast -a com.android.systemui.demo --es command enter || exit
if [[ "$HHMM" != "" ]]; then
$ADB shell am broadcast -a com.android.systemui.demo --es command clock --es hhmm ${HHMM}
fi
$ADB shell am broadcast -a com.android.systemui.demo --es command battery --es level 100 --es plugged false
$ADB shell am broadcast -a com.android.systemui.demo --es command network \
--es wifi show \
--es fully true \
--es level 4
$ADB shell am broadcast -a com.android.systemui.demo --es command network \
--es mobile show \
--es fully true \
--es level 4 \
--es datatype lte
$ADB shell am broadcast -a com.android.systemui.demo --es command notifications \
--es visible false
if [[ "$SCREENSHOT_PATH" != "" ]]; then
$ADB shell screencap -p /sdcard/android_demomode_screen.png
$ADB pull /sdcard/android_demomode_screen.png ${SCREENSHOT_PATH}/device-$(date +%Y%m%d_%H%M%S%Z).png
$ADB shell rm -rf /sdcard/android_demomode_screen.png
$ADB shell am broadcast -a com.android.systemui.demo --es command exit
fi
elif [ $CMD == "off" ]; then
$ADB shell am broadcast -a com.android.systemui.demo --es command exit
fi
@linakis
Copy link
Author

linakis commented Feb 12, 2016

Based on sample script from Demo Mode for the Android System UI, with a few tweaks to make it work as expected.

Added screen grabbing option if save path is specified.

e.g.
./android-screenshooting-demo-mode.sh on 1400 .

will apply the demo mode options and save a screenshot on the current path.

reminder: make sure the script is executable (chmod +x android-screenshooting-demo-mode.sh

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