#include <glib.h>
#include <Types.h>
#include <Json.h>
-#include "BatteryStatisticsTypes.h"
#include "HeartDbReader.h"
#include "BatteryMonitor.h"
static int __lastResetTime = 0;
static int __lastPercent = -1;
static int __lastPercentTime = 0;
+static int __lastHeartTimestamp = 0;
static bool __isCharging = 0;
static std::vector<Json> __batteryTimeInfoVec;
"CREATE TABLE IF NOT EXISTS " BATTERY_LAST_INFO_TABLE \
" (" BATTERY_LAST_INFO_TABLE_COLUMNS ")", &records);
+ __dbMgr.executeSync(
+ "CREATE TABLE IF NOT EXISTS " BATTERY_LAST_CPU_USAGE_TABLE \
+ " (" BATTERY_LAST_CPU_USAGE_TABLE_COLUMNS ")", &records);
+
__dbMgr.createTableSync(BATTERY_TEMP_TIME_INFO, BATTERY_TEMP_TIME_INFO_COLUMNS, NULL);
}
records[0].get(NULL, BATTERY_LAST_RESET_TIME, &__lastResetTime);
records[0].get(NULL, BATTERY_LAST_PERCENT, &__lastPercent);
records[0].get(NULL, BATTERY_LAST_PERCENT_TIME, &__lastPercentTime);
+ records[0].get(NULL, BATTERY_LAST_HEART_TIMESTAMP, &__lastHeartTimestamp);
}
records.clear();
__batteryTimeInfoVec.clear();
- ret = __dbMgr.executeSync("SELECT * FROM " BATTERY_TEMP_TIME_INFO , &__batteryTimeInfoVec);
+ ret = __dbMgr.executeSync("SELECT * FROM " BATTERY_TEMP_TIME_INFO , &__batteryTimeInfoVec);
ret = __dbMgr.executeSync("DELETE FROM " BATTERY_TEMP_TIME_INFO, &records);
char *query = sqlite3_mprintf(
"INSERT OR REPLACE INTO " BATTERY_LAST_INFO_TABLE " (" \
BATTERY_ROW_ID ", " BATTERY_LAST_RESET_TIME ", " \
- BATTERY_LAST_PERCENT ", " BATTERY_LAST_PERCENT_TIME ") VALUES (%s, %d, %d, %d)",
- DEFAULT_ROW_ID_STR, __lastResetTime, __lastPercent, __lastPercentTime);
+ BATTERY_LAST_PERCENT ", " BATTERY_LAST_PERCENT_TIME ", " BATTERY_LAST_HEART_TIMESTAMP ") VALUES (%s, %d, %d, %d, %d)",
+ DEFAULT_ROW_ID_STR, __lastResetTime, __lastPercent, __lastPercentTime, __lastHeartTimestamp);
std::vector<Json> records;
bool ret = __dbMgr.executeSync(query, &records);
return ERR_NONE;
}
+bool BatteryMonitor::__getLastCpuUsageTable(CpuUsageMap* lastCpuUsage)
+{
+ std::vector<Json> lastCpuUsageLog;
+ bool ret = __dbMgr.executeSync(
+ "SELECT * FROM " BATTERY_LAST_CPU_USAGE_TABLE,
+ &lastCpuUsageLog);
+ IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to load last Cpu Times of Apps");
+
+ unsigned int k = 0;
+ std::string appId;
+ int timestamp;
+ int stime;
+ int utime;
+
+ while (k < lastCpuUsageLog.size()) {
+ lastCpuUsageLog[k].get(NULL, BATTERY_APP_ID, &appId);
+ lastCpuUsageLog[k].get(NULL, BATTERY_TIMESTAMP, ×tamp);
+ lastCpuUsageLog[k].get(NULL, BATTERY_UTIME, &utime);
+ lastCpuUsageLog[k].get(NULL, BATTERY_STIME, &stime);
+ k++;
+
+ LastAppCpuUsageInfo lastAppCpuUsage;
+ lastAppCpuUsage.timestamp = timestamp;
+ lastAppCpuUsage.utime = utime;
+ lastAppCpuUsage.stime = stime;
+ (*lastCpuUsage)[appId] = lastAppCpuUsage;
+ }
+ return true;
+}
+
bool BatteryMonitor::processBatteryUsage()
{
IF_FAIL_RETURN_TAG(__batteryTimeInfoVec.size() > 0, true, _D, "All per-app battery usages are already calculated");
bool ret = heartReader.open();
IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to open heart db");
- std::vector<Json> appLog;
- ret = heartReader.readAppLaunchLog(totalStartTime, totalEndTime, &appLog);
+ std::vector<Json> cpuUsageLog;
+ ret = heartReader.readCpuUsageLog(totalStartTime, totalEndTime, &cpuUsageLog);
heartReader.close();
IF_FAIL_RETURN_TAG(ret, false, _E, "Cannot read from heart cpu table");
- IF_FAIL_RETURN_TAG(appLog.size() > 0, true, _W, "Heart cpu data is not prepared yet (%d ~ %d)", totalStartTime, totalEndTime);
- _D("Read %d rows from heart cpu table from %d to %d", appLog.size(), totalStartTime, totalEndTime);
+ IF_FAIL_RETURN_TAG(cpuUsageLog.size() > 0, true, _W, "Heart cpu data is not prepared yet (%d ~ %d)", totalStartTime, totalEndTime);
+ _D("Read %d rows from heart cpu table from %d to %d", cpuUsageLog.size(), totalStartTime, totalEndTime);
- // Get the last timestamp of HEART cpu data
- int lastHeartTimestamp;
- appLog.back().get(NULL, BATTERY_TIMESTAMP, &lastHeartTimestamp);
+ // Get the last timestamp of HEART cpu data and maximum app times tables in cache
+ cpuUsageLog.back().get(NULL, BATTERY_TIMESTAMP, &__lastHeartTimestamp);
+ CpuUsageMap lastCpuUsage;
+ ret = __getLastCpuUsageTable(&lastCpuUsage);
unsigned int i;
for (i = 0; i < __batteryTimeInfoVec.size(); i++) {
row.get(NULL, BATTERY_START_TIME, &startTime);
row.get(NULL, BATTERY_END_TIME, &endTime);
- if (endTime > lastHeartTimestamp) {
+ if (endTime > __lastHeartTimestamp) {
_W("[%d] Heart cpu data is not prepared yet (%d ~ %d)", i, startTime, endTime);
break;
}
// Calculate per app battery usage
std::vector<Json> usage;
- ret = __analyzer.calculateBatteryUsage(startTime, endTime, appLog, &usage);
+ ret = __analyzer.calculateBatteryUsage(startTime, endTime, cpuUsageLog, lastCpuUsage, &usage);
if (!ret) {
_E("[%d] Failed to calculate battery usage (%d ~ %d)", i, startTime, endTime);
continue;
_D("[%d] Battery usage per app calculated (%d ~ %d)", i, startTime, endTime);
// Insert battery usage
- ret = __insertUsageLog(usage);
+ ret = __insertBatteryUsageLog(usage);
if (!ret) {
_E("Failed to insert per app battery usage");
}
}
+ // Insert log of last times of apps
+ if (i != 0) {
+ ret = __insertLastCpuUsageLog(lastCpuUsage);
+ if (!ret) {
+ _E("Failed to insert last Cpu Usage of apps");
+ }
+ }
+
// Remove completed time info
_D("Total %d time intervals, %d intervals are calculated", __batteryTimeInfoVec.size(), i);
__batteryTimeInfoVec.erase(__batteryTimeInfoVec.begin(), __batteryTimeInfoVec.begin() + i);
return true;
}
-bool BatteryMonitor::__insertUsageLog(std::vector<Json>& usage)
+bool BatteryMonitor::__insertBatteryUsageLog(std::vector<Json>& usage)
{
IF_FAIL_RETURN_TAG(usage.size(), true, _W, "No data");
- std::string query = std::string("INSERT INTO " BATTERY_USAGE_TABLE \
- "(" BATTERY_APP_ID ", " BATTERY_START_TIME ", " BATTERY_END_TIME "," BATTERY_AMOUNT ") VALUES");
+ std::string query("INSERT INTO " BATTERY_USAGE_TABLE \
+ "(" BATTERY_APP_ID ", " BATTERY_START_TIME ", " \
+ BATTERY_END_TIME ", " BATTERY_UTIME ", " \
+ BATTERY_STIME ", " BATTERY_AMOUNT ") VALUES");
std::string appId;
int startTime;
+ int stime, utime;
int endTime;
double amount;
usage[i].get(NULL, BATTERY_APP_ID, &appId);
usage[i].get(NULL, BATTERY_START_TIME, &startTime);
usage[i].get(NULL, BATTERY_END_TIME, &endTime);
+ usage[i].get(NULL, BATTERY_UTIME, &utime);
+ usage[i].get(NULL, BATTERY_STIME, &stime);
usage[i].get(NULL, BATTERY_AMOUNT, &amount);
- query += std::string(" ('" + appId + "', " + std::to_string(startTime) + ", " +
- std::to_string(endTime) + ", " + std::to_string((int) (amount * 10000)) + ")");
+ query += " ('" + appId + "', "
+ + std::to_string(startTime) + ", "
+ + std::to_string(endTime) + ", "
+ + std::to_string(utime) + ", "
+ + std::to_string(stime) + ", "
+ + std::to_string((int) (amount * 10000)) + ")";
- if (i != usage.size() - 1 ) {
- query += ", ";
- }
+ query += ", ";
}
+ query = query.substr(0, query.size() - 2);
_D("Insert %d rows of per app battery usage", usage.size());
- std::vector<Json> records;
- return __dbMgr.executeSync(query.c_str(), &records);
+ return __dbMgr.executeSync(query.c_str(), NULL);
+}
+
+bool BatteryMonitor::__insertLastCpuUsageLog(CpuUsageMap& usage)
+{
+ IF_FAIL_RETURN_TAG(usage.size(), true, _W, "No data");
+ _D("Delete all rows from app last times table");
+ __dbMgr.executeSync("DELETE FROM " BATTERY_LAST_CPU_USAGE_TABLE, NULL);
+
+ std::string query("INSERT INTO " BATTERY_LAST_CPU_USAGE_TABLE "(" BATTERY_APP_ID ", " BATTERY_UTIME ", " BATTERY_STIME "," BATTERY_TIMESTAMP ") VALUES");
+
+ std::string appId;
+ int stime, utime;
+ int timestamp;
+
+ for (auto it = usage.begin(); it != usage.end(); it++) {
+ appId = it->first;
+ timestamp = (it->second).timestamp;
+ utime = (it->second).utime;
+ stime = (it->second).stime;
+
+ query += " ('" + appId
+ + "', " + std::to_string(utime)
+ + ", " + std::to_string(stime)
+ + ", " + std::to_string(timestamp) + ")";
+
+ query += ", ";
+ }
+
+ _D("Insert %d rows in app last times table", usage.size());
+ query = query.substr(0, query.size() - 2);
+ return __dbMgr.executeSync(query.c_str(), NULL);
}
int BatteryMonitor::getLastResetTime()
static void __batteryChangeCb(device_callback_e type, void* value, void* userData);
static void __chargerChangeCb(device_callback_e type, void* value, void* userData);
- bool __insertUsageLog(std::vector<Json>& usage);
+ bool __insertBatteryUsageLog(std::vector<Json>& usage);
+ bool __insertLastCpuUsageLog(CpuUsageMap& usage);
+ bool __getLastCpuUsageTable(CpuUsageMap* lastCpuUsage);
DatabaseManager __dbMgr;
BatteryUsageAnalyzer __analyzer;
#define _CONTEXT_STATS_BATTERY_TYPES_H_
#include <ProviderTypes.h>
+#include <map>
#define BATTERY_HISTORY_PRIV PRIV_APP_HISTORY
#define BATTERY_USAGE_TABLE "Log_BatteryUsagePerApp"
#define BATTERY_USAGE_TABLE_COLUMNS \
"AppId TEXT NOT NULL, StartTime INTEGER NOT NULL DEFAULT 0, " \
- "EndTime INTEGER NOT NULL DEFAULT 0, Amount INTEGER NOT NULL DEFAULT 0"
+ "EndTime INTEGER NOT NULL DEFAULT 0, Amount INTEGER NOT NULL DEFAULT 0, " \
+ "Utime INTEGER NOT NULL DEFAULT 0, Stime INTEGER NOT NULL DEFAULT 0"
#define BATTERY_LAST_INFO_TABLE "Battery_LastInfo"
#define BATTERY_LAST_INFO_TABLE_COLUMNS \
"RowId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " \
"LastResetTime UNSIGNED INT NOT NULL DEFAULT 0, " \
- "LastPercent UNSIGNED INT NOT NULL DEFAULT 0," \
- "LastPercentTime UNSIGNED INT NOT NULL DEFAULT 0"
+ "LastPercent UNSIGNED INT NOT NULL DEFAULT 0, " \
+ "LastPercentTime UNSIGNED INT NOT NULL DEFAULT 0, " \
+ "LastHeartTimestamp UNSIGNED INT NOT NULL DEFAULT 0"
#define BATTERY_TEMP_TIME_INFO "Temp_BatteryTimeInfo"
#define BATTERY_TEMP_TIME_INFO_COLUMNS \
"Amount INTEGER NOT NULL DEFAULT 0, StartTime INTEGER NOT NULL DEFAULT 0, " \
"EndTime INTEGER NOT NULL DEFAULT 0"
+#define BATTERY_LAST_CPU_USAGE_TABLE "Temp_LastCpuUsagePerApp"
+#define BATTERY_LAST_CPU_USAGE_TABLE_COLUMNS \
+ "AppId TEXT PRIMARY KEY, Utime INTEGER NOT NULL DEFAULT 0, " \
+ "Stime INTEGER NOT NULL DEFAULT 0, Timestamp INTEGER NOT NULL DEFAULT 0"
+
#define BATTERY_APP_ID "AppId"
+#define BATTERY_INDEX "idx"
#define BATTERY_TIMESTAMP "Timestamp"
#define BATTERY_TYPE "Type"
+#define BATTERY_DATA "Data"
#define BATTERY_START_TIME "StartTime"
#define BATTERY_END_TIME "EndTime"
+#define BATTERY_UTIME "Utime"
+#define BATTERY_STIME "Stime"
#define BATTERY_AMOUNT "Amount"
#define BATTERY_LAST_RESET_TIME "LastResetTime"
#define BATTERY_LAST_PERCENT "LastPercent"
#define BATTERY_LAST_PERCENT_TIME "LastPercentTime"
+#define BATTERY_LAST_HEART_TIMESTAMP "LastHeartTimestamp"
#define BATTERY_ROW_ID "RowId"
#define CURRENT_TIME (int)(time(0))
+/* Typedefs */
+namespace ctx {
+ struct LastAppCpuUsageInfo {
+ int timestamp;
+ int utime;
+ int stime;
+ };
+ typedef std::map<std::string, LastAppCpuUsageInfo> CpuUsageMap;
+}
+
enum AppLaunchType {
TYPE_SERVICE = 0,
TYPE_FOREGROUND,
#include <map>
#include <Types.h>
-#include "BatteryStatisticsTypes.h"
#include "BatteryUsageAnalyzer.h"
using namespace ctx;
-bool BatteryUsageAnalyzer::calculateBatteryUsage(int lastTime, int currTime, std::vector<Json>& appLog, std::vector<Json>* usage)
+void BatteryUsageAnalyzer::__normalizeBatteryUsage(std::vector<Json>* usage, int totalUtime, int totalStime)
+{
+ if (totalStime + totalUtime == 0) {
+ return;
+ }
+
+ int utime;
+ int stime;
+ double batteryUsage;
+
+ for (unsigned int i= 0; i < usage->size(); i++) {
+ (*usage)[i].get(NULL, BATTERY_UTIME, &utime);
+ (*usage)[i].get(NULL, BATTERY_STIME, &stime);
+ batteryUsage = ((double)(utime + stime)) / ((double)(totalUtime + totalStime));
+ (*usage)[i].set(NULL, BATTERY_AMOUNT, batteryUsage);
+ }
+}
+
+bool BatteryUsageAnalyzer::calculateBatteryUsage(int lastTime, int currTime, std::vector<Json>& cpuUsageLog, CpuUsageMap& lastCpuUsage, std::vector<Json>* usage)
{
int timeInterval = currTime - lastTime;
IF_FAIL_RETURN(timeInterval > 0, false);
- std::map<std::string, int> lastAppTimeMap;
std::string appId;
int timestamp;
- int type;
+ int stime;
+ int utime;
+ int idx;
+ int totalUtime = 0;
+ int totalStime = 0;
- for (unsigned int i = 0; i < appLog.size(); i++) {
- appLog[i].get(NULL, BATTERY_APP_ID, &appId);
- appLog[i].get(NULL, BATTERY_TIMESTAMP, ×tamp);
- appLog[i].get(NULL, BATTERY_TYPE, &type);
+ for (unsigned int i = 0; i < cpuUsageLog.size(); i++) {
+ cpuUsageLog[i].get(NULL, BATTERY_APP_ID, &appId);
+ cpuUsageLog[i].get(NULL, BATTERY_TIMESTAMP, ×tamp);
+ cpuUsageLog[i].get(NULL, BATTERY_UTIME, &utime);
+ cpuUsageLog[i].get(NULL, BATTERY_STIME, &stime);
+ cpuUsageLog[i].get(NULL, BATTERY_INDEX, &idx);
if (timestamp < lastTime) {
continue;
}
-
if (timestamp > currTime) {
break;
}
- if (type == TYPE_FOREGROUND) { // Mark timestamp of foreground
- lastAppTimeMap[appId] = timestamp;
- } else if (type == TYPE_BACKGROUND) { // Foreground duration calculation (Foreground->Background)
+ //If CPU table is reset, clear last app times and make lastTime as the timestamp
+ if (idx == 0) {
+ lastCpuUsage.clear();
+ lastTime = timestamp;
+ }
+
+ auto lastAppCpuUsage = lastCpuUsage.find(appId);
+ int prevUtime = 0;
+ int prevStime = 0;
+ int prevTimestamp = 0;
+
+ if (lastAppCpuUsage != lastCpuUsage.end()) {
+ prevTimestamp = (lastAppCpuUsage->second).timestamp;
+ prevUtime = (lastAppCpuUsage->second).utime;
+ prevStime = (lastAppCpuUsage->second).stime;
+
Json row;
- if (lastAppTimeMap.find(appId) == lastAppTimeMap.end() || lastAppTimeMap[appId] == 0) {
- __createBatteryUsage(appId, lastTime, timestamp, timeInterval, &row);
- } else {
- __createBatteryUsage(appId, lastAppTimeMap[appId], timestamp, timeInterval, &row);
- lastAppTimeMap[appId] = 0;
- }
+ row.set(NULL, BATTERY_APP_ID, appId);
+ row.set(NULL, BATTERY_START_TIME, prevTimestamp);
+ row.set(NULL, BATTERY_END_TIME, timestamp);
+ row.set(NULL, BATTERY_AMOUNT, 0);
+ row.set(NULL, BATTERY_UTIME, utime - prevUtime);
+ row.set(NULL, BATTERY_STIME, stime - prevStime);
+
+ totalUtime += utime - prevUtime;
+ totalStime += stime - prevStime;
usage->push_back(row);
- }
- }
- // Not closed app
- for (auto it = lastAppTimeMap.begin(); it != lastAppTimeMap.end(); it++) {
- if (it->second == 0) {
- continue;
+ } else {
+ Json row;
+ row.set(NULL, BATTERY_APP_ID, appId);
+ row.set(NULL, BATTERY_START_TIME, lastTime);
+ row.set(NULL, BATTERY_END_TIME, timestamp);
+ row.set(NULL, BATTERY_AMOUNT, 0);
+ row.set(NULL, BATTERY_UTIME, utime);
+ row.set(NULL, BATTERY_STIME, stime);
+
+ totalStime += stime;
+ totalUtime += utime;
+ usage->push_back(row);
}
- Json row;
- __createBatteryUsage(it->first, it->second, currTime, timeInterval, &row);
- usage->push_back(row);
+ LastAppCpuUsageInfo lastAppUsage;
+ lastAppUsage.timestamp = timestamp;
+ lastAppUsage.utime = utime;
+ lastAppUsage.stime = stime;
+ lastCpuUsage[appId] = lastAppUsage;
}
-
+ __normalizeBatteryUsage(usage, totalUtime, totalStime);
return true;
}
-
-void BatteryUsageAnalyzer::__createBatteryUsage(std::string appId, int startTime, int endTime, int timeInterval, Json* record)
-{
- record->set(NULL, BATTERY_APP_ID, appId);
- record->set(NULL, BATTERY_START_TIME, startTime);
- record->set(NULL, BATTERY_END_TIME, endTime);
- record->set(NULL, BATTERY_AMOUNT, (double)(endTime - startTime) / (double)timeInterval);
-}
#include <vector>
#include <Json.h>
+#include "BatteryStatisticsTypes.h"
namespace ctx {
BatteryUsageAnalyzer() {};
~BatteryUsageAnalyzer() {};
- bool calculateBatteryUsage(int lastTime, int currTime, std::vector<Json>& appLog, std::vector<Json>* usage);
+ bool calculateBatteryUsage(int lastTime, int currTime, std::vector<Json>& cpuUsageLog, CpuUsageMap& lastCpuUsage, std::vector<Json>* usage);
private:
- void __createBatteryUsage(std::string appId, int startTime, int endTime, int timeInterval, Json* record);
+ void __normalizeBatteryUsage(std::vector<Json>* usage, int totalUtime, int totalStime);
};
* limitations under the License.
*/
-//#include <sstream>
+#include <sstream>
#include <tzplatform_config.h>
#include <Json.h>
#include "BatteryStatisticsTypes.h"
#define HEART_APP_ID "appid"
#define HEART_TIME "time"
#define HEART_DATA "data"
+#define HEART_INDEX "idx"
#define HEART_DB_PATH tzplatform_mkpath(TZ_USER_DB, ".resourced-heart-default.db")
__heartDb = NULL;
}
-bool HeartDbReader::readAppLaunchLog(int startTime, int endTime, std::vector<Json>* appLog)
+bool HeartDbReader::readCpuUsageLog(int startTime, int endTime, std::vector<Json>* cpuUsageLog)
{
IF_FAIL_RETURN(__heartDb, false);
char* sql = sqlite3_mprintf(
- "SELECT " HEART_APP_ID ", " HEART_TIME ", " HEART_DATA " FROM " HEART_CPU_TABLE \
+ "SELECT " HEART_APP_ID ", " HEART_TIME ", " HEART_DATA ", " HEART_INDEX " FROM " HEART_CPU_TABLE \
" WHERE " HEART_TIME " >= %d AND " HEART_TIME " < %d", startTime, endTime);
char* err = NULL;
- int ret = sqlite3_exec(__heartDb, sql, __appLaunchLogCb, appLog, &err);
+ int ret = sqlite3_exec(__heartDb, sql, __cpuUsageLogCb, cpuUsageLog, &err);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
_E("Failed to read heart DB: Error(%s)", err);
return true;
}
-int HeartDbReader::__appLaunchLogCb(void *userData, int dim, char **value, char **column)
+int HeartDbReader::__cpuUsageLogCb(void *userData, int dim, char **value, char **column)
{
IF_FAIL_RETURN(userData, 0);
}
if (!columnNull) {
- __convertAppLaunchLog(row, &newRow);
+ __convertCpuUsageLog(row, &newRow);
records->push_back(newRow);
}
return 0;
}
-void HeartDbReader::__convertAppLaunchLog(Json& row, Json* newRow)
+void HeartDbReader::__convertCpuUsageLog(Json& row, Json* newRow)
{
std::string appId;
std::string timestamp;
std::string data;
-/* int utime;
+ int utime;
int stime;
int pid;
int type;
-*/
+ int index;
+
row.get(NULL, HEART_APP_ID, &appId);
row.get(NULL, HEART_TIME, ×tamp);
row.get(NULL, HEART_DATA, &data);
-/*
- std::stringstream buf = data; // TODO use utim & stime
+ row.get(NULL, HEART_INDEX, &index);
+
+ std::stringstream buf(data);
buf >> utime >> stime >> pid >> type;
-*/
- std::string type = data.substr(data.length() - 2, 1);
newRow->set(NULL, BATTERY_APP_ID, appId);
newRow->set(NULL, BATTERY_TIMESTAMP, atoi(timestamp.c_str()));
- newRow->set(NULL, BATTERY_TYPE, atoi(type.c_str()));
+ newRow->set(NULL, BATTERY_UTIME, utime);
+ newRow->set(NULL, BATTERY_STIME, stime);
+ newRow->set(NULL, BATTERY_TYPE, type);
+ newRow->set(NULL, BATTERY_INDEX, index);
}
bool open();
void close();
- bool readAppLaunchLog(int startTime, int endTime, std::vector<Json>* appLog);
+ bool readCpuUsageLog(int startTime, int endTime, std::vector<Json>* cpuUsageLog);
private:
- static int __appLaunchLogCb(void *userData, int dim, char **value, char **column);
- static void __convertAppLaunchLog(Json& row, Json* newRow);
+ static int __cpuUsageLogCb(void *userData, int dim, char **value, char **column);
+ static void __convertCpuUsageLog(Json& row, Json* newRow);
sqlite3 *__heartDb;
};