Skip to content

🟡 Flag unreliable battery readings — "Unknown" capacity on home, warning on insights (#94)#95

Merged
almothafar merged 3 commits into
masterfrom
feat/94-unreliable-health
Jul 6, 2026
Merged

🟡 Flag unreliable battery readings — "Unknown" capacity on home, warning on insights (#94)#95
almothafar merged 3 commits into
masterfrom
feat/94-unreliable-health

Conversation

@almothafar

@almothafar almothafar commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What

On devices whose charge counter is unreliable — notably certain Kirin/HiSilicon chipsets that report a small fixed µAh regardless of actual capacity — the home screen showed a bogus Capacity (e.g. 855 mAh) and the insights screen a bogus health figure (e.g. 21% on a healthy 4000 mAh battery).

This flags those readings honestly, in the right place on each screen:

  • Home (Battery details): the Capacity row shows "Unknown" + a tappable amber instead of the misleading mAh number.
  • Insights (Battery health): keeps showing the real health number + grade (reverted from an earlier "Unknown" approach), but adds a tappable amber next to it when the reading can't be trusted.
  • Both affordances open the same dialog, which explains the likely cause (a hardware/counter quirk) and the genuine edge case that the battery may be wearing out — shutdowns under load, the level collapsing near the bottom (20% behaving like 2%), faster drain — with a "consider replacing" nudge.

How

  • BatteryHealthTracker.isBatteryReadingUnreliable(context) — shared by both screens — flags when the current-full-capacity estimate falls outside 40%–115% of the user-entered design capacity, backed by a pure, unit-tested isEstimateImplausible(currentFullMah, designMah) helper. (Home batteryDO.getCapacity() and insights health both derive from the same getBatteryCapacity() estimate, so the two screens always agree.)
  • BatteryDetailsFragment: the capacity value cell gets a compound info icon + click → dialog, only when unreliable.
  • BatteryInsightsActivity: updateHealthData() always renders the resolved figure; toggles the warning icon on/off by the same check.
  • New ic_warning_amber (insights) + existing ic_info_amber (home); generic battery_reading_unreliable_* strings, EN + Arabic drafts (pending maintainer review).

Notes

  • The 40% floor means a genuinely worn battery reading below 40% is also flagged — the honest outcome, since we can't reliably distinguish a broken counter from a dying cell.
  • A healthy counter reports ≈ design at every charge level, so healthy devices never trip this.
  • Because the detection reads the live estimate, on this fixed-µAh phone it only reads implausible above ~44% charge — best tested with the battery above ~50%.
  • Unit tests cover the helper (incl. the real 852-vs-4000 device case); testDebugUnitTest + assembleDebug green; installed on the Mate 10 Pro.

Closes #94

almothafar and others added 2 commits July 6, 2026 02:42
Some devices (notably certain Kirin/HiSilicon chipsets) report a charge
counter that bears no relation to the real capacity, so the measured
health came out as an absurd figure (e.g. 21% on a healthy 4000 mAh
battery). Cross-check the current-full-capacity estimate against the
user-entered design capacity and, when it lands outside a plausible
window (40%-115% of design), show an explicit "Unknown" state with a
tappable amber info icon instead of a misleading number.

The info dialog explains the likely cause (a hardware/counter quirk) and
also flags the genuine edge case that the battery may be wearing out,
with signs to watch for (shutdowns under load, the level collapsing near
the bottom, faster drain).

- BatteryHealthTracker.isMeasuredHealthUnreliable() + pure, unit-tested
  isEstimateImplausible() helper
- BatteryInsightsActivity: split health rendering into resolved vs.
  unreliable states; amber "?" + "Unknown" + info dialog
- New ic_info_amber vector; EN strings + Arabic drafts (pending review)

Closes #94

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The unreliable-reading case belongs on the home screen's Capacity value
(the misleading "855 mAh"), not on the insights health figure. Per review:

- Home: the Capacity row now shows "Unknown" with a tappable amber info
  icon when the reading can't be trusted; the dialog explains why.
- Insights: reverted to showing the real health number + grade; when the
  reading is unreliable it keeps the figure but adds a tappable amber
  warning icon that opens the same explanation.
- Rename isMeasuredHealthUnreliable() -> isBatteryReadingUnreliable(), now
  shared by both screens (same getBatteryCapacity-vs-design check).
- Generic battery_reading_unreliable_* strings (EN + Arabic drafts); new
  ic_warning_amber; drop the now-unused health_unreliable_* strings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@almothafar almothafar changed the title 🟡 Show "Unknown" battery health when the charge gauge is unreliable (#94) 🟡 Flag unreliable battery readings — "Unknown" capacity on home, warning on insights (#94) Jul 6, 2026
Review follow-ups on #94:

- Use the same amber warning icon on both screens (home Capacity row now
  matches the insights health figure); drop the now-unused ic_info_amber.
- Grammar pass on the Arabic dialog copy (maintainer review): "رغم وجود
  شحن كافٍ", "لا تُطابق", "بصورة غير صحيحة", drop redundant trailing phrase,
  reword the 20%/2% line.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@almothafar almothafar merged commit a92c7cc into master Jul 6, 2026
2 checks passed
@almothafar almothafar deleted the feat/94-unreliable-health branch July 6, 2026 21:33
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.

Battery health: show 'Unknown' + tappable info when the charge gauge is unreliable (vs design capacity)

1 participant