Skip to content

FullCharge: Cancel a session only on a real native settings change - #65

Merged
d4rken merged 1 commit into
mainfrom
fix/session-native-change-guard
Aug 15, 2026
Merged

FullCharge: Cancel a session only on a real native settings change#65
d4rken merged 1 commit into
mainfrom
fix/session-native-change-guard

Conversation

@d4rken

@d4rken d4rken commented Aug 15, 2026

Copy link
Copy Markdown
Member

What changed

A temporary full-charge session could silently end mid-charge without restoring the protective policy: the battery then charged to 100% and protection stayed off until changed manually. Reported from the HyperOS 3 verification run in #48, where the session's cancel-on-native-change watcher fired on a settings notification that carried no actual value change. Sessions now end without restoring only when the charging setting really changed outside the app.

Technical Context

  • Root cause: the session service cancelled without restore on any change notification for the adapter's setting URIs. Settings notifications are dispatched asynchronously, so the session's own override write can be delivered after the observer registers, and the HyperOS provider can notify without a value change — either ends the session with the protective policy never re-written (evidence chain in #48: dashboard idle at 96% while the key monitor shows no value change after the override write).
  • NativeChangeGuard (pure, unit-tested) ignores a notification whose sync readback still decodes to the session's override policy; a different, unrecognized, or unreadable value cancels as before, and adapters without sync readback (Pixel) keep the blanket cancel.
  • A Shizuku readback timeout is TimeoutCancellationException, a CancellationException subclass — it is caught as "unreadable → cancel" rather than rethrown, which would silently drop the notification and keep a session alive past a genuine native change.
  • Accepted trade-off (documented in the KDoc): a native change that decodes to the same policy — re-selecting the identical value, or editing an auxiliary key the decoded policy ignores (Samsung threshold during a PauseAtFull override) — is indistinguishable from noise and keeps the session running.
  • The qualification ledger records the rest of the [Device support] Xiaomi 24117RN76G — settings discovery #48 beta run: absent key decodes as Intelligent (shipped assumption now confirmed), app-context three-mode control over direct WSS confirmed, cap fixed at 80%. Session-lifecycle re-verification on the next beta is the remaining ask.

The session service's native-change observer cancelled without
restoring on ANY notification for the adapter's setting URIs.
Notifications are dispatched asynchronously, so the session's own
override write can arrive after the observer registers, and an OEM
provider can notify without a value change — both observed on
HyperOS 3 tanzanite (issue #48), where the session ended mid-charge
and the protective policy was never restored.

NativeChangeGuard now verifies the change where the configuration is
synchronously readable: a readback still decoding to the session's
override policy is noise and keeps the session; a different, foreign,
or unreadable value cancels as before. Adapters without sync readback
(Pixel) keep the blanket cancel. A Shizuku readback timeout counts as
unreadable instead of silently dropping the notification.

Also records the tanzanite beta verification results in the
qualification ledger: absent key decodes as Intelligent (confirmed),
app-context three-mode control works over direct WSS, and the mode-2
cap is fixed at 80%.
@github-actions github-actions Bot added the enhancement New feature or request label Aug 15, 2026
@d4rken d4rken added bug Something isn't working ROM: HyperOS Xiaomi / Redmi / POCO and removed enhancement New feature or request labels Aug 15, 2026
@d4rken
d4rken merged commit 5039404 into main Aug 15, 2026
12 checks passed
@d4rken
d4rken deleted the fix/session-native-change-guard branch August 15, 2026 06:08
d4rken added a commit that referenced this pull request Aug 16, 2026
…71)

The 2026-08-14 beta run on the Redmi Note 14 (tanzanite) failed its
temporary-session check: the native-change observer cancelled on a
notification carrying no value change, so the device charged to 100%
with Battery protection never restored. That was fixed by
NativeChangeGuard (#65), which shipped in v0.3.4-beta0.

The contributor re-ran the session test on that build (issue #48): the
session reached 100% and Battery protection was re-written automatically
with the cable still connected. RESTORE_FULL therefore fires without a
disconnect, and the guard holds against the exact notification pattern
that produced the bug.

Ledger row and known-gaps bullet updated; the remaining unrun items on
this device are the disconnect-early restore, the Shizuku tier, boot
recovery, and an R8 smoke.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ROM: HyperOS Xiaomi / Redmi / POCO

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant