Initially it unlocks the device and swipe up, but when it comes to co-ordinates, it is sending too, but it does nothing to the device.. Please find the logs.
$ bash test.sh
Sending 1: 254, 948
Sending 4: 254, 1224
Sending 7: 254, 1526
Sending 8: 513, 1526
Trying to draw L through it.. 1,4,7,8..
Here is my pattern. Please check.
PATTERN="1 4 7 8" # The unlock pattern to draw, space seperated
COL_1=254 # X coordinate of column 1 (in pixels)
COL_2=513 # X coordinate of column 2 (in pixels)
COL_3=818 # X coordinate of column 3 (in pixels)
ROW_1=948 # Y coordinate of row 1 (in pixels)
ROW_2=1224 # Y coordinate of row 2 (in pixels)
ROW_3=1526 # Y coordinate of row 3 (in pixels)
MULTIPLIER=1 # Multiplication factor for coordinates. For Nexus 4, set this to 2. For low res phones such as
# Samsung Galaxy S2, set this to 1. Experiment with this value if you can't see anything happening.
WAKE_SCREEN_ENABLED=true # If true, the script will start by sending the power button press event
SWIPE_UP_ENABLED=true # If true, the script will swipe upwards before drawing the pattern (e.g. for lollipop lockscreen)
SWIPE_UP_X=450 # X coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
SWIPE_UP_Y_FROM=1000 # Start Y coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
SWIPE_UP_Y_TO=200 # End Y coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
# =======================================================================================================================
# Define X&Y coordinates for each of the 9 positions.
X[1]=$(( ${COL_1} * ${MULTIPLIER} ))
X[2]=$(( ${COL_2} * ${MULTIPLIER} ))
X[3]=$(( ${COL_3} * ${MULTIPLIER} ))
X[4]=$(( ${COL_1} * ${MULTIPLIER} ))
X[5]=$(( ${COL_2} * ${MULTIPLIER} ))
X[6]=$(( ${COL_3} * ${MULTIPLIER} ))
X[7]=$(( ${COL_1} * ${MULTIPLIER} ))
X[8]=$(( ${COL_2} * ${MULTIPLIER} ))
X[9]=$(( ${COL_3} * ${MULTIPLIER} ))
Y[1]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[2]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[3]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[4]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[5]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[6]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[7]=$(( ${ROW_3} * ${MULTIPLIER} ))
Y[8]=$(( ${ROW_3} * ${MULTIPLIER} ))
Y[9]=$(( ${ROW_3} * ${MULTIPLIER} ))
# Function definitions
WakeScreen() {
if [ "$WAKE_SCREEN_ENABLED" = true ]; then
adb shell input keyevent 26
fi
}
SwipeUp() {
if [ "$SWIPE_UP_ENABLED" = true ]; then
adb shell input swipe ${SWIPE_UP_X} ${SWIPE_UP_Y_FROM} ${SWIPE_UP_X} ${SWIPE_UP_Y_TO}
fi
}
StartTouch() {
adb shell sendevent /dev/input/event1 3 57 14
}
SendCoordinates () {
adb shell sendevent /dev/input/event1 3 53 $1
adb shell sendevent /dev/input/event1 3 54 $2
adb shell sendevent /dev/input/event1 3 58 57
adb shell sendevent /dev/input/event1 0 0 0
}
FinishTouch() {
adb shell sendevent /dev/input/event1 3 57 4294967295
adb shell sendevent /dev/input/event1 0 0 0
}
SwipePattern() {
for NUM in $PATTERN
do
echo "Sending $NUM: ${X[$NUM]}, ${Y[$NUM]}"
SendCoordinates ${X[$NUM]} ${Y[$NUM]}
done
}
# Actions
WakeScreen
SwipeUp
StartTouch
SwipePattern
FinishTouch
Initially it unlocks the device and swipe up, but when it comes to co-ordinates, it is sending too, but it does nothing to the device.. Please find the logs.
$ bash test.sh
Sending 1: 254, 948
Sending 4: 254, 1224
Sending 7: 254, 1526
Sending 8: 513, 1526
Trying to draw L through it.. 1,4,7,8..
Here is my pattern. Please check.