Device: Show Optimized Charging status, add Pro 3 toggle#545
Merged
Conversation
Adds a per-battery 'Optimized' chip on the overview card when pods report wire value 0x05 (CHARGING_OPTIMIZED), which was already decoded but collapsed into a plain 'Charging' in the UI. On AirPods Pro 3, also adds a user-facing toggle for the device-side Optimized Charge Limit (AAP setting 0x3B). - Decode setting 0x3B via decodeAppleBool so unknown values fall through instead of coercing to false - Bypass ear-detection queue for SetDynamicEndOfCharge so the toggle works while pods sit in the closed case - Expose per-slot ChargingState? on PodDevice; StatusChipRow renders 'Optimized' for CHARGING_OPTIMIZED, 'Charging' for CHARGING - New BatteryCard in device settings with experimental warning (pattern matches Sleep Detection) - Generic settingRejectedEvents flow alongside the existing offRejectedEvents so the toggle can show a dedicated snackbar on verification failure
Verified on a real AirPods Pro 3: toggling flips pod charging state from CHARGING_OPTIMIZED to CHARGING and persists across reconnects. Apple-bool wire format is confirmed, so the 'experimental' warning box is no longer warranted.
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.
What changed
When your AirPods pause charging around 80% as part of Apple's Optimized Battery Charging, the overview card now shows an Optimized chip next to the affected battery instead of the generic "Charging" one — so you know why the percentage isn't climbing. On AirPods Pro 3, a new Battery section in device settings lets you toggle Apple's Optimized Charge Limit on or off, matching what iOS exposes for those pods.
Technical Context
CHARGING_OPTIMIZEDwire value (0x05) that the AAP battery notification already carries — it was being collapsed into a plainisCharging = truebefore.StatusChipRownow takes anAapPodState.ChargingState?and picks the chip from that. It self-gates via the wire value: models that never emit0x05never show the chip, so Pro 2 USB-C users get the indicator for free even though the toggle doesn't apply to them.Features.hasDynamicEndOfChargeflag, currently enabled only on Pro 3 where setting0x3Bhas been observed on the initial settings burst. Decoder usesdecodeAppleBoolso unknown byte values fall through to the unhandled-setting log path instead of silently becomingfalse.SetDynamicEndOfChargebypasses the ear-detection send queue (same carve-out asSetDeviceName). Without this the toggle would silently queue while pods sit in the closed case, which is the exact context a user would be in when flipping it.settingRejectedEventsflow onAapConnectionManageralongside the existingoffRejectedEvents, so future setting-write failures can surface their own snackbar. The ViewModel filters forSetDynamicEndOfChargeand shows a dedicated message when verification fails.0x3Bwire format is an educated guess matching the Apple-bool convention every other boolean setting uses. Verified end-to-end on a real Pro 3 — toggling off visibly flips the battery wire state fromCHARGING_OPTIMIZEDback to plainCHARGING. The UI marks the feature experimental (warning below the toggle when enabled, matching Sleep Detection).Review checklist
StatusChipRowOptimizedPreview,BatteryCardEnabledPreview,BatteryCardDisabledPreview