#!/bin/bash # -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*- # Our goal here is to get an Ubuntu Touch device into a testable unlocked state. # This will include a reboot. WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device" while getopts s:w: opt; do case $opt in s) export ANDROID_SERIAL=$OPTARG ;; w) WAIT_COMMAND=$OPTARG ;; esac done eval "$WAIT_COMMAND" # Force a sleep of twenty no matter what, since we may need to wait for unity8 # to finish coming up (it's hard to tell when the greeter is actually rendered) sleep 20 GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked" UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1) if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then echo "I: Unlock passed" exit 0 else echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'" exit 1 fi