on 28aebb5 help sign in
unity8/tools/unlock-device
35 lines 1.1 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"
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
20eval "$WAIT_COMMAND"
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)
24sleep 20
26GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"
28UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1)
29if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
30 echo "I: Unlock passed"
31 exit 0
32else
33 echo "I: Unlock failed, script output: '$UNLOCK_OUTPUT'"
34 exit 1
35fi