| 1 |
#!/bin/bash |
| 2 |
# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*- |
| 3 |
|
| 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. |
| 10 |
# |
| 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. |
| 15 |
# |
| 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/>. |
| 18 |
# |
| 19 |
|
| 20 |
# Our goal here is to get an Lomiri Touch device into a testable unlocked state. |
| 21 |
# This will include a reboot. |
| 22 |
|
| 23 |
WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20" |
| 24 |
|
| 25 |
while 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 |
| 34 |
done |
| 35 |
|
| 36 |
eval "$WAIT_COMMAND" |
| 37 |
|
| 38 |
for 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.lomiri.LomiriGreeter --object-path /com/lomiri/LomiriGreeter --method com.lomiri.LomiriGreeter.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 |
| 48 |
done |
| 49 |
|
| 50 |
echo "I: Too many unlock failures, giving up" |
| 51 |
exit 1 |