Skip to content

Battery current is 1000× too small on OnePlus (phone gives mA, not µA) #9

Open

Description

@groupsky

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.

Activity

  1. groupsky commented on Nov 13, 2026

    @groupsky
    ContributorAuthor

    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.

  2. groupsky commented on Nov 15, 2026

    @groupsky
    ContributorAuthor

    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.
    • Emulator unchanged: raw 900000 µA gives 0.9 A with the default, as before (PR Battery current: unit key auto/uA/mA (#9) #10, "Emulator test").
    • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions