@@ -2,16 +2,15 @@
22# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
33
44# 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.
66
7−boot_delay=20
8−max_retries=5
9−
10−ANDROID_SERIAL=$1
11−if [ -z "$ANDROID_SERIAL" ]; then
12− echo "E: Please provide an adb device number as an argument"
13− exit 1
14−fi
7+while getopts s: opt; do
8+ case $opt in
9+ s)
10+ export ANDROID_SERIAL=$OPTARG
11+ ;;
12+ esac
13+done
1514
1615UNLOCK_SCRIPT='
1716import dbus, logging;
@@ -24,26 +23,15 @@ bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
2423helpers.unlock_unity()
2524'
2625
27−retries=0
28−while [ $retries -lt $max_retries ]; do
29− ((retries += 1))
30− adb -s $ANDROID_SERIAL reboot
31− sleep 5
32− adb -s $ANDROID_SERIAL "wait-for-device"
33− sleep $boot_delay
34− UNLOCK_OUTPUT=$(adb -s $ANDROID_SERIAL shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
35− if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
36− echo "I: Unlock passed"
37− retries=$max_retries
38− else
39− echo "I: Unlock script output: '$UNLOCK_OUTPUT'"
40− if [ $retries -lt $max_retries ]; then
41− echo "W: Unlock failed, trying again"
42− else
43− echo "E: Unlock failed, no more retries"
44− exit 1
45− fi
46− fi
47−done
48−
49−exit 0
26+adb reboot
27+sleep 5
28+adb "wait-for-device"
29+sleep 20
30+UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
31+if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
32+ echo "I: Unlock passed"
33+ exit 0
34+else
35+ echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
36+ exit 1
37+fi