--- UPower-0.9.1.orig/src/linux/up-device-supply.c 2010-02-10 19:09:31.000000000 +0200 +++ UPower-0.9.1/src/linux/up-device-supply.c 2011-02-03 09:40:13.000000000 +0200 @@ -40,6 +40,7 @@ #include "up-device-supply.h" #define UP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */ +#define UP_DEVICE_SUPPLY_REFRESH_DELAY 5 /* seconds */ #define UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */ #define UP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30 #define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */ @@ -569,6 +570,17 @@ if (energy_rate > 100*1000) energy_rate = 0; + /* on some machines acpi reports invalid very high current values + just after unplugging the cord */ + if (state == UP_DEVICE_STATE_DISCHARGING && energy_rate > energy_full_design) { + g_usleep (UP_DEVICE_SUPPLY_REFRESH_DELAY * G_USEC_PER_SEC); + energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0); + } + + /* sanity check to less than energy_full_design */ + if (state == UP_DEVICE_STATE_DISCHARGING && energy_rate > energy_full_design) + energy_rate = 0; + /* the hardware reporting failed -- try to calculate this */ if (energy_rate < 0) up_device_supply_calculate_rate (supply);