You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Battery current is 1000× too small on OnePlus (phone gives mA, not µA) #9
Found while testing the MVP (#2, PR #7) on a OnePlus Nord CE 2 Lite (CPH2409, OxygenOS, Android 12) on 2026-11-13.
What is wrong
device.battery.current is 1000 times too small on this phone, and the sign is the other way.
The phone was charging at about 1.5 A. The OnePlus battery service (dumpsys battery, "Current OPLUS Battery Service state") showed Battery current : -1508 (mA).
The app sent device.battery.current = -0.002 A. It should be about 1.5 A in size.
Android says BatteryManager.BATTERY_PROPERTY_CURRENT_NOW is in microamperes, positive while charging. This OnePlus gives milliamperes, negative while charging. BatteryCollector treats the value as microamperes (currentMicroA), so the value is divided by 1000 once too often.
Other phones may do the same: the unit and the sign are not the same on all phones.
What to do
Add a config key for the unit of the raw value: auto (default), uA or mA. Then a wrong guess can be fixed without a new build. Issue Remote config: Android managed configurations and OpAMP #3 will add the same key to managed configurations and OpAMP.
auto: choose the unit so that a small real current is never read as a huge one. For example, check how fast BATTERY_PROPERTY_CHARGE_COUNTER changes over time, or use the maker (Build.MANUFACTURER) for phones known to give mA. Document the rule.
Keep the sign as the phone gives it (the README already says the sign differs), or add a sign key too. Say in the README which one you chose.
Done when
The unit key exists (auto, uA, mA), with auto as default, and it is in the README config table.
The key is read from the config file and from the adb import. A wrong value is rejected, like a wrong wake_policy.
On a OnePlus phone that gives mA, device.battery.current is about 1.5 A in size (not 0.0015 A) while it charges at 1.5 A, with the default config. The check is recorded in this issue or in the PR.
On the emulator (which gives µA), the value does not change from today.
Unit tests cover the unit choice.
The README row for device.battery.current says how the unit is chosen, how to override it, and which sign is used.
Queued for work on 2026-11-13. It starts after #2 is merged, because the fix changes code from that PR. The OnePlus check in "Done when" needs a real phone, so it stays open for the owner.
Done in #10 (merged 2026-11-15), except the OnePlus check, which needs a real phone.
Unit key collectors.battery.current_unit (auto, uA, mA), default auto, in the README config table: Battery current: unit key auto/uA/mA (#9) #10, ConfigLoader.DEFAULTS_JSON, README "Config" table.
Read from the config file and from the adb import (both use ConfigLoader.load); a wrong value is rejected like a wrong wake_policy: test ConfigLoaderTest.batteryCurrentUnitValues, and on the emulator the adb import of "bogus" answered error: collectors > battery > current_unit: must be one of auto, uA, mA.
OnePlus check, for @groupsky: on the OnePlus Nord CE 2 Lite, install the build from main, keep the default config (no current_unit), charge at about 1.5 A (dumpsys battery shows Battery current : -1508 or so). device.battery.current should be about -1.5 (size 1.5 A; the sign stays as the phone gives it), not -0.0015. If it is wrong, set "current_unit": "mA" and tell what Build.MANUFACTURER the phone gives.
Unit tests: CollectorMappingTest.batteryCurrentUnitChoice and batteryCurrentInMilliAmps.
README row for device.battery.current and the new section "Battery current unit": how the unit is chosen, how to override it, and that the sign is kept.
The auto rule: a raw value of 50000 or more is µA; else mA for OnePlus, OPPO and realme; else µA. Left open with the label question only for the phone check. When it is done, please write the result here, remove the label and close.
Activity
groupsky commentedon Nov 13, 2026
Queued for work on 2026-11-13. It starts after #2 is merged, because the fix changes code from that PR. The OnePlus check in "Done when" needs a real phone, so it stays open for the owner.
Battery current auto rule: µA cut at 50000, not 10000 (#9)
Battery current: unit key auto/uA/mA (#9) (#10)
groupsky commentedon Nov 15, 2026
Done in #10 (merged 2026-11-15), except the OnePlus check, which needs a real phone.
collectors.battery.current_unit(auto,uA,mA), defaultauto, in the README config table: Battery current: unit key auto/uA/mA (#9) #10,ConfigLoader.DEFAULTS_JSON, README "Config" table.ConfigLoader.load); a wrong value is rejected like a wrongwake_policy: testConfigLoaderTest.batteryCurrentUnitValues, and on the emulator the adb import of"bogus"answerederror: collectors > battery > current_unit: must be one of auto, uA, mA.main, keep the default config (nocurrent_unit), charge at about 1.5 A (dumpsys batteryshowsBattery current : -1508or so).device.battery.currentshould be about -1.5 (size 1.5 A; the sign stays as the phone gives it), not -0.0015. If it is wrong, set"current_unit": "mA"and tell whatBuild.MANUFACTURERthe phone gives.CollectorMappingTest.batteryCurrentUnitChoiceandbatteryCurrentInMilliAmps.device.battery.currentand the new section "Battery current unit": how the unit is chosen, how to override it, and that the sign is kept.The
autorule: a raw value of 50000 or more is µA; else mA for OnePlus, OPPO and realme; else µA. Left open with the labelquestiononly for the phone check. When it is done, please write the result here, remove the label and close.