Repository navigation
Battery current: unit key auto/uA/mA (#9) - #10
Merged
Merged
Conversation
Some phones (OnePlus) give BATTERY_PROPERTY_CURRENT_NOW in mA, not uA. New key collectors.battery.current_unit; auto reads uA for values too large to be mA, mA for OnePlus/OPPO/realme, else uA. The sign is kept.
Fast charging (150-240 W) can go above 10 A on the mA makers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #9
Adds
collectors.battery.current_unit(auto,uA,mA; defaultauto) for the rawBATTERY_PROPERTY_CURRENT_NOWvalue.Choices
Build.MANUFACTUREROnePlus, OPPO or realme (one shared battery service); else µA as Android says. No new state on disk, no wait for a second reading.collectors.battery, next to the other battery settings. The config file and the adb import both go throughConfigLoader, so a wrong value rejects the import like a wrongwake_policy.Progress
auto,uA,mA), withautoas default, and it is in the README config table.wake_policy.device.battery.currentis about 1.5 A in size while it charges at 1.5 A, with the default config. Needs a real phone: for Geno.device.battery.currentsays how the unit is chosen, how to override it, and which sign is used.Emulator test (2026-11-15)
Emulator: Android 15, API 35, x86_64 (AOSP image,
device.manufacturer=unknown). Receiver: a throw-away VictoriaMetrics container on 127.0.0.1, removed after.BATTERY_PROPERTY_CURRENT_NOW(service call batteryproperties 1 i32 2):0x000dbba0= 900000 µA. The emulator console cannot set another current.device.battery.currentwith the default (auto): 0.9 (same as before this change: 900000 µA / 1e6)."current_unit": "mA": 900 (1000× bigger, as expected)."uA": 0.9 again."current_unit": "bogus"by adb broadcast:result=0, data="error: collectors > battery > current_unit: must be one of auto, uA, mA"; the config in use stayed.For Geno: the OnePlus check
On the OnePlus Nord CE 2 Lite, with the default config (no
current_unit), while it charges 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.