on 7.89+14.10.20140619.3-0ubuntu1 help sign in
unity8/tools/unlock-device
40 lines 1.2 kB history raw
1#!/bin/bash
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 a reboot.
7WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
9while getopts s:w: opt; do
10 case $opt in
11 s)
12 export ANDROID_SERIAL=$OPTARG
13 ;;
14 w)
15 WAIT_COMMAND=$OPTARG
16 ;;
17 esac
18done
20UNLOCK_SCRIPT='
21import dbus, logging;
22from unity8 import process_helpers as helpers;
23logging.basicConfig(level=logging.INFO);
24bus = dbus.SystemBus().get_object("com.canonical.powerd", "/com/canonical/powerd");
25cookie = bus.requestSysState("unlock-device-hold", 1, dbus_interface="com.canonical.powerd");
26helpers.restart_unity_with_testability();
27bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
28helpers.unlock_unity()
31eval "$WAIT_COMMAND"
33UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
34if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
35 echo "I: Unlock passed"
36 exit 0
37else
38 echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
39 exit 1
40fi