App doesn't detect actual power drain, shows 0.0W
Closed this issue · 22 comments
The app doesn't work properly on my Samsung Galaxy A52s 5G (Android 12, OneUI 4) and just shows an amperage and wattage of 0.0 all the time. I suspect it has something to do with a Samsung quirk, that gives milliampere instead of microampere. One way to solve this might be to check whether the suspected "milliampere" (probably ampere on Samsung phones) are actually bigger than, for example, 5"mA" and to not divide by 1000 again if that isn't the case (I have yet to see a phone that uses 20W or 20mW).
Then again, I'm not 100% sure whether this is a Samsung quirk, but the logs show nothing suspicious.
@Pokemetti you can use this > https://github.com/Anonymous2716/Amp/releases
to view that. For temporary use. Not sure if it will work.
What is that supposed to be? The apk doesn't even install.
@Pokemetti okay. I added the screenshots . check the app-2.apk . if it doesn't work then it won't.
What I'm asking you to do is to add one small conditionto the app, that apk is a totally different app with like no size at all (3.6kB classes.dex).
@Pokemetti Yeah you can check the java code.its small compiled without IDE just on termianl.tested on my phone (android 9). Actually first time wrote an app for fun and following this repository .can you please elaborate "condition"?
On S22 Ultra it won't show the watts as well.
I opened a pull request for the changes, have no idea whether they work since I have never even looked at Kotlin, so this is only based on my knowledge in Python and C.
Thanks for the issue report and input, everyone. A friend of mine has an S10. I'll see if I can reproduce it there, probably tomorrow morning. If it's just reporting incorrect units, something like @Pokemetti's PR could work. A quick Google search seems to indicate Samsung may be reporting mA instead of uA, as specified by the API docs: https://forum.developer.samsung.com/t/charging-current-battery-property-current-now/13517/3. From that thread, it seems like BATTERY_PROPERTY_CHARGE_COUNTER
(also used in this app) might also be affected.
Interestingly, home-assistant/android#2846 seems to suggest that some devices also report current in nA as well...
So I reproduced the issue for battery current on an S10, but charge level looks correct. Is anyone here also seeing an incorrect value for charge level? It should be somewhere in the single digit Ah range.
I published a new release which should work around this issue by dynamically detecting battery current units here: https://github.com/dubrowgn/wattz/releases/tag/v1.5. I'm going to close this issue as resolved, but please let me know if you continue to experience any problems.
@PrototypeGR I can reproduce that as well on the S10 I have, and it seems like yet another Samsung bug. Instead of returning -1
to indicate "no value" as in the spec, it's returning 0
. I should be able to work around it fairly easily though by checking if the device is charging first.
Actually, it looks like it's always reporting false
for isCharging
as well. Their BatteryManager
implementation sure is a wreck...
Works fine on my device, thanks!
I have a pair of work arounds which should address the remaining two issues on Samsung devices, but I'm waiting on a device to test it. Hopefully, I'll have a new build up later today.
@PrototypeGR can you try v1.6? All three issues seem to be fixed on the S10 I have.
They are definitely fixed on my device thanks!
The app reports power draw. A negative sign is intentional, and indicates negative power draw from the battery.