fix(action): stream getevent for vol on Magisk
Users reported vol+ confirmation not registering on Magisk. The prior backgrounded `getevent -qlc 1` + `kill -0` poll captured the first kernel event of any type, then restarted on miss. With six events per keypress (EV_MSC scan, EV_KEY DOWN, EV_SYN, then release variants) and a 1s poll cadence, the 10s budget exhausts before a DOWN sample lands. The chainfire note that piped getevent breaks BusyBox grep applies under Magisk's ash standalone mode. Replace with a single streaming `getevent -lq` matched inline against `KEY_VOLUMEUP DOWN` / `KEY_VOLUMEDOWN DOWN`, wrapped in `/system/bin/timeout 10`. Full paths bypass BusyBox aliasing.
This commit is contained in:
+11
-25
@@ -17,36 +17,22 @@ echo " "
|
|||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
vol_tmp="${TMPDIR:-/data/local/tmp}/teesim_vol_key"
|
vol_tmp="${TMPDIR:-/data/local/tmp}/teesim_vol_key"
|
||||||
seconds=10
|
|
||||||
|
|
||||||
: > "$vol_tmp"
|
: > "$vol_tmp"
|
||||||
getevent -qlc 1 > "$vol_tmp" 2>/dev/null &
|
|
||||||
ge_pid=$!
|
|
||||||
|
|
||||||
while [ "$seconds" -gt 0 ]; do
|
# Stream getevent and match VOLUME DOWN inline. Single-event sampling
|
||||||
sleep 1
|
# (`getevent -c 1`) races with EV_SYN/EV_MSC noise on Magisk's BusyBox ash.
|
||||||
if ! kill -0 "$ge_pid" 2>/dev/null; then
|
/system/bin/timeout 10 /system/bin/sh -c '
|
||||||
key=$(awk '/KEY_/{print $3}' "$vol_tmp" 2>/dev/null)
|
/system/bin/getevent -lq 2>/dev/null | while IFS= read -r line; do
|
||||||
case "$key" in
|
case "$line" in
|
||||||
KEY_VOLUMEUP)
|
*KEY_VOLUMEUP*DOWN*) echo UP > "$1"; exit 0 ;;
|
||||||
rm -f "$vol_tmp"
|
*KEY_VOLUMEDOWN*DOWN*) echo DOWN > "$1"; exit 0 ;;
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
KEY_VOLUMEDOWN)
|
|
||||||
rm -f "$vol_tmp"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
: > "$vol_tmp"
|
done
|
||||||
getevent -qlc 1 > "$vol_tmp" 2>/dev/null &
|
' _ "$vol_tmp"
|
||||||
ge_pid=$!
|
|
||||||
fi
|
|
||||||
seconds=$((seconds - 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
kill "$ge_pid" 2>/dev/null
|
key=$(cat "$vol_tmp" 2>/dev/null)
|
||||||
wait "$ge_pid" 2>/dev/null
|
|
||||||
rm -f "$vol_tmp"
|
rm -f "$vol_tmp"
|
||||||
|
[ "$key" = "UP" ] && return 0
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user