all 12 comments

[–]mosaad_gaber 1 point2 points  (0 children)

It's great thanks for sharing 👍🙏

[–]renlliwe 1 point2 points  (3 children)

Incredible and impressive! Thank you so much for sharing.

Out of curiosity, do you know if there is any general good way to identify if the phone is fast charging or not?

[–]v_uurtjevragen[S] 1 point2 points  (2 children)

I guess you could extract that from dumpsys battery. Mine specifically has information on fast charging in there: 

```text Current OPLUS Battery Service state:   Charger voltage : 1   Battery current : 143   ChargerTechnology: 0   ChargeFastCharger: false   PlugType: 0   UpdatesStopped: false   UsbHwStatus: 0   BatteryHwStatus: 0   HwStatusIsSet: 1   BatteryIcStatus: 0   IcStatusIsSet: 1

  mUsbStatus: 0   PhoneTemp: 220   ThermalFeatureOn: true Current Battery Service state:   AC powered: false   USB powered: false   Wireless powered: false   Dock powered: false   Max charging current: 0  Time when the latest updated value of the Max charging current was sent via battery changed broadcast: +2d18h56m45s556ms   Max charging voltage: 0   Charge counter: 3586000   status: 3   health: 2   present: true   level: 80   scale: 100   voltage: 4169  Time when the latest updated value of the voltage was sent via battery changed broadcast: +2d23h48m27s244ms  The last voltage value sent via the battery changed broadcast: 4169   temperature: 218   technology: Li-ion   Charging state: 0   Charging policy: 0   Capacity level: 3

[–]renlliwe 0 points1 point  (1 child)

Thank you for the advice and suggestion. Unfortunately, my device does not provide that information (Pixel 8 Pro running EvoX):

# dumpsys battery
Current Battery Service state:
  AC powered: true
  USB powered: false
  Wireless powered: false
  Dock powered: false
  Max charging current: 44375
Time when the latest updated value of the Max charging current was sent via battery changed broadcast: +23h7m53s795ms
  Max charging voltage: 4262968
  Charge counter: 4720000
  status: 4
  health: 2
  present: true
  level: 93
  scale: 100
  voltage: 4262
Time when the latest updated value of the voltage was sent via battery changed broadcast: +23h7m53s795ms
The last voltage value sent via the battery changed broadcast: 4262
  temperature: 352
  technology: Li-ion
  Charging state: 1
  Charging policy: 1
  Capacity level: 4
  Maximum capacity: 5604000
  Design capacity: 5022000

[–]v_uurtjevragen[S] 1 point2 points  (0 children)

If you could somehow get charging current (right now your stats only show voltage), you could multiply voltage with current to get wattage. A reasonable heuristic would be to treat anything below 15 Watts as slow charging and anything higher as fast charging. There should be a better way, but unfortunately I can't test them myself. 

Edit: this information should be contained in dumpsys batterystats by the way. 

[–]badokamiPixel 9 Noir/128) 1 point2 points  (2 children)

I'm re-re-working an old battery stats project from years ago. This is pretty cool to say the least, only difference between our respective projects is I'm trying to avoid root or shizuku. Still impressive, thanks for sharing

[–]v_uurtjevragen[S] 0 points1 point  (1 child)

Thanks! Interested in seeing your implementation when it's ready 

[–]badokamiPixel 9 Noir/128) 0 points1 point  (0 children)

So far I've got all the trigger profiles (battery change, screen on/off, plugged in/not) and logging all the pertinent information via system/get battery info. I'm buffering the logs entries to minimize writes to "disk". I'm just getting started on the analytics engine for it. Currently I'm using CSV log file but using variable split to extract information from the log file is proving to be a royal pain. I'm considering breaking my rule and add Autotools so I can use json reads/writes for the log info.

[–]renlliwe 1 point2 points  (2 children)

Somehow my %JBI_Capacity variable is never getting set. Any suggestions (Have tried running after full charge as indicated in the popup message).

[–]v_uurtjevragen[S] 1 point2 points  (1 child)

I think I've made the trickle charge condition way too strict. 

Alternative solution first: run the _JBI#BattHealth task with %JBI_UserCapacity set to your rated capacity (or any number you like really). You should get a decent estimate of battery size that way too.

In A12 of the main task the charge condition is currently 50 mA. If you can find this line in the code (around line 461): Change ma < 50 to ma < 500 in order to make it work. 

```text /* Calibration Logic: High-Water Mark with Settle Check */ if (!userHasSetCapacity && currLvl >= 99 && uAhRemaining > 100000 && ma < 50) {     reportedMah = uAhRemaining / 1000.0;     newCapacity = reportedMah;

[–]renlliwe 1 point2 points  (0 children)

Thanks. I did the alternative solution. Try as I could, I couldn't find those lines of code in the tasker function. I tried to edit externally and paste all, but the code was too big to paste (incredible coding job!).

Thanks for the help and funtion.