Skip to content

Kirin CURRENT_NOW misread: display floor for current + plausibility floor for charge power (#152 v1)#169

Merged
almothafar merged 2 commits into
masterfrom
fix/152-kirin-current-floors-v1
Jul 17, 2026
Merged

Kirin CURRENT_NOW misread: display floor for current + plausibility floor for charge power (#152 v1)#169
almothafar merged 2 commits into
masterfrom
fix/152-kirin-current-floors-v1

Conversation

@almothafar

@almothafar almothafar commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Fixes the user-visible fallout of the Kirin/HiSilicon CURRENT_NOW unit bug (#152): the fuel gauge reports mA instead of µA, so real readings arrive 1000× too small and slipped through every gate that only guarded against too-large values.

v1a — current display floor (BatteryRateTracker)

  • New MIN_DISPLAY_CURRENT_MA = 10; the hasCurrent gate in computeRate now requires the rounded magnitude to reach it (was >= 1).
  • Kills "Discharging −1 mA" / "+1 mA" on both surfaces (ongoing notification's mA fallback and the details table) — the misread values cap out at ~1–3 "mA".
  • On genuine-µA devices, sub-10 mA draw only happens in deep sleep; nothing informative is lost.

v1b — charge power plausibility floor (ChargeSpeed)

Tests

  • Boundary tests at the display floor (9.4 mA hidden / 9.5 mA shown) plus the Kirin raw −800 case with the level-over-time rate still shown.
  • Boundary tests at the power floor (99 mW unknown / 100 mW known) plus the Kirin ~3.8 mW case end-to-end through fromMeasurements.
  • ./gradlew :app:testDebugUnitTest and :app:lintDebug pass.

On-device verification (Mate 10 Pro)

  • No ±1/±2 mA in the notification or the table across several plug/unplug cycles (per the 2026-07-16 field observation, check both surfaces)
  • Notification falls back to the plain status label during warm-up
  • No "Charging slowly" warning during a normal wired charge

v2 (unit auto-calibration, showing the real current on Kirin) follows as a stacked PR.

Part of #152 — v1 of the two-stage fix; the stacked v2 PR closes it.

🤖 Generated with Claude Code

almothafar and others added 2 commits July 17, 2026 03:31
Kirin/HiSilicon reports CURRENT_NOW in mA instead of uA, so a real
~800 mA draw arrives as raw -800 and displayed as a nonsense
"Discharging -1 mA" in the ongoing notification (and intermittently
in the details table). Require the displayed current to round to at
least MIN_DISPLAY_CURRENT_MA (10): the misread values cap out at
~1-3 "mA" and disappear, while on genuine-uA devices a sub-10 mA
draw only happens in deep sleep, where nothing is being read anyway.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The same Kirin mA-unit misread flows into ChargeSpeed.powerMilliwatts
(uA x mV / 1e6): a raw ~1000 while fast charging yields ~3-4 mW, which
passed the > 0 check and classified as a known Trickle tier. That
mislabeled the charge-connected announcement and the notification's
charging segment as "Slow charging" (#125), and made SlowChargeDetector
(#123) fire a false "check the cable and port" warning on every wired
charge below 80%.

A phone that reports CHARGING is never genuinely taking in under
~0.1 W, so add MIN_PLAUSIBLE_MW (100) as the mirror of the existing
MAX_PLAUSIBLE_MW guard. Unknown power makes the tier displays fall
back to the plain label and keeps the slow-charge detector asleep
(its powerKnown gate).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@almothafar
almothafar merged commit ab6da69 into master Jul 17, 2026
2 checks passed
@almothafar
almothafar deleted the fix/152-kirin-current-floors-v1 branch July 17, 2026 12:50
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