okra pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=42d16a0ec1c367e2c89f42382a2df7ed7c465e93

commit 42d16a0ec1c367e2c89f42382a2df7ed7c465e93
Author: Stephen 'Okra' Houston <[email protected]>
Date:   Wed Jan 23 10:17:00 2019 -0600

    Batman Udev: Don't include batteries who have unknown status, have never 
had a full charge, and have no charge rate.
    
    Summary: This fixes issues where erroneous udev detections of batteries are 
included. @bu5hm4n and I both have had issues where udev thinks we have two 
batteries because our hid/touchscreens report a battery even though they are 
not accurate.  The problem is batman will then think there are two batteries 
and calculate battery percentage based off both batteries.  For instance if the 
laptop battery is 100% and it is detecting this phony hid battery, the result 
is batman thinks you are  [...]
    
    Test Plan: You have to have a device that udev reports two batteries for 
when there aren't two.  It should be harmless to not include batteries that 
have never been charged, have no charge, and have unknown for their status.
    
    Reviewers: bu5hm4n, raster, zmike!, devilhorns
    
    Reviewed By: raster
    
    Subscribers: cedric, bu5hm4n
    
    Tags: #enlightenment-git
    
    Differential Revision: https://phab.enlightenment.org/D7736
---
 src/modules/sysinfo/batman/batman_udev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/modules/sysinfo/batman/batman_udev.c 
b/src/modules/sysinfo/batman/batman_udev.c
index d52541b88..ce28f57be 100644
--- a/src/modules/sysinfo/batman/batman_udev.c
+++ b/src/modules/sysinfo/batman/batman_udev.c
@@ -182,7 +182,7 @@ _batman_udev_battery_del(const char *syspath, Instance 
*inst)
 
    EINA_LIST_FOREACH(batman_device_batteries, l, bat)
      {
-        if (inst == bat->inst)
+        if ((inst == bat->inst) && (eina_streq(bat->udi, syspath)))
           {
              batman_device_batteries = 
eina_list_remove_list(batman_device_batteries, l);
              eina_stringshare_del(bat->udi);
@@ -324,6 +324,11 @@ _batman_udev_battery_update(const char *syspath, Battery 
*bat, Instance *inst)
           bat->charging = 1;
         else if ((!strcmp(test, "Unknown")) && (bat->charge_rate > 0))
           bat->charging = 1;
+        else if ((!strcmp(test, "Unknown")) && (bat->charge_rate <= 0) && 
(bat->last_full_charge <= 0))
+          {
+             _batman_udev_battery_del(syspath, inst);
+             return;
+          }
         else
           bat->charging = 0;
         eina_stringshare_del(test);

-- 


Reply via email to