g_print(" 5. Peak Time for Music 6. Peak Time for Video\n");
g_print(" 7. Common Setting for App 8. Common Setting for Music\n");
g_print(" 9. Common Setting for Video 10. Frequently Communicated Address\n");
+ g_print(" 11. Battery Usage 12. Recent Battery Usage\n");
while (!get_input_int("(to exit, ctrl-c)? ")) {;}
case 10:
run_testcase("/history/frequently_communicated_address", _history_comm_frequently);
break;
+ case 11:
+ run_testcase("/history/battery_usage", _history_battery);
+ break;
+ case 12:
+ run_testcase("/history/recent_battery_usage", _history_battery_recent);
+ break;
default:
g_print("Invalid number\n");
break;
return true;
}
-static bool __iterate_list(const char *int_attr[], const char *str_attr[])
+static bool __iterate_list(const char *int_attr[], const char *double_attr[], const char *str_attr[])
{
int cnt = 0;
err = context_history_list_get_count(list_h, &cnt);
g_print("%s(%d) ", int_attr[j], int_val);
}
+ /* Double attributes */
+ for (int j = 0; double_attr[j] != NULL; ++j) {
+ err = context_history_record_get_double(record_h, double_attr[j], &double_val);
+ ASSERT_CMPINT(err, ==, ERR_NONE);
+ g_print("%s(%f) ", double_attr[j], double_val);
+ }
+
/* String attributes */
for (int j = 0; str_attr[j] != NULL; ++j) {
char *tmp = NULL;
{
const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_RECENTLY_USED_APP);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_FREQUENTLY_USED_APP);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_RARELY_USED_APP);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_APP);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
__filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_APP);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_MUSIC);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
__filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_MUSIC);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_VIDEO);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
const char *str_attr[] = {NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
__filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_VIDEO);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;
{
const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
const char *str_attr[] = {CONTEXT_HISTORY_ADDRESS, NULL};
+ const char *double_attr[] = {NULL};
__filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
__filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
bool_val = __get_list(CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS);
IF_FAIL_RETURN(bool_val, false);
- bool_val = __iterate_list(int_attr, str_attr);
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
+ IF_FAIL_RETURN(bool_val, false);
+
+ return true;
+}
+
+bool _history_battery()
+{
+ const char *int_attr[] = {NULL};
+ const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+ const char *double_attr[] = {CONTEXT_HISTORY_TOTAL_AMOUNT, NULL};
+
+ __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
+ __filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
+ __filter_set_int(CONTEXT_HISTORY_FILTER_END_TIME, KEY_END_TIME);
+
+ bool_val = __get_list(CONTEXT_HISTORY_BATTERY_USAGE);
+ IF_FAIL_RETURN(bool_val, false);
+
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
+ IF_FAIL_RETURN(bool_val, false);
+
+ return true;
+}
+
+bool _history_battery_recent()
+{
+ const char *int_attr[] = {"UsedTime", NULL};
+ const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+ const char *double_attr[] = {CONTEXT_HISTORY_TOTAL_AMOUNT, NULL};
+
+ __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
+ __filter_set_int(CONTEXT_HISTORY_FILTER_END_TIME, KEY_END_TIME);
+
+ bool_val = __get_list(CONTEXT_HISTORY_RECENT_BATTERY_USAGE);
+ IF_FAIL_RETURN(bool_val, false);
+
+ bool_val = __iterate_list(int_attr, double_attr, str_attr);
IF_FAIL_RETURN(bool_val, false);
return true;