Skip to content

fix(android): head gestures don't answer or decline calls - #821

Open
Jeremy0538 wants to merge 1 commit into
librepods-org:mainfrom
Jeremy0538:fix/head-gestures-during-calls
Open

Jeremy0538 wants to merge 1 commit into
librepods-org:mainfrom
Jeremy0538:fix/head-gestures-during-calls

Conversation

@Jeremy0538

Copy link
Copy Markdown

Problem

Nodding or shaking the head works on the head gestures test screen, but not on a real incoming call: the detector runs for the whole ring and never reports "yes" or "no".

While a call is ringing, the AirPods send head-tracking data at about 5 Hz (one sample every ~200 ms) instead of about 25 Hz. At that rate consecutive samples land on opposite sides of a nod. applySmoothing() averages the last three, which cancels the motion out, so no value ever passes peakThreshold (400) and no extremes are counted.

Fix

GestureDetector.processHeadOrientation(): when samples arrive more than 100 ms apart, feed the raw values to peak detection instead of the 3-sample average. Fast data (the test screen, ~25 Hz) is smoothed exactly as before.

Evidence

With temporary logging of the raw values and the extreme counts:

  • Test screen: ~27 samples/s, a smooth curve (v=37, 19, 12, 22, 115, 283, 316, 267, 177, 20, -178), then "Yes" Gesture Detected (confidence: 0.8, extremes: 4/4).
  • Incoming call, before: ~5 samples/s, alternating every sample (v=419, -927, 461, 486, -1290, 639), with extremes v=0+0 for the whole ring and no detection.
  • Incoming call, after: nodding answers the call and shaking declines it.

Tested on a Samsung Galaxy S26 Ultra running One UI 9 / Android 17 (unrooted, FOSS debug build) with AirPods Pro (A3064). Not tested on other devices or AirPods models.

Side note, not changed here: these AirPods sent no head-tracking data at all with use_alternate_head_tracking_packets on (the default since #176). They only started after it was turned off.

These changes were written with AI assistance (Claude Code) and debugged against logcat captures from the device above.

🤖 Generated with Claude Code

While a call is ringing the AirPods send head tracking at ~5 Hz instead
of ~25 Hz. At that rate consecutive samples fall on opposite sides of a
nod, so the 3-sample moving average cancels the motion and no peak ever
passes peakThreshold: calls could not be answered or declined by nodding
or shaking. Feed raw values to peak detection when samples arrive more
than 100 ms apart; fast data is smoothed as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant