Skip to content

Fix HAS read presets requests failing after an out of range request - #1015

Merged
zxzxwu merged 1 commit into
google:mainfrom
kwy404:fix-hap-read-presets-in-progress
Oct 22, 2026
Merged

zxzxwu merged 1 commit into
google:mainfrom
kwy404:fix-hap-read-presets-in-progress

Conversation

@kwy404

@kwy404 kwy404 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Root cause: HearingAccessService._on_read_presets_request (bumble/profiles/hap.py) sets read_presets_request_in_progress = True before it validates the request. When the request is rejected with OUT_OF_RANGE (StartIndex 0, NumPresets 0, or no preset at or after StartIndex), the flag is never cleared, because only _read_preset_response resets it and that coroutine is never spawned. From then on every Read Presets Request, and every Write Preset Name which checks the same flag, fails with PROCEDURE_ALREADY_IN_PROGRESS, for all clients and across reconnections:

# Read Presets Request with StartIndex 0 -> OUT_OF_RANGE (expected)
await control_point.write_value(bytes([0x01, 0, 1]), with_response=True)
# valid Read Presets Request -> PROCEDURE_ALREADY_IN_PROGRESS
await control_point.write_value(bytes([0x01, 1, 1]), with_response=True)

Fix: set the flag right before spawning _read_preset_response, after all the checks pass. The busy check stays at the top, so a second request while a response is still being indicated is rejected as before.

Test: added test_read_presets_after_out_of_range_request to tests/profiles/hap_test.py. It sends a request with StartIndex 0, then a valid one, and expects the first preset to be indicated. Before the fix the second write fails with PROCEDURE_ALREADY_IN_PROGRESS, after the fix it passes. pytest tests/profiles/hap_test.py, ruff check and black -S --check pass.

@zxzxwu
zxzxwu merged commit 3550e0e into google:main Oct 22, 2026
34 checks passed
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