-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathunlock-if-locked.sh
More file actions
40 lines (31 loc) · 855 Bytes
/
unlock-if-locked.sh
File metadata and controls
40 lines (31 loc) · 855 Bytes
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
#!/bin/bash
AWAKESTATUS=`adb shell dumpsys power | grep "mWakefulness=" | xargs`
LOCKEDSTATUS=`adb shell dumpsys power | grep "mHoldingWakeLockSuspendBlocker" | xargs`
echo -e "AWAKESTATUS = $AWAKESTATUS"
echo -e "LOCKEDSTATUS = $LOCKEDSTATUS"
if [[ $AWAKESTATUS == *"Awake"* ]]; then
echo "Setting AWAKE to true..."
AWAKE="true"
else
echo "Setting AWAKE to false..."
AWAKE="false"
fi
if [[ $LOCKEDSTATUS == *"mHoldingWakeLockSuspendBlocker=false"* ]]; then
echo "Setting LOCKED to true..."
LOCKED="true"
else
echo "Setting LOCKED to false..."
LOCKED="FALSE"
fi
echo -e "AWAKE = $AWAKE"
echo -e "LOCKED = $LOCKED"
if [[ $AWAKE == "false" ]]; then
echo "Waking up..."
adb shell input keyevent KEYCODE_WAKEUP
sleep 1
fi
if [[ $LOCKED == "true" ]]; then
echo "Unlocking..."
adb shell input keyevent 82
sleep 1
fi