Fix battery time estimates showing thousands of hours on phones that report current in mA (#820)

fix: read battery current reported in mA so time estimates aren't 1000x too long
This commit is contained in:
Muaz Kadan authored and GitHub committed 2026-10-14 13:51:51 -04:00
1 parent 422429d63f
commit ce444fbacb
2 files changed
+17 -2

No files matched your search

@@ -41,6 +41,14 @@ class BatteryComponentTest {
assertTelemetry(supplies, vpower)
}
@Test fun vendorsReportingMilliampsGetTheSameEstimatesAsMicroamps() {
val supplies = tmp.newFolder("power_supply")
val vpower = tmp.newFolder("vpower")
start(supplies, vpower, -2_000L)
assertTelemetry(supplies, vpower)
assertEquals("-2000000", File(supplies, "BAT1/current_now").readText().trim())
}
private fun start(supplies: File, vpower: File, currentUa: Long) {
val context = RuntimeEnvironment.getApplication()
context.sendStickyBroadcast(Intent(Intent.ACTION_BATTERY_CHANGED).apply {