@@ -2,16 +2,15 @@
2# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
2# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
4# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
4# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
5−# This will include reboots.
5+# This will include a reboot.
7−boot_delay=20
7+while getopts s: opt; do
8−max_retries=5
8+ case $opt in
10−ANDROID_SERIAL=$1
10+ export ANDROID_SERIAL=$OPTARG
11−if [ -z "$ANDROID_SERIAL" ]; then
11+ ;;
12− echo "E: Please provide an adb device number as an argument"
12+ esac
16UNLOCK_SCRIPT='
15UNLOCK_SCRIPT='
17import dbus, logging;
16import dbus, logging;
@@ -24,26 +23,15 @@ bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
24helpers.unlock_unity()
23helpers.unlock_unity()
28−while [ $retries -lt $max_retries ]; do
30− adb -s $ANDROID_SERIAL reboot
26+adb reboot
32− adb -s $ANDROID_SERIAL "wait-for-device"
28+adb "wait-for-device"
33− sleep $boot_delay
29+sleep 20
34− UNLOCK_OUTPUT=$(adb -s $ANDROID_SERIAL shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
30+UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
35− if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
31+if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
36− echo "I: Unlock passed"
32+ echo "I: Unlock passed"
37− retries=$max_retries
33+ exit 0
39− echo "I: Unlock script output: '$UNLOCK_OUTPUT'"
35+ echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
40− if [ $retries -lt $max_retries ]; then
41− echo "W: Unlock failed, trying again"
43− echo "E: Unlock failed, no more retries"