on bionic help sign in
unity8/tools/unlock-device
51 lines 1.7 kB history raw
1#!/bin/bash
2# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
4#
5# Copyright (C) 2017 Canonical Ltd
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3 as
9# published by the Free Software Foundation.
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
20# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
21# This will include a reboot.
23WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
25while getopts s:w: opt; do
26 case $opt in
27 s)
28 export ANDROID_SERIAL=$OPTARG
29 ;;
30 w)
31 WAIT_COMMAND=$OPTARG
32 ;;
33 esac
34done
36eval "$WAIT_COMMAND"
38for i in `seq 1 5`; do
39 # We need to go through sudo to get a proper environment for dbus set up
40 UNLOCK_OUTPUT=$(adb shell "gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked" 2>&1)
41 if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
42 echo "I: Unlock passed"
43 exit 0
44 else
45 echo "I: Unlock attempt $i failed, script output: '$UNLOCK_OUTPUT'"
46 sleep 20
47 fi
48done
50echo "I: Too many unlock failures, giving up"
51exit 1