-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathunlock.sh
executable file
·46 lines (34 loc) · 1.01 KB
/
unlock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
#####
# Unlocks the phone using the pin in the variable SECRET_PIN
# Test are expected to fail if the phone doesn't have the PIN set
#####
SECRET_PIN="123456"
while ! (adb devices | grep "emu")
do
echo "Error: The emulator is not running or not connected to adb. "
sleep 1
done
# sleep until Android is done booting
adb wait-for-device shell \
'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "locksettings set-pin $SECRET_PIN" | adb shell || echo "Failed to change pin, probably already set"
sleep 1
echo "Device is done booting"
sleep 10
# back to ensure the screen is turned on
adb shell input keyevent 4 # Back
sleep 1
# then double power button tap to lock in case it was unlocked
adb shell input keyevent 26 # Power
sleep 1
adb shell input keyevent 26 # Power
sleep 1
# trigger the unlock menu
adb shell input keyevent 82 # Menu
sleep 2
# Unlock
adb shell input text $SECRET_PIN # Input Pin
sleep 1
adb shell input keyevent 66 # Enter
echo "Done this unlock"