@@ -0,0 +1,51 @@
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.
5+# This will include reboots.
11+if [ -z "$ANDROID_SERIAL" ]; then
12+ echo "E: Please provide an adb device number as an argument"
18+from unity8 import process_helpers as helpers;
19+logging.basicConfig(level=logging.INFO);
20+bus = dbus.SystemBus().get_object(\"com.canonical.powerd\", \"/com/canonical/powerd\");
21+cookie = bus.requestSysState(\"unlock-device-hold\", 1, dbus_interface=\"com.canonical.powerd\");
22+helpers.restart_unity_with_testability();
23+bus.clearSysState(cookie, dbus_interface=\"com.canonical.powerd\");
24+helpers.unlock_unity()
30+while [ $retries -lt $max_retries ]; do
32+ adb -s $ANDROID_SERIAL reboot
34+ adb -s $ANDROID_SERIAL "wait-for-device"
36+ UNLOCK_OUTPUT=$(adb -s $ANDROID_SERIAL shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
37+ if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
38+ echo "I: Unlock passed"
41+ echo "I: Unlock script output: '$UNLOCK_OUTPUT'"
42+ if [ $retries -lt $max_retries ]; then
43+ echo "W: Unlock failed, trying again"
45+ echo "E: Unlock failed, no more retries"