* @brief Handle for battery consumption, either total or summary for the selected application.
* @since_tizen 5.5
*
- * @see battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids()
+ * @see battery_monitor_get_power_usage_by_app_for_all_resources()
*/
-typedef struct battery_monitor_total_consumption_s* battery_monitor_h;
+typedef struct battery_monitor_total_consumption_s* battery_usage_data_h;
/**
* @brief Destroys the Battery Consumption handle and releases all its resources.
* @since_tizen 5.5
*
- * @param[in] handle Battery usage consumption handle for the application
+ * @param[in] result Battery usage consumption handle for the application
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_NOT_SUPPORTED Feature Not Supported
* @retval #BATTERY_MONITOR_ERROR_INVALID_PARAMETER Invalid Parameter
*/
-int battery_monitor_destroy(battery_monitor_h handle);
+int battery_monitor_battery_usage_data_destroy(battery_usage_data_h result);
/**
- * @brief Gets the battery consumption in mAh (milli-Ampere hour) for specific resource from available data handle.
+ * @brief Gets the battery consumption in mAh (milli-Ampere hour) for specific resource from available data usage handle.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @param[in] handle Battery consumption data handle for the application
- * @param[in] resource_id Identifier of resource type. BLE, WiFi, CPU etc
- * @param[out] battery_usage Battery consumption in mAh for @a resource_id
+ * @param[in] result Battery consumption data usage handle for the application
+ * @param[in] resource Identifier of resource type. BLE, WiFi, CPU etc
+ * @param[out] usage Battery consumption in mAh for @a resource
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_PERMISSION_DENIED Permission Denied
* @retval #BATTERY_MONITOR_ERROR_INVALID_PARAMETER Invalid Parameter
*
- * @pre call battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids() to get data handle
+ * @pre call battery_monitor_get_power_usage_by_app_for_all_resources() to get data handle
*/
-int battery_monitor_get_power_usage_for_resource_id_from_handle(battery_monitor_h handle, battery_monitor_resource_id_e resource_id, double *battery_usage);
+int battery_monitor_usage_data_get_power_usage_per_resource(battery_usage_data_h result, battery_monitor_resource_id_e resource, double* usage);
/**
- * @brief Gets the #battery_monitor_h with battery consumption values in mAh (milli-Ampere hour) by the specified application in custom interval.
+ * @brief Gets the #battery_usage_data_h with battery consumption values in mAh (milli-Ampere hour) by the specified application in custom interval.
+ * Data within the last 7 days can be retrieved.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @remarks The @a handle should be released using battery_monitor_destroy().
+ * @remarks The @a result handle should be released using battery_monitor_battery_usage_data_destroy().
*
- * @param[in] app_id Application ID of the application for which battery usage is required
- * @param[in] start_time Start Time for data in Epoch Time (in seconds)
- * @param[in] end_time End Time for data in Epoch Time (in seconds)
- * @param[out] handle Battery usage consumption data handle for the application
+ * @param[in] appid Application ID of the application for which battery usage is required
+ * @param[in] from Start Time for data in Epoch Time (in seconds)
+ * @param[in] to End Time for data in Epoch Time (in seconds)
+ * @param[out] result Battery consumption data handle for the application
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
*
- * @see battery_monitor_get_power_usage_for_resource_id_from_handle()
+ * @see battery_monitor_usage_data_get_power_usage_per_resource()
*/
-int battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids(char* app_id, long long int start_time, long long int end_time, battery_monitor_h *handle);
+int battery_monitor_get_power_usage_by_app_for_all_resources(const char* appid, time_t from, time_t to, battery_usage_data_h* result);
/**
* @brief Gets the battery consumption in mAh (milli-Ampere hour) for the specific resource for the given application in custom interval.
+ * Data within the last 7 days can be retrieved.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @param[in] app_id Application ID of the application for which battery usage is required
- * @param[in] resource_id Identifier of resource type. BLE, WiFi, CPU etc
- * @param[in] start_time Start Time for data in Epoch Time (in seconds)
- * @param[in] end_time End Time for data in Epoch Time (in seconds)
- * @param[out] battery_usage Battery consumption in mAh for the application
+ * @param[in] appid Application ID of the application for which battery usage is required
+ * @param[in] resource Identifier of resource type. BLE, WiFi, CPU etc
+ * @param[in] from Start Time for data in Epoch Time (in seconds)
+ * @param[in] to End Time for data in Epoch Time (in seconds)
+ * @param[out] usage Battery consumption in mAh for the application
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
*/
-int battery_monitor_get_power_usage_by_app_id_for_resource_id(char* app_id, battery_monitor_resource_id_e resource_id,
- long long int start_time, long long int end_time, double* battery_usage);
+int battery_monitor_get_power_usage_by_app_per_resource(const char* appid, battery_monitor_resource_id_e resource, time_t from, time_t to, double* usage);
/**
- * @brief Gets the total battery usage in mAh (milli-Ampere hour) by an application for certain time interval.
+ * @brief Gets the total battery usage in mAh (milli-Ampere hour) by an application for certain time interval. Data within the last 7 days can be retrieved.
* @details This will be sum of all battery consumed by resources used by application.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @param[in] app_id Application ID of the application for which battery usage is required
- * @param[in] start_time Start Time for data in Epoch Time (in seconds)
- * @param[in] end_time End Time for data in Epoch Time (in seconds)
- * @param[out] battery_usage Battery consumption in mAh for the application
+ * @param[in] appid Application ID of the application for which battery usage is required
+ * @param[in] from Start Time for data in Epoch Time (in seconds)
+ * @param[in] to End Time for data in Epoch Time (in seconds)
+ * @param[out] usage Battery consumption in mAh for the application
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
*/
-int battery_monitor_get_total_power_usage_by_app_id(char* app_id, long long int start_time, long long int end_time, double* battery_usage);
+int battery_monitor_get_power_usage_by_app(const char* appid, time_t from, time_t to, double* usage);
/**
- * @brief Gets the battery usage in mAh (milli-Ampere hour) by a resource for certain time interval.
+ * @brief Gets the battery usage in mAh (milli-Ampere hour) by a resource for certain time interval. Data within the last 7 days can be retrieved.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @param[in] resource_id Resource identifier for which battery usage is requested
- * @param[in] start_time Start Time for data in Epoch Time (in seconds)
- * @param[in] end_time End Time for data in Epoch Time (in seconds)
- * @param[out] battery_usage Battery consumption in mAh (milli-Ampere hour) for resource-id
+ * @param[in] resource Resource identifier for which battery usage is requested
+ * @param[in] from Start Time for data in Epoch Time (in seconds)
+ * @param[in] to End Time for data in Epoch Time (in seconds)
+ * @param[out] usage Battery consumption in mAh (milli-Ampere hour) for resource
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
*/
-int battery_monitor_get_total_power_usage_by_resource_id(battery_monitor_resource_id_e resource_id,
- long long int start_time, long long int end_time, double* battery_usage);
+int battery_monitor_get_power_usage_by_resource(battery_monitor_resource_id_e resource, time_t from, time_t to, double* usage);
/**
* @}
return bm_server;
}
-static int battery_monitor_check_time_interval(long long start_time, long long end_time)
+static int battery_monitor_check_time_interval(time_t *start_time, time_t *end_time)
{
ENTER;
- time_t curr_time;
- long int ret = 0;
- time(&curr_time);
- if (curr_time == -1) {
+ time_t now;
+ time(&now);
+ if (now == -1) {
_ERR("Time failed");
return -1;
}
- ret = curr_time;
- _DBG("current time [%ld]", ret);
- if (start_time < end_time) {
- if ((start_time > (ret - tmin)) && (end_time <= ret))
- return BATTERY_MONITOR_ERROR_NONE;
+ _DBG("current time [%ld]", now);
+ if (*start_time >= 0 && *start_time < *end_time) {
+ if ((*start_time >= (now - tmin)) && (*end_time <= now))
+ _INFO("Time Checked");
+ // Add to modify out of bound time.
+ else {
+ if (*start_time < (now - tmin))
+ *start_time = now - tmin;
+ if (*end_time > now)
+ *end_time = now;
+ }
+ return BATTERY_MONITOR_ERROR_NONE;
}
EXIT;
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
-BM_API int battery_monitor_destroy(battery_monitor_h handle)
+BM_API int battery_monitor_battery_usage_data_destroy(battery_usage_data_h result)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(handle);
+ BM_CHECK_INPUT_PARAM(result);
- battery_monitor_h data_handle = handle;
+ battery_usage_data_h data_handle = result;
BM_FREE(data_handle);
return BATTERY_MONITOR_ERROR_NONE;
}
-BM_API int battery_monitor_get_power_usage_for_resource_id_from_handle(battery_monitor_h handle, battery_monitor_resource_id_e resource_id, double *battery_usage)
+BM_API int battery_monitor_usage_data_get_power_usage_per_resource(battery_usage_data_h result, battery_monitor_resource_id_e resource, double *usage)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(handle);
- BM_CHECK_INPUT_PARAM(battery_usage);
+ BM_CHECK_INPUT_PARAM(result);
+ BM_CHECK_INPUT_PARAM(usage);
- if (resource_id >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
+ if (resource >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
_ERR("Unknown resource id specified");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
int error_code = BATTERY_MONITOR_ERROR_NONE;
- error_code = battery_monitor_resource_id_is_supported(resource_id);
+ error_code = battery_monitor_resource_id_is_supported(resource);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Not Supported Resource ID");
return BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND;
}
battery_monitor_total_consumption_s *data_handle = \
- (battery_monitor_total_consumption_s *)handle;
+ (battery_monitor_total_consumption_s *)result;
- switch (resource_id) {
+ switch (resource) {
case BATTERY_MONITOR_RESOURCE_ID_BLE:
- *battery_usage = (double)data_handle->ble_val/cmah;
+ *usage = (double)data_handle->ble_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_WIFI:
- *battery_usage = (double)data_handle->wifi_val/cmah;
+ *usage = (double)data_handle->wifi_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_CPU:
- *battery_usage = (double)data_handle->cpu_val/cmah;
+ *usage = (double)data_handle->cpu_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_DISPLAY:
- *battery_usage = (double)data_handle->dp_val/cmah;
+ *usage = (double)data_handle->dp_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK:
- *battery_usage = (double)data_handle->dn_val/cmah;
+ *usage = (double)data_handle->dn_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR:
- *battery_usage = (double)data_handle->gps_val/cmah;
+ *usage = (double)data_handle->gps_val/cmah;
break;
default:
break;
return BATTERY_MONITOR_ERROR_NONE;
}
-BM_API int battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids(char* app_id, long long int start_time, long long int end_time, battery_monitor_h *handle)
+BM_API int battery_monitor_get_power_usage_by_app_for_all_resources(const char* appid, time_t from, time_t to, battery_usage_data_h *result)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(app_id);
- BM_CHECK_INPUT_PARAM(handle);
+ BM_CHECK_INPUT_PARAM(appid);
+ BM_CHECK_INPUT_PARAM(result);
int error_code = BATTERY_MONITOR_ERROR_NONE;
- error_code = battery_monitor_check_time_interval(start_time, end_time);
+ error_code = battery_monitor_check_time_interval(&from, &to);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- _INFO("Consumption requested for [%s] for start_time(s) [%lld] and end_time(s) [%lld]", app_id, start_time, end_time);
+ long long int start_time = from; long long int end_time = to;
+ _INFO("Consumption requested for [%s] for start_time(s) [%lld] and end_time(s) [%lld]", appid, start_time, end_time);
GError *error = NULL;
bm_server = battery_monitor_get_instance();
BM_CATCH_ERROR((bm_server != NULL), {}, BATTERY_MONITOR_ERROR_PERMISSION_DENIED, "Failed to get dbus.");
GVariant *handle_variant = NULL;
_INFO("before IPC call - get_usage_handle_by_app_id_for_all_resource_id_custom_interval_sync()");
- bool is_success = battery_monitor_call_get_usage_handle_by_app_id_for_all_resource_id_custom_interval_sync(bm_server, app_id, start_time, end_time,
+ bool is_success = battery_monitor_call_get_usage_handle_by_app_id_for_all_resource_id_custom_interval_sync(bm_server, appid, start_time, end_time,
(int)getuid(), &handle_variant, NULL, &error);
battery_monitor_release_instance();
_INFO("after un-marshal data");
- *handle = (battery_monitor_h)data_handle;
+ *result = (battery_usage_data_h)data_handle;
_INFO("battery_get_usage_handle_by_app_id_for_all_resource_id_custom_interval() - SUCCESS");
return error_code;
}
-BM_API int battery_monitor_get_power_usage_by_app_id_for_resource_id(char* app_id, battery_monitor_resource_id_e resource_id,
- long long int start_time, long long int end_time, double* battery_usage)
+BM_API int battery_monitor_get_power_usage_by_app_per_resource(const char* appid, battery_monitor_resource_id_e resource,
+ time_t from, time_t to, double *usage)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(app_id);
- BM_CHECK_INPUT_PARAM(battery_usage);
+ BM_CHECK_INPUT_PARAM(appid);
+ BM_CHECK_INPUT_PARAM(usage);
- if (resource_id >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
+ if (resource >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
_ERR("Unknown resource id specified");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
int error_code = BATTERY_MONITOR_ERROR_NONE;
- error_code = battery_monitor_resource_id_is_supported(resource_id);
+ error_code = battery_monitor_resource_id_is_supported(resource);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Not Supported Resource ID");
return BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND;
}
- error_code = battery_monitor_check_time_interval(start_time, end_time);
+ error_code = battery_monitor_check_time_interval(&from, &to);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
+ long long int start_time = from; long long int end_time = to;
double battery_consumption = 0;
GError *error = NULL;
- _INFO("Consumption requested for [%s], resource_id(%d) for start_time(s) [%lld] and end_time(s) [%lld]", app_id, resource_id, start_time, end_time);
+ _INFO("Consumption requested for [%s], resource_id(%d) for start_time(s) [%lld] and end_time(s) [%lld]", appid, resource, start_time, end_time);
bm_server = battery_monitor_get_instance();
BM_CATCH_ERROR((bm_server != NULL), {}, BATTERY_MONITOR_ERROR_PERMISSION_DENIED, "Failed to get dbus.");
- _INFO("before IPC call - app_id(%s), resource_id(%d), start_time(%lld), end_time(%lld)", app_id, resource_id, start_time, end_time);
+ _INFO("before IPC call - app_id(%s), resource_id(%d), start_time(%lld), end_time(%lld)", appid, resource, start_time, end_time);
- bool is_success = battery_monitor_call_get_mah_usage_by_app_id_for_resource_id_custom_interval_sync(bm_server, app_id, resource_id,
+ bool is_success = battery_monitor_call_get_mah_usage_by_app_id_for_resource_id_custom_interval_sync(bm_server, appid, resource,
start_time, end_time, (int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
BM_CATCH_ERROR((is_success != false), {}, battery_monitor_get_error_code(is_success, error), "Failed to get dbus.");
g_clear_error(&error);
- *battery_usage = battery_consumption;
+ *usage = battery_consumption;
_INFO("battery_get_mah_usage_by_app_id_for_resource_id_custom_interval() - SUCCESS");
return error_code;
}
-BM_API int battery_monitor_get_total_power_usage_by_app_id(char* app_id, long long int start_time, long long int end_time, double* battery_usage)
+BM_API int battery_monitor_get_power_usage_by_app(const char* appid, time_t from, time_t to, double* usage)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(app_id);
- BM_CHECK_INPUT_PARAM(battery_usage);
+ BM_CHECK_INPUT_PARAM(appid);
+ BM_CHECK_INPUT_PARAM(usage);
int error_code = BATTERY_MONITOR_ERROR_NONE;
- error_code = battery_monitor_check_time_interval(start_time, end_time);
+ error_code = battery_monitor_check_time_interval(&from, &to);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
+ long long int start_time = from; long long int end_time = to;
double battery_consumption = 0;
GError *error = NULL;
- _INFO("Consumption requested for app_id [%s] for start_time(s) [%lld] and end_time(s) [%lld]", app_id, start_time, end_time);
+ _INFO("Consumption requested for app_id [%s] for start_time(s) [%lld] and end_time(s) [%lld]", appid, start_time, end_time);
bm_server = battery_monitor_get_instance();
BM_CATCH_ERROR((bm_server != NULL), {}, BATTERY_MONITOR_ERROR_PERMISSION_DENIED, "Failed to get dbus.");
- _INFO("before IPC call - app_id(%s), start_time (%lld), end_time (%lld)", app_id, start_time, end_time);
+ _INFO("before IPC call - app_id(%s), start_time (%lld), end_time (%lld)", appid, start_time, end_time);
- bool is_success = battery_monitor_call_get_total_mah_usage_by_app_id_custom_interval_sync(bm_server, app_id, start_time, end_time,
+ bool is_success = battery_monitor_call_get_total_mah_usage_by_app_id_custom_interval_sync(bm_server, appid, start_time, end_time,
(int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
_INFO("after IPC call - battery_consumption(%lf)", battery_consumption);
- *battery_usage = battery_consumption;
+ *usage = battery_consumption;
BM_CATCH_ERROR((is_success != false), {}, battery_monitor_get_error_code(is_success, error), "Failed to get dbus.");
g_clear_error(&error);
return error_code;
}
-BM_API int battery_monitor_get_total_power_usage_by_resource_id(battery_monitor_resource_id_e resource_id,
- long long int start_time, long long int end_time, double* battery_usage)
+BM_API int battery_monitor_get_power_usage_by_resource(battery_monitor_resource_id_e resource, time_t from, time_t to, double* usage)
{
ENTER;
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
- BM_CHECK_INPUT_PARAM(battery_usage);
+ BM_CHECK_INPUT_PARAM(usage);
- if (resource_id >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
+ if (resource >= BATTERY_MONITOR_RESOURCE_ID_MAX) {
_ERR("Unknown resource id specified");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
int error_code = BATTERY_MONITOR_ERROR_NONE;
- error_code = battery_monitor_resource_id_is_supported(resource_id);
+ error_code = battery_monitor_resource_id_is_supported(resource);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Not Supported Resource ID");
return BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND;
}
- error_code = battery_monitor_check_time_interval(start_time, end_time);
+
+ error_code = battery_monitor_check_time_interval(&from, &to);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
+ long long int start_time = from; long long int end_time = to;
double battery_consumption = 0;
GError *error = NULL;
- _INFO("Consumption requested for resource_id [%d] for start_time(s) [%lld] and end_time(s) [%lld]", resource_id, start_time, end_time);
+ _INFO("Consumption requested for resource_id [%d] for start_time(s) [%lld] and end_time(s) [%lld]", resource, start_time, end_time);
bm_server = battery_monitor_get_instance();
BM_CATCH_ERROR((bm_server != NULL), {}, BATTERY_MONITOR_ERROR_PERMISSION_DENIED, "Failed to get dbus.");
- _INFO("before IPC call - resource_id(%d), start_time (%lld), end_time (%lld)", resource_id, start_time, end_time);
+ _INFO("before IPC call - resource_id(%d), start_time (%lld), end_time (%lld)", resource, start_time, end_time);
- bool is_success = battery_monitor_call_get_total_mah_usage_by_resource_id_custom_interval_sync(bm_server, resource_id, start_time,
+ bool is_success = battery_monitor_call_get_total_mah_usage_by_resource_id_custom_interval_sync(bm_server, resource, start_time,
end_time, (int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
_INFO("after IPC call - battery_consumption(%lf)", battery_consumption);
- *battery_usage = battery_consumption;
+ *usage = battery_consumption;
BM_CATCH_ERROR((is_success != false), {}, battery_monitor_get_error_code(is_success, error), "Failed to get dbus.");
g_clear_error(&error);
}
testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_total_power_usage_by_app_id(app_name, start_time, end_time, &battery_usage);
+ error_code = battery_monitor_get_power_usage_by_app(app_name, (time_t)start_time, (time_t)end_time, &battery_usage);
if (error_code == BATTERY_MONITOR_ERROR_NONE)
testapp_print(" battery_monitor_get_total_usage_by_app_id for APPID [%s] returned Usage of [%lf] & Error Code [%d] \n", app_name, battery_usage, error_code);
}
testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_total_power_usage_by_resource_id(resource_id, start_time, end_time, &battery_usage);
+ error_code = battery_monitor_get_power_usage_by_resource(resource_id, (time_t)start_time, (time_t)end_time, &battery_usage);
if (error_code == BATTERY_MONITOR_ERROR_NONE)
testapp_print(" battery_monitor_get_total_usage_by_resource_id for RID [%d], returned Usage of [%lf] & Error Code [%d] \n", resource_id, battery_usage, error_code);
char app_name[56] = {0, };
int error_code = BATTERY_MONITOR_ERROR_NONE;
- battery_monitor_h data_handle = NULL;
+ battery_usage_data_h data_handle = NULL;
testapp_print("\n Input AppID using Look Up table:\n");
if (0 >= scanf("%55s", app_name)) {
testapp_print("Invalid input ");
}
testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids(app_name, start_time, end_time, &data_handle);
+ error_code = battery_monitor_get_power_usage_by_app_for_all_resources(app_name, (time_t)start_time, (time_t)end_time, &data_handle);
if (error_code == BATTERY_MONITOR_ERROR_NONE) {
testapp_print ("Valid Handle Received, Value of error_code is [%d] \n", error_code);
for (int id = BATTERY_MONITOR_RESOURCE_ID_BLE; id <= BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR; ++id) {
#endif
battery_usage = -1;
- error_code = battery_monitor_get_power_usage_for_resource_id_from_handle(data_handle, id, &battery_usage);
+ error_code = battery_monitor_usage_data_get_power_usage_per_resource(data_handle, id, &battery_usage);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
if (error_code == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND)
}
}
- error_code = battery_monitor_destroy(data_handle);
+ error_code = battery_monitor_battery_usage_data_destroy(data_handle);
if (error_code != BATTERY_MONITOR_ERROR_NONE)
testapp_print ("Handle Destroy Failed");
}
testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_power_usage_by_app_id_for_resource_id(app_name, resource_id, start_time, end_time, &battery_usage);
+ error_code = battery_monitor_get_power_usage_by_app_per_resource(app_name, resource_id, (time_t)start_time, (time_t)end_time, &battery_usage);
if (error_code == BATTERY_MONITOR_ERROR_NONE)
testapp_print (" Battery Usage for APPID [%s], of RID [%d] is [%lf]", app_name, resource_id, battery_usage);