[battery-stats] Adjust related timestamps for the case that device fully charged... 63/114563/3
authorSomin Kim <somin926.kim@samsung.com>
Tue, 14 Feb 2017 05:00:20 +0000 (14:00 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Tue, 14 Feb 2017 05:15:08 +0000 (14:15 +0900)
Change-Id: I3380b3c07cf1606e82ca50b59a50bec293ea8662
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
src/battery-stats/BatteryMonitor.cpp

index 79940a8..1cc12bf 100644 (file)
@@ -93,8 +93,19 @@ bool BatteryMonitor::__loadLastInfo()
                records[0].get(NULL, BATTERY_LAST_HEART_ACCESS_TIME, &__lastHeartAccessTime);
        }
 
+       // Adjust last full time & last heart access time
+       int percent = 0;
+       bool charging = false;
+       device_battery_get_percent(&percent);
+       device_battery_is_charging(&charging);
+
        int currentTime = CURRENT_TIME;
-       if (__lastFullTime == 0) {
+       if (!charging && percent == 100) {      // Fully charged
+               __lastFullTime = currentTime;
+               __lastHeartAccessTime = currentTime;
+               _I("Fully charged. Last fully charged time: %d", __lastFullTime);
+               __updateLastInfo();
+       } else if (__lastFullTime == 0) {       // Never fully charged yet
                __lastFullTime = currentTime;
                _I("Device has not fully charged until now. Start time of recent battery usage will be %d", __lastFullTime);
                __updateLastInfo();