diff options
author | Randeep Singh <randeep.s@samsung.com> | 2021-02-03 09:59:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review> | 2021-02-03 09:59:21 +0000 |
commit | f8c745ac322143308ac80a561ba04240704c6986 (patch) | |
tree | 3a3d7bc3b97f1c341b17b57bb90ab97193b50bfe | |
parent | 1ec9a115c3128a9143992154d0cef79d17911286 (diff) | |
parent | 0dce9218540653daa40c1fe309b20300e7d4e8df (diff) | |
download | batterymonitor-f8c745ac322143308ac80a561ba04240704c6986.tar.gz batterymonitor-f8c745ac322143308ac80a561ba04240704c6986.tar.bz2 batterymonitor-f8c745ac322143308ac80a561ba04240704c6986.zip |
Merge "[Non-ACR] GPS Plugin Power Consumption Calculation" into tizensubmit/tizen/20210205.050625
-rwxr-xr-x[-rw-r--r--] | config/bm_params.json | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | config/bm_power_profile_params_TW3.json | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | config/bm_power_profile_params_dummy.json | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_common.h | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_config_parser.h | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_plugin_interface.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_power_engine.h | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_private.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | include/bm_util.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_callback_handler.c | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_config_parser.c | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_plugin_manager.c | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_power_engine.c | 80 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_server_db.c | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | src/bm_util.c | 8 |
15 files changed, 46 insertions, 116 deletions
diff --git a/config/bm_params.json b/config/bm_params.json index 37bdc5c..37bdc5c 100644..100755 --- a/config/bm_params.json +++ b/config/bm_params.json diff --git a/config/bm_power_profile_params_TW3.json b/config/bm_power_profile_params_TW3.json index c3e1db7..d8786b2 100644..100755 --- a/config/bm_power_profile_params_TW3.json +++ b/config/bm_power_profile_params_TW3.json @@ -34,7 +34,8 @@ "p_dp_low": 10.31 }, "gps_sensor": { - "p_gps_inuse": 0.0 + "p_gps_inuse": 23.315, + "p_gps_insearching": 23.115 }, "cpu": { "p_cpu_user": 22.36, diff --git a/config/bm_power_profile_params_dummy.json b/config/bm_power_profile_params_dummy.json index c3e1db7..d8786b2 100644..100755 --- a/config/bm_power_profile_params_dummy.json +++ b/config/bm_power_profile_params_dummy.json @@ -34,7 +34,8 @@ "p_dp_low": 10.31 }, "gps_sensor": { - "p_gps_inuse": 0.0 + "p_gps_inuse": 23.315, + "p_gps_insearching": 23.115 }, "cpu": { "p_cpu_user": 22.36, diff --git a/include/bm_common.h b/include/bm_common.h index 33140eb..33140eb 100644..100755 --- a/include/bm_common.h +++ b/include/bm_common.h diff --git a/include/bm_config_parser.h b/include/bm_config_parser.h index 88b233e..5b7f392 100644..100755 --- a/include/bm_config_parser.h +++ b/include/bm_config_parser.h @@ -39,9 +39,9 @@ int bm_get_device_network_power_params(double *signal_strength0, double *signal_ int bm_get_display_power_params(double *high, double *medium, double *low); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN -int bm_get_gps_sensor_power_params(double *gps_use); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ + +int bm_get_gps_sensor_power_params(double *gps_use, double *gps_searching); + int bm_get_cpu_power_params(double *fg, double *bg); diff --git a/include/bm_plugin_interface.h b/include/bm_plugin_interface.h index 5fa2065..bc6f8b6 100644..100755 --- a/include/bm_plugin_interface.h +++ b/include/bm_plugin_interface.h @@ -166,6 +166,7 @@ typedef struct { typedef struct { time_t connStartTime; /**< start time of feature data collection session */ time_t connStopTime; /**< stop time of feature data collection session */ + uint searchingTime; /**< time elapsed in search operation */ GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */ GSList *gps_data_list; /**< list of nodes of 'bm_gps_st' for next consecutive sessions */ } bm_gps_st; diff --git a/include/bm_power_engine.h b/include/bm_power_engine.h index d274d3b..5c4791d 100644..100755 --- a/include/bm_power_engine.h +++ b/include/bm_power_engine.h @@ -42,9 +42,7 @@ struct bm_feature_data_handles_s { bm_cpu_st *bm_cpu_handle; bm_display_st *bm_display_handle; bm_device_network_st *bm_dn_handle; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_gps_st *bm_gps_handle; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ }; typedef struct bm_feature_data_handles_s *bm_feature_data_h; /**< handle for feature data handle structure */ @@ -55,9 +53,7 @@ struct bm_req_feature_data_handle_flag_s { bool req_cpu_data; bool req_dp_data; bool req_dn_data; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bool req_gps_data; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ }; void bm_engine_set_req_flag_handle(bm_plugin_id_e req_plugin_id, bool value); @@ -82,9 +78,7 @@ int bm_display_calc_power_and_commit(bm_display_st *handle, bool mode); int bm_device_network_calc_power_and_commit(bm_device_network_st *handle, bool mode); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN int bm_gps_calc_power_and_commit(bm_gps_st *handle); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ int bm_battery_calc_power_and_commit(void); diff --git a/include/bm_private.h b/include/bm_private.h index 3cf421f..af86afa 100644..100755 --- a/include/bm_private.h +++ b/include/bm_private.h @@ -69,10 +69,8 @@ typedef enum { BM_APPUSAGE_FIELD_RID_CPU, BM_APPUSAGE_FIELD_RID_DISPLAY, BM_APPUSAGE_FIELD_RID_DEV_NTW, -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN BM_APPUSAGE_FIELD_RID_GPS, BM_APPUSAGE_FIELD_RID_BATTERY, -#endif BM_APPUSAGE_FIELD_END, } BM_APPUSAGE_DB_IDX; diff --git a/include/bm_util.h b/include/bm_util.h index 985c981..dd7ee04 100644..100755 --- a/include/bm_util.h +++ b/include/bm_util.h @@ -89,9 +89,7 @@ void bm_set_free_display_data_handle(bm_display_st **display_handle); void bm_set_free_device_network_data_handle(bm_device_network_st **dn_handle); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ void bm_set_free_data_handles(bm_feature_data_h* data_h); diff --git a/src/bm_callback_handler.c b/src/bm_callback_handler.c index 941bd94..6843637 100644..100755 --- a/src/bm_callback_handler.c +++ b/src/bm_callback_handler.c @@ -175,7 +175,6 @@ void bm_receive_device_network_feature_data(bm_plugin_error_e result, bm_data_h return; } -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN void bm_receive_gps_sensor_feature_data(bm_plugin_error_e result, bm_data_h *handle) { ENTER; @@ -206,7 +205,6 @@ void bm_receive_gps_sensor_feature_data(bm_plugin_error_e result, bm_data_h *han EXIT; return; } -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ bm_callbacks_st bm_receiver_callbacks[BATTERY_MONITOR_CALLBACKS_MAX] = \ { { .provide_feature_data = bm_receive_ble_feature_data }, @@ -214,7 +212,5 @@ bm_callbacks_st bm_receiver_callbacks[BATTERY_MONITOR_CALLBACKS_MAX] = \ { .provide_feature_data = bm_receive_cpu_feature_data }, { .provide_feature_data = bm_receive_display_feature_data }, { .provide_feature_data = bm_receive_device_network_feature_data }, -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN { .provide_feature_data = bm_receive_gps_sensor_feature_data } -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ }; diff --git a/src/bm_config_parser.c b/src/bm_config_parser.c index abfd775..076ab76 100644..100755 --- a/src/bm_config_parser.c +++ b/src/bm_config_parser.c @@ -376,8 +376,7 @@ END: return ret; } -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN -int bm_get_gps_sensor_power_params(double *gps_use) +int bm_get_gps_sensor_power_params(double *gps_use, double *gps_searching) { ENTER; @@ -387,6 +386,7 @@ int bm_get_gps_sensor_power_params(double *gps_use) json_object *jmain = NULL, *jdouble = NULL, *jvalue = NULL; BM_CHECK_INPUT_PARAM(gps_use); + BM_CHECK_INPUT_PARAM(gps_searching); contents = bm_read_content_from_file(BATTERY_MONITOR_POWER_PROFILE_CONFIG_FILE_PATH); @@ -409,6 +409,13 @@ int bm_get_gps_sensor_power_params(double *gps_use) _DBG("gps-sensor power params - gps[%lf]", *gps_use); + json_object_object_get_ex(jvalue, "p_gps_insearching", &jdouble); + if (!jdouble) + goto END; + *gps_searching = json_object_get_double(jdouble); + + _DBG("gps-sensor searching power params - gps[%lf]", *gps_searching); + ret = BATTERY_MONITOR_ERROR_NONE; END: g_free(contents); @@ -418,7 +425,6 @@ END: EXIT; return ret; } -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ int bm_get_cpu_power_params(double *user, double *system) { diff --git a/src/bm_plugin_manager.c b/src/bm_plugin_manager.c index e855ec5..5b2586d 100644..100755 --- a/src/bm_plugin_manager.c +++ b/src/bm_plugin_manager.c @@ -27,9 +27,7 @@ const bm_callbacks_st wifi_cb; const bm_callbacks_st cpu_cb; const bm_callbacks_st display_cb; const bm_callbacks_st device_network_cb; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN const bm_callbacks_st gps_cb; -#endif static bm_plugin_info_h *plugins[BATTERY_MONITOR_PLUGINS_MAX]; @@ -40,9 +38,7 @@ inline void bm_populate_callbacks(void) bm_receiver_callbacks[BM_DATA_TYPE_CPU] = &cpu_cb; bm_receiver_callbacks[BM_DATA_TYPE_DISPLAY] = &display_cb; bm_receiver_callbacks[BM_DATA_TYPE_DEVICE_NETWORK] = &device_network_cb; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_receiver_callbacks[BM_DATA_TYPE_GPS_SENSOR] = &gps_cb; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ return; } @@ -55,9 +51,7 @@ const char *bm_get_plugin_name(bm_plugin_id_e id) BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_CPU) BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_DISPLAY) BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_DEVICE_NETWORK) -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_GPS_SENSOR) -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ default: return "UNKNOWN PLUGIN NAME"; } @@ -72,11 +66,7 @@ void bm_get_feature_plugin_handle(bm_plugin_info_h **handle, bm_plugin_id_e id) return; } -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN if (id >= BM_PLUGIN_ID_MAX) { -#else - if (id > BM_PLUGIN_ID_DEVICE_NETWORK) { -#endif *handle = NULL; _ERR("invalid plugin id"); goto END; @@ -105,12 +95,7 @@ static int bm_init_loaded_plugins() const bm_callbacks_st *bm_cb = NULL; bm_populate_callbacks(); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) { -#else - for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) { -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ - bm_plugin = plugins[id]; bm_cb = bm_receiver_callbacks[id]; @@ -145,11 +130,7 @@ static int bm_add_plugin(void *handle, bm_plugin_st *plugin) _INFO("Plugin Info - name[%s], id[%d], version[%s]", plugin->name, plugin->id, plugin->version); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN if (BATTERY_MONITOR_PLUGINS_MAX < plugin->id) { -#else - if (BM_PLUGIN_ID_DEVICE_NETWORK < plugin->id) { -#endif _ERR("Unknown plugin id[%d] for [%s]", plugin->id, plugin->name); return BATTERY_MONITOR_ERROR_PLUGIN_ADD; } @@ -160,8 +141,7 @@ static int bm_add_plugin(void *handle, bm_plugin_st *plugin) } if (g_str_equal(plugin->version, BATTERY_MONITOR_VERSION) == FALSE) { - _ERR("Version (%s) mismatch for %s", - plugin->version, plugin->name); + _ERR("Version (%s) mismatch for %s",plugin->version, plugin->name); return BATTERY_MONITOR_ERROR_PLUGIN_ADD; } @@ -301,11 +281,7 @@ void deinitialize_plugin_manager(void) int id; bm_plugin_info_h *bm_plugin = NULL; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) { -#else - for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) { -#endif bm_plugin = plugins[id]; diff --git a/src/bm_power_engine.c b/src/bm_power_engine.c index 5763f50..a8caef9 100644..100755 --- a/src/bm_power_engine.c +++ b/src/bm_power_engine.c @@ -96,12 +96,10 @@ int bm_engine_get_mah_usage_by_app_id_for_resource_id_ci(const gchar* app_id, gi *battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_display, cmah); else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK) *battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_device_network, cmah); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR) *battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_gps, cmah); else *battery_usage = -1; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ bm_appid_usage_free(app_usage); @@ -134,9 +132,7 @@ int bm_engine_get_total_mah_usage_by_app_id_ci(const gchar* app_id, gint64 start } int total_consumption = (app_usage->rId_ble + app_usage->rId_wifi + app_usage->rId_cpu + \ app_usage->rId_display + app_usage->rId_device_network); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN total_consumption += app_usage->rId_gps; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ *battery_usage = bm_calc_individual_mah_consumption(total_consumption, cmah); _INFO("total battery consumption is [%lf] for app-id[%s]", *battery_usage, app_id); @@ -211,11 +207,8 @@ int bm_engine_get_all_resource_usage_handle_ci(const gchar* app_id, gint64 start battery_data->cpu_val = app_usage->rId_cpu; battery_data->dp_val = app_usage->rId_display; battery_data->dn_val = app_usage->rId_device_network; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN battery_data->gps_val = app_usage->rId_gps; battery_data->bat_val = app_usage->rId_battery; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ - bm_appid_usage_free(app_usage); EXIT; @@ -247,11 +240,9 @@ void bm_engine_set_req_flag_handle(bm_plugin_id_e req_plugin_id, bool value) case BM_PLUGIN_ID_DEVICE_NETWORK: bm_req_flag_h->req_dn_data = value; break; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN case BM_PLUGIN_ID_GPS_SENSOR: bm_req_flag_h->req_gps_data = value; break; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ default: _DBG("Invalid plugin ID"); break; @@ -275,9 +266,7 @@ void bm_set_req_flag_handles(bool value) bm_req_flag_h->req_cpu_data = value; bm_req_flag_h->req_dp_data = value; bm_req_flag_h->req_dn_data = value; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_req_flag_h->req_gps_data = value; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ _INFO("request flags set-[%s]", (value == true) ? "TRUE" : "FALSE"); @@ -309,10 +298,8 @@ static int bm_appid_session_usage_map(char *app_id, int app_usage, bm_plugin_id_ temp->rId_display += app_usage; else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK) temp->rId_device_network += app_usage; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR) temp->rId_gps += app_usage; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ _DBG("update - app_usage for app_id(%s), for resource(%d), by usage(%d)", app_id, resource_id, app_usage); //_DBG("session usage bt %d, wifi %d, cpu %d, dsp %d, dn %d", temp->rId_ble, temp->rId_wifi, temp->rId_cpu, @@ -334,10 +321,8 @@ static int bm_appid_session_usage_map(char *app_id, int app_usage, bm_plugin_id_ temp->rId_display = app_usage; else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK) temp->rId_device_network = app_usage; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR) temp->rId_gps = app_usage; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ _DBG("insert - app_usage app_id(%s), for resource(%d), by usage(%d)", app_id, resource_id, app_usage); @@ -1247,7 +1232,6 @@ int bm_device_network_calc_power_and_commit(bm_device_network_st *handle, bool m return ret_val; } -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN int bm_gps_calc_power_and_commit(bm_gps_st *handle) { ENTER; @@ -1263,21 +1247,23 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle) /* creating hash-map with (key, value) = (app-id, data) */ GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); - long int edTime = 0; - long int stTime = 0; - int sesTime = 0; - int onTime = 0; + guint64 stTime = 0; + guint64 edTime = 0; + guint64 searchTime = 0; + guint64 connTime = 0; + guint64 onTime = 0; /* iterating over list for data accumulation */ for (gps_data_iterator = handle->gps_data_list; gps_data_iterator; gps_data_iterator = gps_data_iterator->next) { bm_gps_st *datalistnode = (bm_gps_st *)(gps_data_iterator->data); - edTime = datalistnode->connStartTime; - stTime = datalistnode->connStopTime; - sesTime = edTime - stTime; + stTime = datalistnode->connStartTime; + edTime = datalistnode->connStopTime; + searchTime += datalistnode->searchingTime; + connTime += (edTime - stTime - datalistnode->searchingTime); gps_atm_iterator = datalistnode->atm_list; for ( ; gps_atm_iterator; gps_atm_iterator = gps_atm_iterator->next) { app_time_map_st1 *gps_atm_node = (app_time_map_st1 *)gps_atm_iterator->data; if (!gps_atm_node) { - _DBG("no bt data available"); + _DBG("no gps data available"); continue; } _DBG("gps data available"); @@ -1288,36 +1274,35 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle) _DBG("previous app_id = %s", (char *)prv_app_id); app_time_map_st1 *gps_atm_prv_node = (app_time_map_st1 *)prv_data; gps_atm_node->time += gps_atm_prv_node->time; - _DBG("update - app_id(%s), time(%d)", gps_atm_node->app_id, gps_atm_node->time); + _DBG("update - app_id(%s), time(%u)", gps_atm_node->app_id, gps_atm_node->time); _INFO("updated - %d", g_hash_table_replace(hash, gps_atm_node->app_id, gps_atm_node)); } else { - _DBG("insert - app_id(%s), time(%d)", gps_atm_node->app_id, gps_atm_node->time); + _DBG("insert - app_id(%s), time(%u)", gps_atm_node->app_id, gps_atm_node->time); _INFO("inserted - %d", g_hash_table_insert(hash, gps_atm_node->app_id, gps_atm_node)); } } - } - +} + _DBG("gps-sensor searching duration(%llu), gps-sensor connected duration(%llu)",searchTime, connTime); /* Read standard Rated Values from Device Spec File/Power Profile File */ - double sP_power_gps_conn = 0; - - ret_val = bm_get_gps_sensor_power_params(&sP_power_gps_conn); + double sP_power_gps_conn = 0, sP_power_gps_searching = 0; + ret_val = bm_get_gps_sensor_power_params(&sP_power_gps_conn, &sP_power_gps_searching); if (ret_val != BATTERY_MONITOR_ERROR_NONE) _ERR("failed to get gps-sensor power params"); - _DBG("gps-sensor power params - gps[%lf]", sP_power_gps_conn); + _DBG("gps-sensor power coefficients - gps connected[%lf], gps searching[%lf]", sP_power_gps_conn, sP_power_gps_searching); /* GPS power consumption Level - 1 at the Resource Level */ - int P_power_gps = 0, P_power_conn = 0; - P_power_conn = ((sP_power_gps_conn * sesTime)); - - P_power_gps = P_power_conn; - _DBG("Calculated Power for GPS P_power_gps (%d), P_power_conn (%d)", P_power_gps, P_power_conn); + double P_power_gps = 0, P_power_conn = 0, P_power_searching = 0; + P_power_conn = ((sP_power_gps_conn * connTime)); + P_power_searching = ((sP_power_gps_searching * searchTime)); + P_power_gps = P_power_conn + P_power_searching; + _DBG("calculated gps-sensor power consumption - P_power_gps(%lf), P_power_conn(%lf), P_power_searching(%lf)", P_power_gps, P_power_conn, P_power_searching); /* GPS power consumption Level - 2 at the Application Level */ GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, hash); - int P_power_app_gps = 0, P_power_app_conn = 0; + double P_power_app_gps = 0; char *appid = NULL; int apptime = 0; long int ret_time = bm_get_log_time(data_collection_period); @@ -1325,21 +1310,21 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle) appid_usage_s app_usage = {0}; while (g_hash_table_iter_next(&iter, &key, &value)) { - P_power_app_gps = 0; P_power_app_conn = 0; + P_power_app_gps = 0; apptime = 0; app_time_map_st1 *temp = (app_time_map_st1 *)value; appid = temp->app_id; apptime = temp->time; - if (onTime != 0) - P_power_app_conn = (P_power_conn * apptime)/onTime; //check for 0 denominator & same units - P_power_app_gps = P_power_app_conn; + if (onTime != 0) { + P_power_app_gps = (P_power_gps * apptime)/onTime; //check for 0 denominator & same units + } app_usage.AppId = appid; app_usage.rId_gps = P_power_app_gps; app_usage.log_time = ret_time; total_app_pw += P_power_app_gps; /* Call Insert Function */ - _DBG("Calculated Power for Appid (%s) P_power_app_gps (%d), P_power_app_conn (%d)", appid, P_power_app_gps, P_power_app_conn); + _DBG("calculated gps-sensor power consumed by app(%s), P_power_app_gps(%lf)", appid, P_power_app_gps); ret_val = bm_server_app_usage_insert_to_db(&app_usage); if (ret_val != BATTERY_MONITOR_ERROR_NONE) _ERR("Insert of GPS App failed "); @@ -1369,7 +1354,6 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle) EXIT; return ret_val; } -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ int bm_get_data_from_handles(void) { @@ -1440,7 +1424,6 @@ int bm_get_data_from_handles(void) } _DBG("completed device-network data request"); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN /* parsing gps data */ if (bm_data_handle->bm_gps_handle != NULL && bm_req_flag_h->req_gps_data) { _DBG("parsing gps data"); @@ -1451,7 +1434,6 @@ int bm_get_data_from_handles(void) bm_engine_set_req_flag_handle(BM_PLUGIN_ID_GPS_SENSOR, true); } _DBG("completed gps data request"); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ ret_val = bm_insert_appid_session_usage_to_db(); BM_CHECK_VAL((ret_val == BATTERY_MONITOR_ERROR_NONE), "battery session logging failure"); @@ -1493,11 +1475,7 @@ int bm_start_getting_feature_data(void) bm_update_plugin_request_time(); /* request data from each plugin & store its handle */ -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) { -#else - for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) { -#endif bm_get_feature_plugin_handle(&bm_plugin, id); handle = NULL; if (!bm_plugin || !bm_plugin->api) { @@ -1562,7 +1540,6 @@ int bm_start_getting_feature_data(void) bm_data_handle->bm_dn_handle = (bm_device_network_st *)(handle); } break; -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN case BM_PLUGIN_ID_GPS_SENSOR: /* GPS Sensor Data */ ret_val = bm_plugin->api->get_feature_data(&handle, id); if (ret_val != BATTERY_MONITOR_ERROR_NONE) { @@ -1574,7 +1551,6 @@ int bm_start_getting_feature_data(void) bm_data_handle->bm_gps_handle = (bm_gps_st *)(handle); } break; -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ default: break; } diff --git a/src/bm_server_db.c b/src/bm_server_db.c index a3154e1..24923a2 100644..100755 --- a/src/bm_server_db.c +++ b/src/bm_server_db.c @@ -366,10 +366,8 @@ static int bm_appid_usage_convert_to_sql(appid_usage_s *bm_app_type, bm_stmt hst bm_query_bind_int(hstmt, count++, bm_app_type->rId_cpu); bm_query_bind_int(hstmt, count++, bm_app_type->rId_display); bm_query_bind_int(hstmt, count++, bm_app_type->rId_device_network); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_query_bind_int(hstmt, count++, bm_app_type->rId_gps); bm_query_bind_int(hstmt, count++, bm_app_type->rId_battery); -#endif EXIT; return count; } @@ -556,10 +554,8 @@ static void bm_convert_column_to_appid_usage(bm_stmt hstmt, appid_usage_s* bm_ap bm_app_type->rId_cpu = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_CPU); bm_app_type->rId_display = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_DISPLAY); bm_app_type->rId_device_network = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_DEV_NTW); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_app_type->rId_gps = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_GPS); bm_app_type->rId_battery = -1; -#endif EXIT; return; @@ -1076,14 +1072,9 @@ static int bm_appid_usage_insert_to_db(sqlite3 *bm_db_handle, appid_usage_s *bm_ return BATTERY_MONITOR_ERROR_INVALID_PARAMETER; BM_MEMSET(query, 0x00, sizeof(query)); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN BM_SNPRINTF(query, sizeof(query), \ "INSERT INTO %s( AppId, log_time, rId_ble, rId_wifi, rId_cpu, rId_display, rId_device_network, rId_gps, rId_battery ) values " "(?, ?, ?, ?, ?, ?, ?, ?, ?)", BATTERY_MONITOR_APP_ID_USAGE_TABLE); -#else - BM_SNPRINTF(query, sizeof(query), "INSERT INTO %s( AppId, log_time, rId_ble, rId_wifi, rId_cpu, rId_display, rId_device_network) values " - "(?, ?, ?, ?, ?, ?, ?)", BATTERY_MONITOR_APP_ID_USAGE_TABLE); -#endif hstmt = bm_prepare_query(bm_db_handle, query); if (bm_db_err_code(bm_db_handle) == SQLITE_PERM) { diff --git a/src/bm_util.c b/src/bm_util.c index ec01e36..efefc0f 100644..100755 --- a/src/bm_util.c +++ b/src/bm_util.c @@ -287,10 +287,8 @@ GVariant* bm_marshal_serialized_data(const bm_total_consumption_h data) g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_DN_DATA_ID, g_variant_new_int32(in_data->dn_val)); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_GPS_DATA_ID, g_variant_new_int32(in_data->gps_val)); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_BATTERY_DATA_ID, g_variant_new_int32(in_data->bat_val)); @@ -309,9 +307,7 @@ const char *bm_get_resource_id_string(gint resource_id) BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_DISPLAY, BATTERY_MONITOR_DP_DATA_ID) BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_DEVICE_NETWORK, BATTERY_MONITOR_DN_DATA_ID) BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_GPS_SENSOR, BATTERY_MONITOR_GPS_DATA_ID) -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN BM_RESOURCE_ID_TO_STR(BM_PLUGIN_CONST_BATTERY, BATTERY_MONITOR_BATTERY_DATA_ID) -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ default: EXIT; @@ -844,7 +840,6 @@ void bm_set_free_device_network_data_handle(bm_device_network_st **dn_handle) return; } -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle) { ENTER; @@ -891,7 +886,6 @@ void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle) EXIT; return; } -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ void bm_set_free_data_handles(bm_feature_data_h* data_hdl) { @@ -902,9 +896,7 @@ void bm_set_free_data_handles(bm_feature_data_h* data_hdl) bm_set_free_cpu_data_handle(&((*data_hdl)->bm_cpu_handle)); bm_set_free_display_data_handle(&((*data_hdl)->bm_display_handle)); bm_set_free_device_network_data_handle(&((*data_hdl)->bm_dn_handle)); -#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN bm_set_free_gps_sensor_data_handle(&((*data_hdl)->bm_gps_handle)); -#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */ BM_FREE(*data_hdl); |