~saviq/unity8/card-visual-tweaks

« back to all changes in this revision

Viewing changes to tools/unlock-device

  • Committer: CI bot
  • Author(s): Michael Terry
  • Date: 2014-08-28 20:06:18 UTC
  • mfrom: (1205.2.4 unlock-via-dbus)
  • Revision ID: ps-jenkins@lists.canonical.com-20140828200618-chymc4g3165z74hz
With recent password support, we want to be able to unlock the device even with a password set.  And we need to be able to do this once the new adbd lands.  So I've added a DBus command to hide the greeter.  This should be secure because all apps are constrained and if you're on the local session bus unconstrained, you already have access to anything you want.
 
Approved by: Martin Pitt, Albert Astals Cid

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
5
5
# This will include a reboot.
6
6
 
7
 
WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
 
7
WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
8
8
 
9
9
while getopts s:w: opt; do
10
10
        case $opt in
17
17
        esac
18
18
done
19
19
 
20
 
UNLOCK_SCRIPT='
21
 
import dbus, logging;
22
 
from unity8 import process_helpers as helpers;
23
 
logging.basicConfig(level=logging.INFO);
24
 
bus = dbus.SystemBus().get_object("com.canonical.powerd", "/com/canonical/powerd");
25
 
cookie = bus.requestSysState("unlock-device-hold", 1, dbus_interface="com.canonical.powerd");
26
 
helpers.restart_unity_with_testability();
27
 
bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
28
 
helpers.unlock_unity()
29
 
'
30
 
 
31
20
eval "$WAIT_COMMAND"
32
21
 
33
 
UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
 
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)
 
24
sleep 20
 
25
 
 
26
GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"
 
27
 
 
28
UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1)
34
29
if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
35
30
    echo "I: Unlock passed"
36
31
    exit 0