Recently Written · git

assistkey

Hardware key remapper for the Viwoods AiPaper Reader: AI key, volume keys and power, with multi-tap, hold and chords

git clone https://github.com/equwal/assistkey

Log | Files | Refs


tools/e2e/ai-key-return.sh (1678 bytes)

1 #!/usr/bin/env bash
2 # Test on a Viwoods reader: inside the AI screen or the crop screen, the AI key
3 # goes back to the app that was in use before.
4 #
5 # Needs: adb root, release build installed, key remapping on. Presses go through
6 # the kernel input node, because `adb shell input keyevent` skips the input
7 # filter stage.
8 set -u
9 export MSYS_NO_PATHCONV=1
10 NODE=${AI_NODE:-/dev/input/event5}
11 E="sendevent $NODE"; AI="$E 1 59 1; $E 0 0 0; sleep 0.08; $E 1 59 0; $E 0 0 0"
12 top() {
13   local t="" i
14   for i in 1 2 3 4 5; do
15     t=$(adb shell "dumpsys activity activities" | grep -m1 topResumedActivity | grep -oE '[A-Za-z0-9_.]+/[A-Za-z0-9_.$]+' | head -1)
16     [ -n "$t" ] && break; sleep 1
17   done; echo "${t%%/*}"; }
18 fail=0
19 check() { if [ "$2" = "$3" ]; then echo "PASS  $1: $2"; else echo "FAIL  $1: got '$2', want '$3'"; fail=1; fi; }
20 
21 adb shell input keyevent KEYCODE_WAKEUP; sleep 2
22 adb shell "am start -a android.settings.SETTINGS" >/dev/null 2>&1; sleep 3
23 check "start in a normal app" "$(top)" "com.android.settings"
24 
25 adb shell "am start -n com.viwoods.viwoodsai/com.wisky.wiskyai.WebViewAiActivity" >/dev/null 2>&1; sleep 3
26 check "AI screen is in front" "$(top)" "com.viwoods.viwoodsai"
27 adb shell "su 0 sh -c '$AI'"; sleep 3
28 check "AI key in the AI screen returns to the app" "$(top)" "com.android.settings"
29 
30 adb shell "su 0 am start -n com.viwoods.launcher/com.viwoods.libfloating.activity.ScreenCaptureActivity" >/dev/null 2>&1; sleep 4
31 check "crop screen is in front" "$(top)" "com.viwoods.launcher"
32 adb shell "su 0 sh -c '$AI'"; sleep 3
33 check "AI key in the crop screen returns to the app" "$(top)" "com.android.settings"
34 
35 adb shell input keyevent KEYCODE_HOME
36 exit $fail