Modify recnet battery usage to return data after booting, if device never fully charged. 68/101068/2
authorSomin Kim <somin926.kim@samsung.com>
Wed, 30 Nov 2016 06:37:54 +0000 (15:37 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 30 Nov 2016 09:34:42 +0000 (01:34 -0800)
Change-Id: I01f9e9f62271094a6e10f4fec00eeba71fda1fb4
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
src/battery-stats/BatteryMonitor.cpp

index 4352019..9a11562 100644 (file)
@@ -27,6 +27,7 @@
 
 using namespace ctx;
 
+static int __bootingTime = 0;
 static int __lastResetTime = 0;
 static int __lastPercent = -1;
 static int __lastPercentTime = 0;
@@ -64,6 +65,8 @@ void BatteryMonitor::__initialize()
 
 bool BatteryMonitor::__loadLastInfo()
 {
+       __bootingTime = CURRENT_TIME;
+
        device_battery_is_charging(&__isCharging);
 
        std::vector<Json> records;
@@ -355,8 +358,13 @@ bool BatteryMonitor::__insertLastCpuUsageLog(CpuUsageMap& usage)
        return __dbMgr.executeSync(query.c_str(), NULL);
 }
 
+// Used for Recent Battery Usage
 int BatteryMonitor::getLastResetTime()
 {
-       IF_FAIL_RETURN_TAG(__lastResetTime != 0, CURRENT_TIME, _D, "Last reset time doesn't exist");
+       if (__lastResetTime == 0) {
+               _I("Device has not fully charged until now. Start time of recent battery usage will be booting time");
+               return __bootingTime;
+       }
+
        return __lastResetTime;
 }