@@ -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; sleep 20"
7+WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
88
99while getopts s:w: opt; do
1010 case $opt in
@@ -17,20 +17,15 @@ while getopts s:w: opt; do
1717 esac
1818done
1919
20−UNLOCK_SCRIPT='
21−import dbus, logging;
22−from unity8 import process_helpers as helpers;
23−logging.basicConfig(level=logging.INFO);
24−bus = dbus.SystemBus().get_object("com.canonical.powerd", "/com/canonical/powerd");
25−cookie = bus.requestSysState("unlock-device-hold", 1, dbus_interface="com.canonical.powerd");
26−helpers.restart_unity_with_testability();
27−bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
28−helpers.unlock_unity()
29−'
30−
3120eval "$WAIT_COMMAND"
3221
33−UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
22+# Force a sleep of twenty 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 20
25+
26+GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"
27+
28+UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1)
3429if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
3530 echo "I: Unlock passed"
3631 exit 0