on xenial help sign in
Make unlock device more reliable by retrying
690c11bMichael Terry
tools/unlock-device+14−13
@@ -4,7 +4,7 @@
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 a reboot.
5# This will include a reboot.
6
6
7−WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
7+WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
8
8
9while getopts s:w: opt; do
9while getopts s:w: opt; do
10 case $opt in
10 case $opt in
@@ -19,16 +19,17 @@ done
19
19
20eval "$WAIT_COMMAND"
20eval "$WAIT_COMMAND"
21
21
22−# Force a sleep no matter what, since we may need to wait for unity8
22+for i in `seq 1 5`; do
23−# to finish coming up (it's hard to tell when the greeter is actually rendered)
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'"
24−sleep 30
30+ sleep 20
31+ fi
32+done
25
33
26−# We need to go through sudo to get a proper environment for dbus set up
34+echo "I: Too many unlock failures, giving 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
35+exit 1
34−fi