//#include <appsvc.h>
#include <efl_extension.h>
#include <device/battery.h>
+#include <context_history.h>
#include "smartmanager-battery.h"
#include "smartmanager-battery-main.h"
SmartMgrBattery *ad = data;
ret_if(NULL == data);
- setting_create_Gendial_field_def(
- ad->md.genlist,
- &(ad->itc_layout2),
- NULL,
- ad,
- SWALLOW_Type_LAYOUT_SLIDER,
- "/usr/share/icons/default/small/org.tizen.setting.png",
- "/usr/apps/org.tizen.setting/res/icons/org.tizen.setting.png",
- 15,
- "Application 2",
- "25%",
- NULL);
+// setting_create_Gendial_field_def(
+// ad->md.genlist,
+// &(ad->itc_layout2),
+// NULL,
+// ad,
+// SWALLOW_Type_LAYOUT_SLIDER,
+// "/usr/share/icons/default/small/org.tizen.setting.png",
+// "/usr/apps/org.tizen.setting/res/icons/org.tizen.setting.png",
+// 15,
+// "Application 2",
+// "25%",
+// NULL);
+//
+// setting_create_Gendial_field_def(
+// ad->md.genlist,
+// &(ad->itc_layout2),
+// NULL,
+// NULL,
+// SWALLOW_Type_LAYOUT_SLIDER,
+// "/usr/apps/org.tizen.setting/res/icons/org.tizen.setting.png",
+// NULL,
+// 0,
+// "Applic 3",
+// "38%",
+// NULL);
+
+ context_history_h handle;
+ context_history_filter_h filter;
+ context_history_list_h list;
+
+ int ret = context_history_create(&handle);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_create error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
- setting_create_Gendial_field_def(
- ad->md.genlist,
- &(ad->itc_layout2),
- NULL,
- NULL,
- SWALLOW_Type_LAYOUT_SLIDER,
- "/usr/apps/org.tizen.setting/res/icons/org.tizen.setting.png",
- NULL,
- 0,
- "Applic 3",
- "38%",
- NULL);
+ ret = context_history_filter_create(&filter);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_filter_create() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+ ret = context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, 30);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] () error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ ret = context_history_get_list(handle, CONTEXT_HISTORY_BATTERY_USAGE, filter, &list);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_get_list() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ int i;
+ int count = 0;
+ context_history_record_h record;
+ char *value = NULL;
+ double amount;
+
+ ret = context_history_list_get_count(list, &count);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_get_list() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ for (i = 0; i < count; ++i) {
+ ret = context_history_list_get_current(list, &record);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_list_get_current() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ continue;
+ }
+
+ ret = context_history_record_get_string(record, CONTEXT_HISTORY_APP_ID, &value);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_list_get_current() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ continue;
+ }
+
+ ret = context_history_record_get_double(record, CONTEXT_HISTORY_TOTAL_AMOUNT, &amount);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_list_get_current() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ continue;
+ }
+
+ ret = context_history_list_move_next(list);
+ if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] context_history_list_move_next() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ continue;
+ }
+
+ SETTING_TRACE("<MS> APP: %s %g", value, amount);
+ free(value);
+
+ context_history_record_destroy(record);
+ }
+ context_history_filter_destroy(filter);
+ context_history_list_destroy(list);
+ context_history_destroy(handle);
}
static int battery_main_create(void *data)