Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions fingerprint/bridge/omamobile-fp-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -230,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. */
Expand Down Expand Up @@ -934,20 +937,41 @@ 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);
int64_t time = now_ms();
int64_t time;

if (down)
finger_since = time;
write_pointer(in, touch_x, touch_y, time, finger_since);
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) {
call_void(session, S_ON_POINTER_DOWN_WITH_CONTEXT, in, "onPointerDown");
lhbm(true);
if (lhbm_lit)
usleep(lhbm_settle_ms * 1000);
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");
Expand Down Expand Up @@ -1026,7 +1050,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)
{
Expand Down Expand Up @@ -1465,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);
}

Expand All @@ -1487,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"))
Expand Down
18 changes: 14 additions & 4 deletions packages/omamobile-fingerprint/lib/omamobile-fp-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ 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 ;;
# 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_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}
Expand Down Expand Up @@ -182,13 +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"
echo 60 > "$sys/devices/platform/exynos-drm/primary-panel/op_hz"
# 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 > "$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"
Expand Down Expand Up @@ -419,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

Expand Down
14 changes: 14 additions & 0 deletions packages/omamobile-fingerprint/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-fingerprint/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.10
0.1.11