on xenial help sign in
Make unlock device more reliable by retrying
commit690c11b967b8983929835f91a4a7599754f7abe8 authorMichael Terry <michael.terry@canonical.com> dateFri 26 Sep 2014, 14:01 (12 years ago) parentade5c1b
1 file changed+14−13
tools/unlock-device+14−13
tools/unlock-device+14−13
@@ -4,7 +4,7 @@
44# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
55# This will include a reboot.
66
7−WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
7+WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
88
99while getopts s:w: opt; do
1010 case $opt in
@@ -19,16 +19,17 @@ done
1919
2020eval "$WAIT_COMMAND"
2121
22−# Force a sleep no matter what, since we may need to wait for unity8
23−# to finish coming up (it's hard to tell when the greeter is actually rendered)
24−sleep 30
22+for i in `seq 1 5`; do
23+ # We need to go through sudo to get a proper environment for dbus set up
24+ UNLOCK_OUTPUT=$(adb shell "gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked" 2>&1)
25+ if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
26+ echo "I: Unlock passed"
27+ exit 0
28+ else
29+ echo "I: Unlock attempt $i failed, script output: '$UNLOCK_OUTPUT'"
30+ sleep 20
31+ fi
32+done
2533
26−# We need to go through sudo to get a proper environment for dbus set up
27−UNLOCK_OUTPUT=$(adb shell "gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked" 2>&1)
28−if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
29− echo "I: Unlock passed"
30− exit 0
31−else
32− echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
33− exit 1
34−fi
34+echo "I: Too many unlock failures, giving up"
35+exit 1