Skip to content

Dashboard: Show charging speed and wattage in more places - #55

Merged
d4rken merged 4 commits into
mainfrom
feat/wattage-display
Aug 13, 2026
Merged

Dashboard: Show charging speed and wattage in more places#55
d4rken merged 4 commits into
mainfrom
feat/wattage-display

Conversation

@d4rken

@d4rken d4rken commented Aug 12, 2026

Copy link
Copy Markdown
Member

What changed

  • The dashboard charging card now says how fast the charge is going: "Charging slowly", "Charging", "Charging fast", or "Charging very fast", based on the same measured wattage it already displays.
  • The Battery & charging screen gained two rows: the live charge power, and the maximum wattage the connected charger advertises ("Charger max"). When the battery is positively not taking charge (unplugged, held at a limit, full) the power row says "Not charging" instead of the misleading "Not reported".
  • The charge session screen shows a live "Power now" value alongside the existing peak and average, but only while viewing the session that is actually charging right now.

Technical Context

  • The speed buckets are AOSP SettingsLib's own thresholds (slow < 5 W, fast > 7.5 W) applied to the measured draw rather than the charger-advertised maximum the lock screen classifies. The label therefore always matches the wattage figure shown beside it and tapers honestly near full. The > 15 W "very fast" bucket is Amply-specific (2x the AOSP fast bar). Titles re-classify on each 3 s battery poll; boundary flicker is accepted rather than debounced.
  • BatteryManager.EXTRA_MAX_CHARGING_CURRENT/VOLTAGE are @hide, so BatteryReader reads the extras by their literal stable AOSP keys. Values at or below zero normalize to null ("no charger" rather than "a 0 W charger"), and a missing advertised voltage falls back to AOSP's assumed 5 V.
  • "Power now" is gated on the viewed session's id matching the boot-scoped live session, not just on the session being open: the detail query is unrestricted by-id, so a dangling open row from an earlier boot must not be attributed the current charge's wattage.
  • BatteryEffect moved (git mv) from the dashboard package to battery/ui: the hub and stats screens reuse its "Not charging" vs "Not reported" semantics, and stats/ui must not depend on dashboard presentation files. The power arithmetic lives as readout overloads on StatsPowerCalculator, which already owned the calculation.

d4rken added 4 commits August 12, 2026 15:04
The sticky battery broadcast carries EXTRA_MAX_CHARGING_CURRENT and
EXTRA_MAX_CHARGING_VOLTAGE: what the connected supply claims it can
deliver. Both land on BatteryReadout as nullable fields (absent or
non-positive normalizes to null: a device with nothing connected reports
0, which is "no charger", not "a 0 W charger").

StatsPowerCalculator gains advertisedMaxMilliwatts for that pair, with
AOSP BatteryStatus' 5 V fallback when only the current is reported, plus
readout-taking overloads so callers don't re-derive the charge-power
gate. The existing implausibility cap applies to the advertised figure
too.

Also adds the strings the upcoming wattage surfaces need.
The card headline said only "Charging" whatever the charger delivered.
It now classifies the measured draw into slowly / (plain) / fast / very
fast. The slow and fast bars are AOSP SettingsLib's own bucket values
(5 W / 7.5 W), applied to the measured draw rather than the
charger-advertised maximum AOSP classifies: the measurement is what the
battery actually receives and is the number printed one line below the
headline. The very-fast bar at 15 W is ours, twice the AOSP fast bar, so
modern 20 W+ chargers aren't all lumped in as merely "fast". A draw that
can't be measured keeps the plain title rather than guessing a speed.

BatteryEffect moves from main/ui/dashboard to battery/ui: its tri-state
"is the battery positively not charging" semantics are needed by the
battery hub and the session detail screen, which must not import a
dashboard presentation file. It gains chargePowerFallbackRes, the shared
rule for what to print in place of a withheld wattage.
The wattage was only ever visible in the dashboard card's reading line
and as a recorded peak/average. The battery hub's electrical section now
carries "Charge power" (the gated live figure, so a discharge draw can
never read as charge power) and "Charger max" (the supply's advertised
capability, read through only while something is connected).

The charge session detail gains a live "Power now" row, but only while
the viewed session is the open one the caller vouched for: the detail
query is by id and unrestricted, so it can resolve a dangling open row
from an earlier boot that the boot-scoped live query rejects. The
activity therefore attributes the readout only when the viewed id
equals the live session's id.

Both surfaces distinguish a withheld figure from a missing one: "Not
charging" where the battery positively reported it isn't taking charge,
"Not reported" everywhere else.
BatteryManager.EXTRA_MAX_CHARGING_CURRENT/VOLTAGE are @hide constants:
BatteryService puts both into ACTION_BATTERY_CHANGED, but the symbols
are absent from the public SDK's android.jar, so referencing them fails
to compile. The extras themselves are readable (only the constants are
missing), so the reader uses the stable AOSP string keys instead. No
reflection is involved.
@d4rken d4rken added the enhancement New feature or request label Aug 12, 2026
@d4rken
d4rken merged commit 5e9aaa0 into main Aug 13, 2026
12 checks passed
@d4rken
d4rken deleted the feat/wattage-display branch August 13, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant