From 338778908d5d2c9e7968bf4a203ad44e3d3bb0f6 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 18:58:11 -0647 Subject: [PATCH 1/2] omamobile-fingerprint 0.1.11: touches in panel pixels, the circle lit before the capture, and the refresh rate the HAL parses On the Pixel 9a every authenticate touch came back ACQUIRED_PARTIAL. Three things were wrong, all found from the HAL's own log. The bridge scaled touches to panel pixels for its own hit test but handed the HAL the raw touchscreen values, ten times too large (5432,17847 for a finger on the 540,1756 circle), so the HAL saw every finger off the sensor. It now sends the scaled position. The HAL captures at onPointerDownWithContext, not at onUiReady, so the circle was still dark for the first frame. The bridge now lights the circle and waits the settle time before it reports the finger. The HAL reads the refresh rate from panel0-backlight/state after its "@" (gs-panel's "on: WxH@Hz") and logged "Failed to parse refresh rate" on our bare "on". The runner now writes the panel's size and rate, per device (cheetah 60 Hz, tegu 120 Hz, the rate the 9a's local HBM needs). With these, captures are GOOD and reach the matcher (NOMATCH rather than PARTIAL); image quality is still low (15-26) and matching is the next step. --- fingerprint/bridge/omamobile-fp-bridge.c | 14 ++++++++++---- .../omamobile-fingerprint/lib/omamobile-fp-chroot | 11 +++++++---- packages/omamobile-fingerprint/version | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/fingerprint/bridge/omamobile-fp-bridge.c b/fingerprint/bridge/omamobile-fp-bridge.c index ac8d40840..a39a8b00f 100644 --- a/fingerprint/bridge/omamobile-fp-bridge.c +++ b/fingerprint/bridge/omamobile-fp-bridge.c @@ -34,7 +34,8 @@ * is not the user's password: fprintd's own polkit check is what guards * enrollment; * - reads the touchscreen while an operation runs: a finger inside the - * sensor circle lights the circle (the panel's local_hbm_mode), then + * sensor circle lights the circle (the panel's local_hbm_mode), then, + * with the position scaled to panel pixels, * onPointerDownWithContext and, a frame later, onUiReady; lifting the * finger reverses that. The HAL reports halHandlesDisplayTouches and * halControlsIllumination false, so both are the client's job. @@ -934,6 +935,9 @@ static void lhbm(bool on) lhbm_at = now_ms(); } +static int32_t touch_max_x, touch_max_y; /* 0: unknown, no scaling */ +static int32_t scale(int32_t v, int32_t max, int32_t panel); + static void pointer(bool down) { AParcel *in = begin(session); @@ -941,13 +945,16 @@ static void pointer(bool down) if (down) finger_since = time; - write_pointer(in, touch_x, touch_y, time, finger_since); + /* The HAL takes panel pixels, the frame of its sensor location. */ + write_pointer(in, scale(touch_x, touch_max_x, panel_w), + scale(touch_y, touch_max_y, panel_h), time, finger_since); if (down) { reply("FINGER DOWN"); - call_void(session, S_ON_POINTER_DOWN_WITH_CONTEXT, in, "onPointerDown"); + /* The HAL captures at pointer down: light the circle first. */ lhbm(true); if (lhbm_lit) usleep(lhbm_settle_ms * 1000); + call_void(session, S_ON_POINTER_DOWN_WITH_CONTEXT, in, "onPointerDown"); call_void(session, S_ON_UI_READY, begin(session), "onUiReady"); } else { call_void(session, S_ON_POINTER_UP_WITH_CONTEXT, in, "onPointerUp"); @@ -1026,7 +1033,6 @@ struct input_absinfo_ { int32_t value, minimum, maximum, fuzz, flat, resolution; }; #define EVIOCGABS_(abs) _IOR('E', 0x40 + (abs), struct input_absinfo_) -static int32_t touch_max_x, touch_max_y; /* 0: unknown, no scaling */ static void touch_range(void) { diff --git a/packages/omamobile-fingerprint/lib/omamobile-fp-chroot b/packages/omamobile-fingerprint/lib/omamobile-fp-chroot index 3e4fd6043..9c4751464 100755 --- a/packages/omamobile-fingerprint/lib/omamobile-fp-chroot +++ b/packages/omamobile-fingerprint/lib/omamobile-fp-chroot @@ -49,14 +49,14 @@ case $DEVICE in cheetah) TA=g7.app KEYMINT=/vendor/bin/hw/android.hardware.security.keymint-service.trusty - PANEL=1440x3120 PANEL_NAME=sdc-s6e3hc4 MAP_STORES=0 ;; + PANEL=1440x3120 PANEL_HZ=60 PANEL_NAME=sdc-s6e3hc4 MAP_STORES=0 ;; tegu) TA=g7a.app KEYMINT=/vendor/bin/hw/android.hardware.security.keymint-service.rust.trusty # Google's panel_name is the DSI device's name, from the bootloader's # "google-tg4c" panel; OMAMOBILE_FP_PANEL_NAME overrides it. # the 9a's Trusty stores as block devices (FINGERPRINT-PLAN D1, F4b) - PANEL=1080x2424 PANEL_NAME=google-tg4c MAP_STORES=1 ;; + PANEL=1080x2424 PANEL_HZ=120 PANEL_NAME=google-tg4c MAP_STORES=1 ;; *) echo "omamobile-fp: unknown device '$DEVICE' (cheetah, tegu)" >&2; exit 1 ;; esac PANEL_NAME=${OMAMOBILE_FP_PANEL_NAME:-$PANEL_NAME} @@ -182,13 +182,16 @@ setup_sys() { done mkdir -p "$sys/devices/platform/exynos-drm/primary-panel" echo "$PANEL_NAME" > "$sys/devices/platform/exynos-drm/primary-panel/panel_name" - echo 60 > "$sys/devices/platform/exynos-drm/primary-panel/op_hz" + # The HAL reads the refresh rate from the backlight state, after its "@" + # (gs-panel's "on: WxH@Hz"); a bare "on" logs "Failed to parse refresh + # rate" and leaves its exposure compensation without a rate. + echo "$PANEL_HZ" > "$sys/devices/platform/exynos-drm/primary-panel/op_hz" # The panel driver's backlight device carries local_hbm_mode and # local_hbm_max_timeout; expose it under Google's name. bl=$(grep -l . /sys/class/backlight/*/local_hbm_mode 2>/dev/null | head -1 || true) mkdir -p "$sys/class/backlight/panel0-backlight" echo 0 > "$sys/class/backlight/panel0-backlight/hbm_mode" - echo on > "$sys/class/backlight/panel0-backlight/state" + echo "on: ${PANEL}@${PANEL_HZ}" > "$sys/class/backlight/panel0-backlight/state" if [[ -n $bl ]]; then bl=$(dirname "$bl") bind "$bl/local_hbm_mode" "$sys/class/backlight/panel0-backlight/local_hbm_mode" diff --git a/packages/omamobile-fingerprint/version b/packages/omamobile-fingerprint/version index 9767cc98e..20f49513e 100644 --- a/packages/omamobile-fingerprint/version +++ b/packages/omamobile-fingerprint/version @@ -1 +1 @@ -0.1.10 +0.1.11 From ba4d1f2f19885e675d721421cc7359113eb8450e Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 20:00:06 -0647 Subject: [PATCH 2/2] omamobile-fingerprint 0.1.11: keep the 7 Pro's circle order and state line Review: the reorder and the rate in the backlight state are the 9a's needs, so both are per device now. The 9a passes --lhbm-first 1 and writes gs_panel's "On: 1080x2424@120"; the 7 Pro keeps pointer down before the circle and its bare "on". The PointerContext time is taken after the settle, and the package test checks each phone's values under set -u. --- fingerprint/bridge/omamobile-fp-bridge.c | 35 ++++++++++++++----- .../lib/omamobile-fp-chroot | 19 ++++++---- packages/omamobile-fingerprint/test/all | 14 ++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/fingerprint/bridge/omamobile-fp-bridge.c b/fingerprint/bridge/omamobile-fp-bridge.c index a39a8b00f..ec55b1cbf 100644 --- a/fingerprint/bridge/omamobile-fp-bridge.c +++ b/fingerprint/bridge/omamobile-fp-bridge.c @@ -231,6 +231,8 @@ static const char *inhibit_dir; /* --inhibit: off unless given */ /* The panel takes the circle at its next frame; a frame and a half at 60 Hz * would do, an idle panel may run at 10 Hz. Tuned in FINGERPRINT-PLAN F8. */ static int lhbm_settle_ms = 120; +/* --lhbm-first 1: light the circle before onPointerDown (the 9a) */ +static bool lhbm_first; /* The panel driver turns LHBM off after at most 3 s; refresh it meanwhile. */ #define LHBM_REFRESH_MS 2000 /* Sensor defaults (stock cheetah); getSensorProps() replaces them. */ @@ -941,20 +943,35 @@ static int32_t scale(int32_t v, int32_t max, int32_t panel); static void pointer(bool down) { AParcel *in = begin(session); - int64_t time = now_ms(); + int64_t time; - if (down) + if (down) { + reply("FINGER DOWN"); + /* + * The 9a's HAL captures at pointer down, so the circle is lit + * and settled first (--lhbm-first 1). The 7 Pro's waits for + * onUiReady: pointer down, then the circle, then the settle. + */ + if (lhbm_first) { + lhbm(true); + if (lhbm_lit) + usleep(lhbm_settle_ms * 1000); + } + time = now_ms(); finger_since = time; + } else { + time = now_ms(); + } /* The HAL takes panel pixels, the frame of its sensor location. */ write_pointer(in, scale(touch_x, touch_max_x, panel_w), scale(touch_y, touch_max_y, panel_h), time, finger_since); if (down) { - reply("FINGER DOWN"); - /* The HAL captures at pointer down: light the circle first. */ - lhbm(true); - if (lhbm_lit) - usleep(lhbm_settle_ms * 1000); call_void(session, S_ON_POINTER_DOWN_WITH_CONTEXT, in, "onPointerDown"); + if (!lhbm_first) { + lhbm(true); + if (lhbm_lit) + usleep(lhbm_settle_ms * 1000); + } call_void(session, S_ON_UI_READY, begin(session), "onUiReady"); } else { call_void(session, S_ON_POINTER_UP_WITH_CONTEXT, in, "onPointerUp"); @@ -1471,7 +1488,7 @@ static void usage(void) { say("usage: omamobile-fp-bridge [--socket PATH] [--state DIR] [--touch EVDEV]\n" " [--lhbm PATH] [--settle MS] [--ui-state PATH]\n" - " [--inhibit DIR] [--panel WxH]"); + " [--inhibit DIR] [--panel WxH] [--lhbm-first 0|1]"); exit(2); } @@ -1493,6 +1510,8 @@ int main(int argc, char **argv, char **envp) lhbm_path = v; else if (!strcmp(argv[i], "--settle")) lhbm_settle_ms = atoi(v); + else if (!strcmp(argv[i], "--lhbm-first")) + lhbm_first = atoi(v) != 0; else if (!strcmp(argv[i], "--ui-state")) ui_state_path = v; else if (!strcmp(argv[i], "--inhibit")) diff --git a/packages/omamobile-fingerprint/lib/omamobile-fp-chroot b/packages/omamobile-fingerprint/lib/omamobile-fp-chroot index 9c4751464..3c753d475 100755 --- a/packages/omamobile-fingerprint/lib/omamobile-fp-chroot +++ b/packages/omamobile-fingerprint/lib/omamobile-fp-chroot @@ -49,14 +49,20 @@ case $DEVICE in cheetah) TA=g7.app KEYMINT=/vendor/bin/hw/android.hardware.security.keymint-service.trusty - PANEL=1440x3120 PANEL_HZ=60 PANEL_NAME=sdc-s6e3hc4 MAP_STORES=0 ;; + # the 7 Pro's HAL got a bare "on" and the circle after pointer down, + # and matches with both + PANEL=1440x3120 PANEL_HZ=60 PANEL_STATE=on LHBM_FIRST=0 + PANEL_NAME=sdc-s6e3hc4 MAP_STORES=0 ;; tegu) TA=g7a.app KEYMINT=/vendor/bin/hw/android.hardware.security.keymint-service.rust.trusty # Google's panel_name is the DSI device's name, from the bootloader's # "google-tg4c" panel; OMAMOBILE_FP_PANEL_NAME overrides it. # the 9a's Trusty stores as block devices (FINGERPRINT-PLAN D1, F4b) - PANEL=1080x2424 PANEL_HZ=120 PANEL_NAME=google-tg4c MAP_STORES=1 ;; + # the 9a's HAL parses the rate after the "@" of gs_panel's state line + # ("On: WxH@Hz") and captures at pointer down, so the circle comes first + PANEL=1080x2424 PANEL_HZ=120 PANEL_STATE="On: 1080x2424@120" LHBM_FIRST=1 + PANEL_NAME=google-tg4c MAP_STORES=1 ;; *) echo "omamobile-fp: unknown device '$DEVICE' (cheetah, tegu)" >&2; exit 1 ;; esac PANEL_NAME=${OMAMOBILE_FP_PANEL_NAME:-$PANEL_NAME} @@ -182,16 +188,16 @@ setup_sys() { done mkdir -p "$sys/devices/platform/exynos-drm/primary-panel" echo "$PANEL_NAME" > "$sys/devices/platform/exynos-drm/primary-panel/panel_name" - # The HAL reads the refresh rate from the backlight state, after its "@" - # (gs-panel's "on: WxH@Hz"); a bare "on" logs "Failed to parse refresh - # rate" and leaves its exposure compensation without a rate. + # The 9a's HAL reads the refresh rate from the backlight state, after its + # "@" (gs_panel's "On: WxH@Hz"); a bare "on" logs "Failed to parse refresh + # rate". PANEL_STATE is per device: the 7 Pro keeps its bare "on". echo "$PANEL_HZ" > "$sys/devices/platform/exynos-drm/primary-panel/op_hz" # The panel driver's backlight device carries local_hbm_mode and # local_hbm_max_timeout; expose it under Google's name. bl=$(grep -l . /sys/class/backlight/*/local_hbm_mode 2>/dev/null | head -1 || true) mkdir -p "$sys/class/backlight/panel0-backlight" echo 0 > "$sys/class/backlight/panel0-backlight/hbm_mode" - echo "on: ${PANEL}@${PANEL_HZ}" > "$sys/class/backlight/panel0-backlight/state" + echo "$PANEL_STATE" > "$sys/class/backlight/panel0-backlight/state" if [[ -n $bl ]]; then bl=$(dirname "$bl") bind "$bl/local_hbm_mode" "$sys/class/backlight/panel0-backlight/local_hbm_mode" @@ -422,6 +428,7 @@ start() { --socket /dev/socket/omamobile-fp/bridge.sock --touch /dev/input/touchscreen \ --ui-state /dev/socket/omamobile-fp-ui/state.json \ --inhibit /dev/socket/omamobile-fp-ui/inhibit --panel "$PANEL" \ + --lhbm-first "$LHBM_FIRST" \ ${OMAMOBILE_FP_LHBM_SETTLE_MS:+--settle "$OMAMOBILE_FP_LHBM_SETTLE_MS"} fi diff --git a/packages/omamobile-fingerprint/test/all b/packages/omamobile-fingerprint/test/all index 9aa02a1e4..a0a4422d7 100755 --- a/packages/omamobile-fingerprint/test/all +++ b/packages/omamobile-fingerprint/test/all @@ -22,6 +22,20 @@ grep -c '\[\[ -f \$STATE/td.img \]\] && maps+=(-f 0:/dev/block/ss-td -m /dev/blo fail "TD maps only with its image" grep -c '\[\[ -f \$STATE/tdp.img \]\] && maps+=(-f persist/0:/dev/block/ss-tdp)' lib/omamobile-fp-chroot >/dev/null || fail "TDP maps only with its image" +# Each phone's panel state and circle order: the 7 Pro keeps a bare "on" and +# the circle after pointer down; the 9a's HAL parses the rate after the "@". +grep -c 'PANEL=1440x3120 PANEL_HZ=60 PANEL_STATE=on LHBM_FIRST=0$' lib/omamobile-fp-chroot >/dev/null || + fail "cheetah's panel rate, state and circle order" +grep -c 'PANEL=1080x2424 PANEL_HZ=120 PANEL_STATE="On: 1080x2424@120" LHBM_FIRST=1$' lib/omamobile-fp-chroot >/dev/null || + fail "tegu's panel rate, state and circle order" +grep -c -- '--lhbm-first "\$LHBM_FIRST"' lib/omamobile-fp-chroot >/dev/null || fail "the runner passes the circle order" +# Under set -u, each phone's case sets every value the spawn line uses. +cases=$(sed -n '/^case \$DEVICE in/,/^esac/p' lib/omamobile-fp-chroot) +for d in cheetah tegu; do + DEVICE=$d bash -uc "$cases"' + [[ -n $PANEL && -n $PANEL_HZ && -n $PANEL_STATE && -n $LHBM_FIRST ]]' || + fail "$d: the case leaves a panel value unset" +done grep -c '^ro.hardware=tegu$' lib/props-tegu.conf >/dev/null || fail "props-tegu.conf" grep -c '^ro.hardware=cheetah$' lib/props-cheetah.conf >/dev/null || fail "props-cheetah.conf" grep -c '^ro.hardware=' lib/props.conf >/dev/null && fail "props.conf keeps a phone's ro.hardware"