on 7.85+14.04.20140416-0ubuntu1 help sign in
unity8/tools/unlock-device
42 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="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()
31adb reboot
32sleep 5
33adb "wait-for-device"
34eval "$WAIT_COMMAND"
35UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
36if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
37 echo "I: Unlock passed"
38 exit 0
39else
40 echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
41 exit 1
42fi