Skip to content

omamobile-keys: a double tap lights the display first, the lock's wake beside it - #745

Draft
Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:keys-dtap-1113
Draft

Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:keys-dtap-1113

Conversation

@Somnius

@Somnius Somnius commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@derekross, a small one from the Pixel 8 Pro: a double tap on the dark screen woke it, but it felt slow ("not like a normal phone"). The delay is in omamobile-keys double-tap, which ran its steps one after another. Timed one by one on the phone, three rounds: the locked check (omarchy-shell lock isLocked) 94 to 99 ms, the lock's own wake (omarchy-shell lock wake) 90 to 96 ms, and omarchy-brightness-display on, which includes the display modeset, 247 to 251 ms. The screen only started lighting when the last of them started, so with the script's own start and the small checks the display came on about 0.3 s after the call and the panel about 0.45 s.

The change: start the display first, in the background, run the locked check and the lock's wake beside it, wait for the display, and then do the brightness floor as before (it is now a function, brightness_floor, which wake_locked and wake_unlocked call too, the same four lines as before). Nothing about what is woken changes: a dark screen only, locked or not, no lock wake when unlocked.

Measured on my phone with a 4 ms poll of the DSI dpms file and the backlight's bl_power, the screen dark and locked, from the call to omamobile-keys double-tap until the display is on and until the panel is on, five runs each, alternating the old and the new script:

old: display on 298 to 342 ms (about 324), panel on 433 to 467 ms (about 452)
new: display on 127 to 161 ms (about 145), panel on 259 to 297 ms (about 278)

So about 180 ms earlier. That leaves out the doubletap daemon's own detection (it fires on the second tap's release) and its start of the script, and it was one phone, with the SoC at about 55 C and the sensor proxy not running, so the proximity guard added nothing.

I also counted display modesets per wake, since a second DPMS enable is what blanked the panel for a beat before: ten wakes on the phone, five with each script, and each had exactly one gs-decon mode line and the same sequence of the DSI dpms and bl_power states (Off/4, On/4, On/0), so the lock's own display-on call did not cause a second modeset in the new order.

Tests: test/keys.sh passes. The block's locked-check stand-in takes 0.1 s, as on the phone, so the order check doesn't depend on a race between two process starts. The new block uses a display stand-in that takes 0.4 s and logs its start and end, and checks that the lock's wake is logged between them (so it runs beside the display and not after it), that the handler still waits for the display, and that an unlocked tap still has no lock wake. I ran it against the old omamobile-keys and it fails on "the display starts before the lock's wake".

Not tested: how it looks. Running the lock's wake beside the display's modeset is the kind of ordering that gave the flash in #640, and I have only measured times, nobody has watched the screen on a double tap with this change yet, so I'm opening it as a draft and I'll look at it in the morning. The kernel and shell on that phone are the ones from #724 (the shell is 0.2.107 with my copy of this file patched the same way).

@derekross

Copy link
Copy Markdown
Owner

Thank you, @Somnius. The measurement is exactly what this needed: the three steps timed one by one, old and new alternated, and the modeset count to show the lock's own display-on doesn't cause a second one. 180 ms off a double tap is worth having.

Main moved under it, though, and in the same functions, so it needs rebuilding rather than a rebase. #577 (shell 0.2.133) gave omamobile-keys a second wake_locked: the first one is already "panel first, the lock's wake meanwhile", measured on the Pixel 7, and the old order is kept for every phone that hasn't set OMAMOBILE_POWER_KEY_ANDROID=1, which today includes my Pixel 7 Pro. So what your change still adds is the display started before the locked check, and the display-first order for the double tap on every phone. Before it leaves draft:

  1. Rebuild it on main's file. I'd keep it to the double-tap case and brightness_floor, and run test/keys.sh with the switch on and off, so it's clear what each phone gets. A plain rebase may apply your wake_locked hunk to the wrong one of the two definitions.
  2. Your own open point: has anyone watched it? You wrote that the lock's wake beside the modeset is the ordering that gave the flash in omamobile-keys: put the brightness back only after the panel is off #640. A few double taps on a dark, locked phone and a few unlocked, looking for a flash or a blank beat, and a line here with what you saw.
  3. A run of the rebuilt package on the 8 Pro with a tools/phone-smoke report. The timings so far came from a patched copy of the file inside shell 0.2.107, which is fine as a measurement of the idea but isn't this change on today's script.
  4. For the Pixel 7 Pro this is a new order. Say whether you'd like it behind the switch main already has or as the default for everyone; if the default, I'll run it on my 7 Pro before it merges.

One small thing on the test: the new order check depends on two sleeps (0.1 s and 0.4 s). keys.sh has had one timing flake already (#889), so if you can make the display stand-in wait on a FIFO that the test releases after it has seen the lock's wake, it won't depend on the runner's clock. I set the version at merge.

…roid switch

With OMAMOBILE_POWER_KEY_ANDROID=1, a double tap on a dark screen starts the
display first, in the background, and runs the locked check and the lock's
wake beside it, then waits for the display and puts the brightness floor
back. The display (about 0.25 s of modeset, then the panel's 0.13 s on the
Pixel 8 Pro) is the slow part, and neither call into the shell depends on it.

I put it behind the switch main already has rather than making it the
default, so phones without it (the Pixel 7 Pro today) keep the order they
have: the locked check, the lock's wake, then the display.

The brightness floor is now one function, brightness_floor, used by both
wake_locked definitions, wake_unlocked and the double tap.

test/keys.sh checks the double tap's order with the switch on and off. The
display stand-in waits on a FIFO that the test opens only after it has seen
the lock's wake (or the display's start when unlocked), and with the switch
on the locked check waits for the display's start, so the check doesn't
depend on sleeps or the runner's clock.
@Somnius

Somnius commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@derekross rebuilt on main's file instead of rebased, force-pushed as 34493b2:

  • Kept to the double-tap case and a new brightness_floor(). Both wake_locked definitions and wake_unlocked call it instead of repeating the same four lines; otherwise they're as on main.
  • Behind the switch main already has: with OMAMOBILE_POWER_KEY_ANDROID=1 the double tap starts the display in the background, runs the locked check and the lock's wake beside it, then waits for the display before the floor. Without the switch it's today's line, so your 7 Pro keeps its order. I'd rather it go default only after you've seen it on the 7 Pro.
  • test/keys.sh covers the switch on and off. The order check has no sleeps now: the display stand-in waits on a FIFO the test releases only after it has seen the lock's wake. The handler runs in its own process group, so a failure cleans up and fails in about 14 s instead of hanging. A wrong order fails with the switch on and with it off (checked by swapping the order). 20 runs, 10 with each, all pass. test/all and pr-check pass too.

Still to do, both on the phone: watching a few double taps on a dark, locked phone and unlocked for a flash or a blank beat, and a run of this package with tools/phone-smoke. It stays a draft until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants