Merge branch 'devel/tizen' into tizen_3.0 53/107053/1 accepted/tizen/3.0/common/20161227.102140 accepted/tizen/3.0/ivi/20161227.010909 accepted/tizen/3.0/mobile/20161227.010831 accepted/tizen/3.0/wearable/20161227.010845 submit/tizen_3.0/20161226.100642
authorSomin Kim <somin926.kim@samsung.com>
Mon, 26 Dec 2016 08:35:14 +0000 (17:35 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Mon, 26 Dec 2016 08:35:14 +0000 (17:35 +0900)
* devel/tizen:
  [battery-stats] Changed heart sync policy (after rebooting, fully charged ...) & Version 0.9.12

Change-Id: Ic004ac8abed91de67ec6dca232eceaddc246ce23
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
packaging/context-provider.spec
src/battery-stats/BatteryMonitor.cpp
src/battery-stats/BatteryMonitor.h

index d973523..7a22304 100644 (file)
@@ -1,6 +1,6 @@
 Name:       context-provider
 Summary:    Context Provider
-Version:    0.9.11
+Version:    0.9.12
 Release:    1
 Group:      Service/Context
 License:    Apache-2.0
index 4c34e8c..3e1715f 100644 (file)
 
 using namespace ctx;
 
+bool __needSync = true;
 BatteryMonitor* BatteryMonitor::__instance = NULL;
 
 BatteryMonitor::BatteryMonitor() :
-       __bootingTime(0),
        __lastFullTime(0),
        __lastHeartAccessTime(0),
        __heartReader(NULL)
@@ -80,8 +80,6 @@ void BatteryMonitor::initialize()
 
 bool BatteryMonitor::__loadLastInfo()
 {
-       __bootingTime = CURRENT_TIME;
-
        std::vector<Json> records;
        bool ret = __dbMgr.executeSync(
                        "SELECT * FROM " BATTERY_LAST_INFO_TABLE \
@@ -93,6 +91,12 @@ bool BatteryMonitor::__loadLastInfo()
                records[0].get(NULL, BATTERY_LAST_HEART_ACCESS_TIME, &__lastHeartAccessTime);
        }
 
+       if (__lastFullTime == 0) {
+               __lastFullTime = CURRENT_TIME;
+               _I("Device has not fully charged until now. Start time of recent battery usage will be %d", __lastFullTime);
+               __updateLastInfo();
+       }
+
        return true;
 }
 
@@ -120,6 +124,8 @@ void BatteryMonitor::__chargerChangeCb(device_callback_e type, void* value, void
 
        // If charger is disconnected after 100% charged
        if (percent == 100) {
+               __needSync = true;
+
                instance->__lastFullTime = CURRENT_TIME;
                _D("Charger is disconnected after fully charged. Last fully charged time: %d", instance->__lastFullTime);
 
@@ -230,6 +236,7 @@ bool BatteryMonitor::__processBatteryUsage()
        IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to update last cpu log");
 
        __removeExpiredLog();
+       __needSync = false;
 
        return true;
 }
@@ -318,19 +325,14 @@ bool BatteryMonitor::__updateLastCpuUsageLog(CpuUsageMap& usage)
 // Used for Recent Battery Usage
 int BatteryMonitor::getLastFullTime()
 {
-       if (__lastFullTime == 0) {
-               _I("Device has not fully charged until now. Start time of recent battery usage will be booting time: %d", __bootingTime);
-               return __bootingTime;
-       }
-
        return __lastFullTime;
 }
 
 void BatteryMonitor::prepareData()
 {
        int timeDiff = CURRENT_TIME - __lastHeartAccessTime;
-       IF_FAIL_VOID_TAG(timeDiff >= 5 * 60 * 1000,
-               _D, "Battery usage was updated %d minutes ago", timeDiff / 60000);
+       IF_FAIL_VOID_TAG(__needSync || timeDiff >= 5 * 60,
+               _D, "Battery usage was updated %d minutes ago", timeDiff / 60);
 
        _D("Request to sync heart cpu data");
        bool ret = __heartReader->requestSync();
index 4127b09..f87dc3b 100644 (file)
@@ -52,7 +52,6 @@ namespace ctx {
                static int __timeoutCb(void* data);
 
                static BatteryMonitor* __instance;
-               int __bootingTime;
                int __lastFullTime;
                int __lastHeartAccessTime;