fix(ble): Handle scan registration failure#6019
Merged
jamesarich merged 2 commits intoJun 30, 2026
Merged
Conversation
Android reports BLE scan-start registration failure (SCAN_FAILED_APPLICATION_REGISTRATION_FAILED) via Kable as an IllegalStateException whose message contains 'app cannot be registered'. Add a typed BleScanStartException wrapper with a bounded cause-chain walker that detects this pattern. Unrelated IllegalStateExceptions pass through unchanged.
Catch BleScanStartException in startBleScan: clear scanning state, disable auto-scan, start a 15-second retry cooldown with generation- guarded try/finally, and surface a user-facing warning. Uses safeCatchingAll for the error string lookup because compose-resources can throw ExceptionInInitializerError before the resource system is ready (e.g. in unit tests).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughIntroduces ChangesBLE Scan Start Failure Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request handles an Android BLE scan startup failure observed in field logs.
In that failure path, Android rejected BLE scanner registration with
SCAN_FAILED_APPLICATION_REGISTRATION_FAILED. That means the discovery scan never actually started: there were no advertisements to wait for and no device-discovery result to recover from. The adapter was enabled and there was no permission exception, but Android reported that the app could not be registered for scanning.Before this change, that failure escaped from the scan coroutine as a generic
[startBleScan]unhandled exception. The scan state reset, and the app could immediately try again, creating repeated scanner-registration failures without a useful recovery message.This change makes that scan-start failure explicit: the app classifies it near the scanner adapter, clears scan state, disables immediate BLE auto-scan retry, shows a recovery warning, and allows manual retry after a short cooldown.
Key Changes
BleScanStartException.[startBleScan]unhandled exception.Testing
IllegalStateExceptionfailures are preserved.stopBleScan()remains idempotent after failed startup.Migration Notes
Summary by CodeRabbit
New Features
Bug Fixes