* power consumed by individual resources which are used by the application at the time of running.
*
* The API's provide the following functionality:
- * - battery consumption in percent for specific resource from available data.
- * - battery consumption in percent for all resources used by app_id.
- * - battery consumption in percent by an app-id for a specific resource.
- * - total battery usage in percent by an app-id for certain time duration.
- * - battery consumption in percent usage by a resource for certain time duration.
+ * Battery Power Usage in mAh (milli-Ampere-Hour) for, between a custom start & end time.
+ * - battery consumption in mAh for specific resource from available data.
+ * - battery consumption in mAh for all resources used by app_id.
+ * - battery consumption in mAh by an app-id for a specific resource.
+ * - total battery usage in mAh by an app-id for certain start & end time pair.
+ * - battery consumption in mAh by a resource for certain start & end time pair.
*
* @section CAPI_SYSTEM_BATTERY_BATTERY_MONITOR_MODULE_FEATURE Related Features
* The API's defined are related with the following features:\n
- * - http://tizen.org/feature/battery\n
+ * - %http://tizen.org/feature/battery\n
*
* It is recommended to design applications with regard to features, for reliability.\n
*
* @since_tizen 5.5
*/
typedef enum {
- BATTERY_MONITOR_RESOURCE_ID_BLE = 0, /**< Bluetooth Low Energy */
- BATTERY_MONITOR_RESOURCE_ID_WIFI, /**< Wi-Fi */
- BATTERY_MONITOR_RESOURCE_ID_CPU, /**< CPU */
- BATTERY_MONITOR_RESOURCE_ID_DISPLAY, /**< Display */
- BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK, /**< Network */
- BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR, /**< GPS */
- BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR, /**< Heart Rate Monitor */
- BATTERY_MONITOR_RESOURCE_ID_BATTERY, /**< Battery */
+ BATTERY_MONITOR_RESOURCE_ID_BLE = 0, /**< Bluetooth */
+ BATTERY_MONITOR_RESOURCE_ID_WIFI = 1, /**< Wi-Fi */
+ BATTERY_MONITOR_RESOURCE_ID_CPU = 2, /**< CPU */
+ BATTERY_MONITOR_RESOURCE_ID_DISPLAY = 3, /**< Display */
+ BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK = 4, /**< Device Network */
+ BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR = 5, /**< GPS Sensor*/
+ BATTERY_MONITOR_RESOURCE_ID_MAX, /**< Use for iterating over enums only */
} battery_monitor_resource_id_e;
-/**
- * @brief Enumeration for feature data collection period.
- * @since_tizen 5.5
- */
-typedef enum {
- BATTERY_MONITOR_DURATION_TYPE_1DAY = 0, /**< Set the period from a day ago to now */
- BATTERY_MONITOR_DURATION_TYPE_1WEEK, /**< Set the period from a week ago to now */
-} battery_monitor_duration_type_e;
-
/**
* @brief Handle for battery consumption, either total or summary for the selected application.
* @since_tizen 5.5
*
- * @see battery_monitor_create()
- * @see battery_monitor_get_usage_by_app_id_for_all_resource_id()
+ * @see battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids()
*/
typedef struct battery_monitor_total_consumption_s* battery_monitor_h;
-/**
- * @brief Creates a handle to the Battery Consumption for getting resource based usage.
- * @since_tizen 5.5
- *
- * @remarks @a handle should be released using battery_monitor_destroy().
- *
- * @param[out] handle Battery usage consumption handle for the application
- *
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #BATTERY_MONITOR_ERROR_NONE Successful
- * @retval #BATTERY_MONITOR_ERROR_NOT_SUPPORTED Feature Not Supported
- * @retval #BATTERY_MONITOR_ERROR_INVALID_PARAMETER Invalid Parameter
- * @retval #BATTERY_MONITOR_ERROR_OUT_OF_MEMORY Out of Memory
- */
-int battery_monitor_create(battery_monitor_h *handle);
-
/**
* @brief Destroys the Battery Consumption handle and releases all its resources.
* @since_tizen 5.5
int battery_monitor_destroy(battery_monitor_h handle);
/**
- * @brief Gets the battery-percent for specific resource from available data.
+ * @brief Gets the battery consumption in mAh (milli-Ampere hour) for specific resource from available data handle.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
*
- * @param[in] handle Battery usage consumption handle for the application
+ * @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 usage consumption for @a resource_id
+ * @param[out] battery_usage Battery consumption in mAh for @a resource_id
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_NOT_SUPPORTED Feature Not Supported
* @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
*/
-int battery_monitor_get_usage_for_resource_id(battery_monitor_h handle, battery_monitor_resource_id_e resource_id, int *battery_usage);
+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);
/**
- * @brief Gets the #battery_monitor_h with battery consumption by the specified application.
+ * @brief Gets the #battery_monitor_h with battery consumption values in mAh (milli-Ampere hour) by the specified application in custom interval.
* @since_tizen 5.5
* @privlevel public
* @privilege %http://tizen.org/privilege/systemmonitor
* @remarks The @a handle should be released using battery_monitor_destroy().
*
* @param[in] app_id Application ID of the application for which battery usage is required
- * @param[in] duration Time duration for which battery usage is requested
- * @param[out] handle Battery usage consumption for the application
+ * @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
*
* @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_usage_for_resource_id()
+ * @see battery_monitor_get_power_usage_for_resource_id_from_handle()
*/
-int battery_monitor_get_usage_by_app_id_for_all_resource_id(char *app_id, battery_monitor_duration_type_e duration, battery_monitor_h *handle);
+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);
/**
- * @brief Gets the battery consumption for the specific resource for the given application.
+ * @brief Gets the battery consumption in mAh (milli-Ampere hour) for the specific resource for the given application in custom interval.
* @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] duration Time duration for which battery usage is requested
- * @param[out] battery_usage Battery usage consumption for the application
+ * @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
*
* @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_usage_by_app_id_for_resource_id(char *app_id, battery_monitor_resource_id_e resource_id, battery_monitor_duration_type_e duration, int *battery_usage);
+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);
/**
- * @brief Gets the total battery usage in percent by an application for certain time duration.
+ * @brief Gets the total battery usage in mAh (milli-Ampere hour) by an application for certain time interval.
* @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] duration Time duration for which battery usage is requested
- * @param[out] battery_usage Battery usage consumption for the application
+ * @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
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_DB_FAILED DB operation failed
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
-*/
-int battery_monitor_get_total_usage_by_app_id(char *app_id, battery_monitor_duration_type_e duration, int *battery_usage);
+ */
+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);
/**
- * @brief Gets the battery-percent usage by a resource for certain time duration.
+ * @brief Gets the battery usage in mAh (milli-Ampere hour) by a resource for certain time interval.
* @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] duration Time duration for which battery usage is requested
- * @param[out] battery_usage Battery usage consumption for resource-id
+ * @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
*
* @return @c 0 on success,
* otherwise a negative error value
* @retval #BATTERY_MONITOR_ERROR_DB_FAILED DB operation failed
* @retval #BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND Record Not found
* @retval #BATTERY_MONITOR_ERROR_INTERNAL Internal Error
-*/
-int battery_monitor_get_total_usage_by_resource_id(battery_monitor_resource_id_e resource_id, battery_monitor_duration_type_e duration, int *battery_usage);
+ */
+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);
/**
* @}
/* feature supported macros */
#define BATTERY_FEATURE "http://tizen.org/feature/battery"
+#define BATTERY_MONITOR_BLE_RES_ID "http://tizen.org/feature/network.bluetooth"
+#define BATTERY_MONITOR_WIFI_RES_ID "http://tizen.org/feature/network.wifi"
+/*#define BATTERY_MONITOR_CPU_RES_ID : CPU is always present" */
+#define BATTERY_MONITOR_DP_RES_ID "http://tizen.org/feature/screen"
+#define BATTERY_MONITOR_DN_RES_ID "http://tizen.org/feature/network.telephony"
+#define BATTERY_MONITOR_GPS_RES_ID "http://tizen.org/feature/location.gps"
#define CHECK_BATTERY_FEATURE_SUPPORTED(feature_name) \
do { \
#define BATTERY_MONITOR_DP_DATA_ID "display"
#define BATTERY_MONITOR_DN_DATA_ID "device-network"
#define BATTERY_MONITOR_GPS_DATA_ID "gps"
-#define BATTERY_MONITOR_HRM_DATA_ID "hrm"
-#define BATTERY_MONITOR_BATTERY_DATA_ID "battery"
/* validating input param */
#define BM_CHECK_INPUT_PARAM(arg) \
void unmarshal_serialized_data(GVariant *handle, battery_monitor_total_consumption_s *data_handle);
+int battery_monitor_resource_id_is_supported(battery_monitor_resource_id_e resource_id);
+
#ifdef __cplusplus
}
#endif
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/tizen/battery/monitor">
<interface name="org.tizen.battery.monitor">
- <method name="get_usage_by_app_id_for_resource_id">
+ <method name="get_mah_usage_by_app_id_for_resource_id_custom_interval">
<arg type="s" name="app_id" direction="in" />
<arg type="i" name="resource_id" direction="in" />
- <arg type="i" name="duration" direction="in" />
+ <arg type="x" name="start_time" direction="in" />
+ <arg type="x" name="end_time" direction="in" />
<arg type="i" name="uid" direction="in" />
- <arg type="i" name="battery_usage" direction="out" />
+ <arg type="d" name="battery_usage" direction="out" />
</method>
- <method name="get_total_usage_by_app_id">
+ <method name="get_total_mah_usage_by_app_id_custom_interval">
<arg type="s" name="app_id" direction="in" />
- <arg type="i" name="duration" direction="in" />
+ <arg type="x" name="start_time" direction="in" />
+ <arg type="x" name="end_time" direction="in" />
<arg type="i" name="uid" direction="in" />
- <arg type="i" name="battery_usage" direction="out" />
+ <arg type="d" name="battery_usage" direction="out" />
</method>
- <method name="get_total_usage_by_resource_id">
- <arg type="i" name="resource_id" direction="in" />
- <arg type="i" name="duration" direction="in" />
- <arg type="i" name="uid" direction="in" />
- <arg type="i" name="battery_usage" direction="out" />
+ <method name="get_total_mah_usage_by_resource_id_custom_interval">
+ <arg type="i" name="resource_id" direction="in" />
+ <arg type="x" name="start_time" direction="in" />
+ <arg type="x" name="end_time" direction="in" />
+ <arg type="i" name="uid" direction="in" />
+ <arg type="d" name="battery_usage" direction="out" />
</method>
- <method name="get_all_resource_usage">
+ <method name="get_usage_handle_by_app_id_for_all_resource_id_custom_interval">
<arg type="s" name="app_id" direction="in" />
- <arg type="i" name="duration" direction="in" />
+ <arg type="x" name="start_time" direction="in" />
+ <arg type="x" name="end_time" direction="in" />
<arg type="i" name="uid" direction="in" />
<arg type="a{sv}" name="battery_data" direction="out" />
</method>
#include <glib.h>
#include <stdio.h>
#include <pthread.h>
+#include <time.h>
#include "battery_monitor.h"
#include "battery_monitor_util.h"
-#define BATTERY_MONITOR_RESOURCE_ID_MAX (BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR + 1)
-#define BATTERY_MONITOR_DURATION_TYPE_MAX (BATTERY_MONITOR_DURATION_TYPE_1WEEK + 1)
-
+const int tmin = 604800; /* Time interval for 7 days in seconds */
+const double cmah = 3600.00;
static BatteryMonitor *bm_server = NULL;
static GDBusConnection *connection = NULL;
static int instance_count = 0;
return bm_server;
}
-BM_API int battery_monitor_create(battery_monitor_h *handle)
+static int battery_monitor_check_time_interval(long long start_time, long long end_time)
{
ENTER;
+ time_t curr_time;
+ long int ret = 0;
+ time(&curr_time);
+ if (curr_time == -1) {
+ _ERR("Time failed");
+ return -1;
+ }
- CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
-
- BM_CHECK_INPUT_PARAM(handle);
-
- battery_monitor_total_consumption_s *data_handle = \
- (battery_monitor_total_consumption_s *)calloc(1, sizeof(battery_monitor_total_consumption_s));
-
- BM_RETURN_VAL((data_handle != NULL), {}, BATTERY_MONITOR_ERROR_OUT_OF_MEMORY, "memory allocation failed");
-
- data_handle->ble_val = 0;
- data_handle->wifi_val = 0;
- data_handle->cpu_val = 0;
- data_handle->dp_val = 0;
- data_handle->dn_val = 0;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
- data_handle->gps_val = 0;
- data_handle->hrm_val = 0;
- data_handle->bat_val = 0;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN */
-
- *handle = (battery_monitor_h)data_handle;
+ 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;
+ }
EXIT;
- return BATTERY_MONITOR_ERROR_NONE;
+ return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
BM_API int battery_monitor_destroy(battery_monitor_h handle)
return BATTERY_MONITOR_ERROR_NONE;
}
-BM_API int battery_monitor_get_usage_for_resource_id(battery_monitor_h handle, battery_monitor_resource_id_e resource_id, int *battery_usage)
+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)
{
ENTER;
_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);
+ 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 *)handle;
switch (resource_id) {
case BATTERY_MONITOR_RESOURCE_ID_BLE:
- *battery_usage = data_handle->ble_val;
+ *battery_usage = (double)data_handle->ble_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_WIFI:
- *battery_usage = data_handle->wifi_val;
+ *battery_usage = (double)data_handle->wifi_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_CPU:
- *battery_usage = data_handle->cpu_val;
+ *battery_usage = (double)data_handle->cpu_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_DISPLAY:
- *battery_usage = data_handle->dp_val;
+ *battery_usage = (double)data_handle->dp_val/cmah;
break;
case BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK:
- *battery_usage = data_handle->dn_val;
+ *battery_usage = (double)data_handle->dn_val/cmah;
break;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
case BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR:
- *battery_usage = data_handle->gps_val;
- break;
- case BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR:
- *battery_usage = data_handle->hrm_val;
+ *battery_usage = (double)data_handle->gps_val/cmah;
break;
- case BATTERY_MONITOR_RESOURCE_ID_BATTERY:
- *battery_usage = data_handle->bat_val;
- break;
- #endif /* DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN */
default:
break;
}
return BATTERY_MONITOR_ERROR_NONE;
}
-BM_API int battery_monitor_get_usage_by_app_id_for_all_resource_id(char* app_id, battery_monitor_duration_type_e duration, battery_monitor_h *handle)
+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)
{
ENTER;
-
CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_FEATURE);
-
BM_CHECK_INPUT_PARAM(app_id);
BM_CHECK_INPUT_PARAM(handle);
- BM_RETURN_VAL((duration < BATTERY_MONITOR_DURATION_TYPE_MAX), {}, BATTERY_MONITOR_ERROR_INVALID_PARAMETER, "invalid duration");
-
- _INFO("total consumption requested for [%s] for duration [%d]", app_id, duration);
int error_code = BATTERY_MONITOR_ERROR_NONE;
- GError *error = NULL;
+ error_code = battery_monitor_check_time_interval(start_time, end_time);
+ 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);
+ 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_all_resource_usage_sync()");
-
- bool is_success = battery_monitor_call_get_all_resource_usage_sync(bm_server, app_id, duration,
- (int)getuid(), &handle_variant, NULL, &error);
+ _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,
+ (int)getuid(), &handle_variant, NULL, &error);
battery_monitor_release_instance();
-
- _INFO("after IPC call - get_all_resource_usage_sync()");
+ _INFO("after IPC call - get_usage_handle_by_app_id_for_all_resource_id_custom_interval_sync()");
BM_CATCH_ERROR((is_success != false), {}, battery_monitor_get_error_code(is_success, error), "Failed to get dbus.");
g_clear_error(&error);
-
battery_monitor_total_consumption_s *data_handle = \
(battery_monitor_total_consumption_s *)calloc(1, sizeof(battery_monitor_total_consumption_s));
BM_RETURN_VAL((data_handle != NULL), {}, BATTERY_MONITOR_ERROR_OUT_OF_MEMORY, "memory allocation failed");
_INFO("before un-marshal data");
-
unmarshal_serialized_data(handle_variant, data_handle);
g_variant_unref(handle_variant);
*handle = (battery_monitor_h)data_handle;
- _INFO("battery_get_usage_by_app_id_for_all_resource_id() - SUCCESS");
+ _INFO("battery_get_usage_handle_by_app_id_for_all_resource_id_custom_interval() - SUCCESS");
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
CATCH:
g_clear_error(&error);
- _ERR("battery_monitor_call_get_all_resource_usage_sync()=[%d]", error_code);
+ _ERR("battery_monitor_call_get_usage_handle_by_app_id_for_all_resource_id_custom_interval_sync()=[%d]", error_code);
return error_code;
}
-BM_API int battery_monitor_get_usage_by_app_id_for_resource_id(char* app_id, battery_monitor_resource_id_e resource_id,
- battery_monitor_duration_type_e duration, int* battery_usage)
+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)
{
ENTER;
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- if (duration >= BATTERY_MONITOR_DURATION_TYPE_MAX) {
- _ERR("Unknown duration specified");
+ int error_code = BATTERY_MONITOR_ERROR_NONE;
+ error_code = battery_monitor_resource_id_is_supported(resource_id);
+ 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);
+ if (error_code != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- int battery_consumption = 0;
- int error_code = BATTERY_MONITOR_ERROR_NONE;
+ 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);
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), duration(%d)", app_id, resource_id, duration);
+ _INFO("before IPC call - app_id(%s), resource_id(%d), start_time(%lld), end_time(%lld)", app_id, resource_id, start_time, end_time);
- bool is_success = battery_monitor_call_get_usage_by_app_id_for_resource_id_sync(bm_server, app_id, resource_id,
- duration, (int)getuid(), &battery_consumption, NULL, &error);
+ bool is_success = battery_monitor_call_get_mah_usage_by_app_id_for_resource_id_custom_interval_sync(bm_server, app_id, resource_id,
+ start_time, end_time, (int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
- _INFO("after IPC call - battery_consumption(%d)", battery_consumption);
+ _INFO("after IPC call - battery_consumption(%lf)", battery_consumption);
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;
- _INFO("battery_get_usage_by_app_id_for_resource_id() - SUCCESS");
+ _INFO("battery_get_mah_usage_by_app_id_for_resource_id_custom_interval() - SUCCESS");
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
CATCH:
g_clear_error(&error);
- _ERR("battery_monitor_call_get_usage_by_app_id_for_resource_id_sync()=[%d]", error_code);
+ _ERR("battery_monitor_call_get_mah_usage_by_app_id_for_resource_id_custom_interval_sync()=[%d]", error_code);
return error_code;
}
-BM_API int battery_monitor_get_total_usage_by_app_id(char* app_id, battery_monitor_duration_type_e duration, int* battery_usage)
+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)
{
ENTER;
BM_CHECK_INPUT_PARAM(app_id);
BM_CHECK_INPUT_PARAM(battery_usage);
- if (duration >= BATTERY_MONITOR_DURATION_TYPE_MAX) {
- _ERR("Unknown duration specified");
+ int error_code = BATTERY_MONITOR_ERROR_NONE;
+ error_code = battery_monitor_check_time_interval(start_time, end_time);
+ if (error_code != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- int battery_consumption = 0;
- int error_code = BATTERY_MONITOR_ERROR_NONE;
+ 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);
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), duration(%d)", app_id, duration);
+ _INFO("before IPC call - app_id(%s), start_time (%lld), end_time (%lld)", app_id, start_time, end_time);
- bool is_success = battery_monitor_call_get_total_usage_by_app_id_sync(bm_server, app_id, duration,
+ bool is_success = battery_monitor_call_get_total_mah_usage_by_app_id_custom_interval_sync(bm_server, app_id, start_time, end_time,
(int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
- _INFO("after IPC call - battery_consumption(%d)", battery_consumption);
+ _INFO("after IPC call - battery_consumption(%lf)", battery_consumption);
*battery_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);
- _INFO("battery_monitor_call_get_total_usage_by_app_id_sync() - SUCCESS");
+ _INFO("battery_monitor_call_get_total_mah_usage_by_app_id_custom_interval_sync() - SUCCESS");
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
CATCH:
g_clear_error(&error);
- _ERR("battery_monitor_call_get_total_usage_by_app_id_sync()=[%d]", error_code);
+ _ERR("battery_monitor_call_get_total_mah_usage_by_app_id_custom_interval_sync()=[%d]", error_code);
return error_code;
}
-BM_API int battery_monitor_get_total_usage_by_resource_id(battery_monitor_resource_id_e resource_id,
- battery_monitor_duration_type_e duration, int* battery_usage)
+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)
{
ENTER;
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- if (duration >= BATTERY_MONITOR_DURATION_TYPE_MAX) {
- _ERR("Unknown duration specified");
+ int error_code = BATTERY_MONITOR_ERROR_NONE;
+ error_code = battery_monitor_resource_id_is_supported(resource_id);
+ 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);
+ if (error_code != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("Invalid Time Interval: Invalid Params");
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
}
- int battery_consumption = 0;
- int error_code = BATTERY_MONITOR_ERROR_NONE;
+ 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);
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), duration(%d)", resource_id, duration);
+ _INFO("before IPC call - resource_id(%d), start_time (%lld), end_time (%lld)", resource_id, start_time, end_time);
- bool is_success = battery_monitor_call_get_total_usage_by_resource_id_sync(bm_server, resource_id, duration,
- (int)getuid(), &battery_consumption, NULL, &error);
+ bool is_success = battery_monitor_call_get_total_mah_usage_by_resource_id_custom_interval_sync(bm_server, resource_id, start_time,
+ end_time, (int)getuid(), &battery_consumption, NULL, &error);
battery_monitor_release_instance();
- _INFO("after IPC call - battery_consumption(%d)", battery_consumption);
+ _INFO("after IPC call - battery_consumption(%lf)", battery_consumption);
*battery_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);
- _INFO("battery_get_total_usage_by_resource_id() - SUCCESS");
+ _INFO("battery_get_total_mah_usage_by_resource_id_custom_interval() - SUCCESS");
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
CATCH:
g_clear_error(&error);
- _ERR("battery_monitor_call_get_total_usage_by_resource_id_sync()=[%d]", error_code);
+ _ERR("battery_monitor_call_get_total_mah_usage_by_resource_id_custom_interval_sync()=[%d]", error_code);
return error_code;
}
#include <pthread.h>
#include "battery_monitor_util.h"
+#include <system_info.h>
GDBusErrorEntry battery_monitor_svc_errors[] = {
{BATTERY_MONITOR_ERROR_NONE, BATTERY_MONITOR_SVC_ERROR_PREFIX".NoError"},
} else if (g_strcmp0(key, BATTERY_MONITOR_GPS_DATA_ID) == 0) {
data->gps_val = g_variant_get_int32(value);
_INFO("gps_val - [%d]", data->gps_val);
- } else if (g_strcmp0(key, BATTERY_MONITOR_HRM_DATA_ID) == 0) {
- data->hrm_val = g_variant_get_int32(value);
- _INFO("hrm_val - [%d]", data->hrm_val);
- } else if (g_strcmp0(key, BATTERY_MONITOR_BATTERY_DATA_ID) == 0) {
- data->bat_val = g_variant_get_int32(value);
- _INFO("bat_val - [%d]", data->bat_val);
} else {
;
}
EXIT;
return;
}
+
+int battery_monitor_resource_id_is_supported(battery_monitor_resource_id_e resource_id)
+{
+ ENTER;
+
+ int error_code = BATTERY_MONITOR_ERROR_NONE;
+
+ switch (resource_id) {
+ case BATTERY_MONITOR_RESOURCE_ID_BLE:
+ CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_MONITOR_BLE_RES_ID);
+ break;
+ case BATTERY_MONITOR_RESOURCE_ID_WIFI:
+ CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_MONITOR_WIFI_RES_ID);
+ break;
+ case BATTERY_MONITOR_RESOURCE_ID_CPU:
+ error_code = BATTERY_MONITOR_ERROR_NONE;
+ break;
+ case BATTERY_MONITOR_RESOURCE_ID_DISPLAY:
+ CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_MONITOR_DP_RES_ID);
+ break;
+ case BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK:
+ CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_MONITOR_DN_RES_ID);
+ break;
+ case BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR:
+ CHECK_BATTERY_FEATURE_SUPPORTED(BATTERY_MONITOR_GPS_RES_ID);
+ break;
+ default:
+ error_code = BATTERY_MONITOR_ERROR_NOT_SUPPORTED;
+ break;
+ }
+
+ EXIT;
+ return error_code;
+}
#include "battery_monitor.h"
#include "battery_monitor_util.h"
-#define BATTERY_MONITOR_RESOURCE_ID_MAX (BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR + 1)
-
-static gboolean bmt_testapp_get_total_usage_by_app_id()
+static gboolean bmt_testapp_get_total_power_usage_by_app_id_for_ci()
{
/*
- * @brief Gets the total battery usage in percent by an app-id for certain time duration.
+ * @brief Gets the total battery usage in mAh by an app-id for certain time interval.
* This will be sum of all battery consumed by resources used by application.
* app_id - app-id for which battery usage is required
- * duration - time duration for which battery usage is requested
+ * start_time - Start time of data in Epoch Time (s)
+ * end_time - End time of data in Epoch Time (s)
* battery_usage - battery usage consumption for the app-id
-*/
+ */
char app_name[56] = {0, };
- int duration = -1;
+ long long int start_time = -1;
+ long long int end_time = -1;
int error_code = BATTERY_MONITOR_ERROR_NONE;
- int battery_usage = -1;
+ double battery_usage = -1;
testapp_print("\n Input AppID using Look Up table:\n");
if (0 >= scanf("%55s", app_name)) {
}
testapp_print("\n AppID: %s \n", app_name);
- testapp_print("\n Input Duration using Look Up table:\n");
- if (0 >= scanf("%d", &duration)) {
+ testapp_print("\n Input Start Time:\n");
+ if (0 >= scanf("%lld", &start_time)) {
+ testapp_print("Invalid input ");
+ return FALSE;
+ }
+ testapp_print("\n Start Time: %lld \n", start_time);
+
+ testapp_print("\n Input End Time:\n");
+ if (0 >= scanf("%lld", &end_time)) {
testapp_print("Invalid input ");
return FALSE;
}
- testapp_print("\n Duration: %d \n", duration);
+ testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_total_usage_by_app_id(app_name, duration, &battery_usage);
+ error_code = battery_monitor_get_total_power_usage_by_app_id(app_name, start_time, 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 [%d] & Error Code [%d] \n", app_name, battery_usage, error_code);
+ 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);
return FALSE;
}
-static gboolean bmt_testapp_get_total_usage_by_resource_id()
+static gboolean bmt_testapp_get_total_power_usage_by_resource_id_ci()
{
/*
- * @brief Gets the battery-percent usage by a resource for certain time duration.
- * resource_id - resource identifier for which battery usage is requested
- * duration - time duration for which battery usage is requested
- * battery_usage - battery usage consumption for resource-id
-*/
-
- int duration = -1;
+ * @brief Gets the battery usage in mAh by a resource for certain time interval.
+ * resource_id - resource identifier for which battery usage is requested.
+ * start_time - Start time of data in Epoch Time (s)
+ * end_time - End time of data in Epoch Time (s)
+ * battery_usage - battery usage consumption in mAh
+ *
+ */
+ long long int start_time = -1;
+ long long int end_time = -1;
int resource_id = -1;
+ double battery_usage = -1;
int error_code = BATTERY_MONITOR_ERROR_NONE;
- int battery_usage = -1;
testapp_print("\n Input Resource Id using Look Up Table: \n");
if (0 >= scanf("%d", &resource_id)) {
}
testapp_print("\n ResourceID: %d \n", resource_id);
- testapp_print("\n Input Duration using Look Up table:\n");
- if (0 >= scanf("%d", &duration)) {
+ testapp_print("\n Input Start Time:\n");
+ if (0 >= scanf("%lld", &start_time)) {
+ testapp_print("Invalid input ");
+ return FALSE;
+ }
+ testapp_print("\n Start Time: %lld \n", start_time);
+
+ testapp_print("\n Input End Time:\n");
+ if (0 >= scanf("%lld", &end_time)) {
testapp_print("Invalid input ");
return FALSE;
}
- testapp_print("\n Duration: %d \n", duration);
+ testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_total_usage_by_resource_id(resource_id, duration, &battery_usage);
+ error_code = battery_monitor_get_total_power_usage_by_resource_id(resource_id, start_time, 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 [%d] & Error Code [%d] \n", resource_id, battery_usage, error_code);
+ 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);
return FALSE;
}
-static gboolean bmt_testapp_get_total_usage_by_app_id_for_all_resource_id()
+static gboolean bmt_testapp_get_total_power_usage_by_app_id_for_all_resource_id_ci()
{
/*
- * @brief Gets the battery-percent for all resources used by app_id
+ * @brief Gets the battery usage in mAh for all resources used by app_id
* app_id - app-id for which battery usage is required
- * duration - time duration for which battery usage is requested
- * battery_usage - battery usage consumption for the app-id
-*/
-
- int duration = -1;
+ * start_time - Start time of data in Epoch Time (s)
+ * end_time - End time of data in Epoch Time (s)
+ * battery_usage - battery consumption in mAh
+ */
+ long long int start_time = -1;
+ long long int end_time = -1;
char app_name[56] = {0, };
int error_code = BATTERY_MONITOR_ERROR_NONE;
battery_monitor_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 AppID: %s \n", app_name);
- testapp_print("\n Input Duration using Look Up table:\n");
- if (0 >= scanf("%d", &duration)) {
+ testapp_print("\n Input Start Time:\n");
+ if (0 >= scanf("%lld", &start_time)) {
+ testapp_print("Invalid input ");
+ return FALSE;
+ }
+ testapp_print("\n Start Time: %lld \n", start_time);
+
+ testapp_print("\n Input End Time:\n");
+ if (0 >= scanf("%lld", &end_time)) {
testapp_print("Invalid input ");
return FALSE;
}
- testapp_print("\n Duration: %d \n", duration);
+ testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_usage_by_app_id_for_all_resource_id(app_name, duration, &data_handle);
+ error_code = battery_monitor_get_power_usage_handle_by_app_id_for_all_resource_ids(app_name, start_time, 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);
- int battery_usage;
+ double battery_usage = -1;
#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
for (int id = BATTERY_MONITOR_RESOURCE_ID_BLE; id < BATTERY_MONITOR_RESOURCE_ID_MAX; id++) {
#else
- for (int id = BATTERY_MONITOR_RESOURCE_ID_BLE; id <= BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK; ++id) {
+ 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_usage_for_resource_id(data_handle, id, &battery_usage);
+ error_code = battery_monitor_get_power_usage_for_resource_id_from_handle(data_handle, id, &battery_usage);
if (error_code != BATTERY_MONITOR_ERROR_NONE) {
- testapp_print ("Error Received, Value of error_code is [%d] \n", error_code);
+ if (error_code == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND)
+ testapp_print ("This resource is not available \n");
+ else
+ testapp_print ("Error Received, Value of error_code is [%d] \n", error_code);
continue;
}
switch (id) {
case BATTERY_MONITOR_RESOURCE_ID_BLE:
- testapp_print ("Resource ID : BT App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : BT App Usage Value = [%lf] \n", battery_usage);
break;
case BATTERY_MONITOR_RESOURCE_ID_WIFI:
- testapp_print ("Resource ID : WIFI App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : WIFI App Usage Value = [%lf] \n", battery_usage);
break;
case BATTERY_MONITOR_RESOURCE_ID_CPU:
- testapp_print ("Resource ID : CPU App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : CPU App Usage Value = [%lf] \n", battery_usage);
break;
case BATTERY_MONITOR_RESOURCE_ID_DISPLAY:
- testapp_print ("Resource ID : DISPLAY App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : DISPLAY App Usage Value = [%lf] \n", battery_usage);
break;
case BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK:
- testapp_print ("Resource ID : DEVICE NETWORK App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : DEVICE NETWORK App Usage Value = [%lf] \n", battery_usage);
break;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
case BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR:
- testapp_print ("Resource ID : GPS App Usage Value = [%d] \n", battery_usage);
+ testapp_print ("Resource ID : GPS App Usage Value = [%lf] \n", battery_usage);
break;
- case BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR:
- testapp_print ("Resource ID : HRM App Usage Value = [%d] \n", battery_usage);
+ default:
+ testapp_print ("Default Case");
break;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN */
}
}
}
return FALSE;
}
-static gboolean bmt_testapp_get_total_usage_by_app_id_for_resource_id()
+static gboolean bmt_testapp_get_power_usage_by_app_id_for_resource_id_ci()
{
/*
- * @brief Gets the battery-percent by an app-id for a specific resource.
+ * @brief Gets the battery usage in mAh by an app-id for a specific resource.
* app_id - app-id for which battery usage is required
- * resource_id - identifier of resource type . BLE, WiFi, CPU etc
- * duration - time duration for which battery usage is requested
- * battery_usage - battery usage consumption for the app-id
+ * resource_id - esource identifier for which battery usage is requested.
+ * start_time - Start time of data in Epoch Time (s)
+ * end_time - End time of data in Epoch Time (s)
+ * battery_usage - battery usage consumption in mAh
*/
-
- int duration = -1;
- char app_name[56] = {0, };
- int battery_usage = -1;
+ long long int start_time = -1;
+ long long int end_time = -1;
int resource_id = -1;
+ char app_name[56] = {0, };
+ double battery_usage = -1;
int error_code = BATTERY_MONITOR_ERROR_NONE;
testapp_print("\n Input AppID using Look Up table:\n");
}
testapp_print("\n AppID: %s \n", app_name);
- testapp_print("\n Input Duration using Look Up table:\n");
- if (0 >= scanf("%d", &duration)) {
+ testapp_print("\n Input Resource Id using Look Up Table: \n");
+ if (0 >= scanf("%d", &resource_id)) {
testapp_print("Invalid input ");
return FALSE;
}
- testapp_print("\n Duration: %d \n", duration);
+ testapp_print("\n ResourceID: %d \n", resource_id);
- testapp_print("\n Input Resource Id using Look Up Table: \n");
- if (0 >= scanf("%d", &resource_id)) {
+ testapp_print("\n Input Start Time:\n");
+ if (0 >= scanf("%lld", &start_time)) {
testapp_print("Invalid input ");
return FALSE;
}
- testapp_print("\n ResourceID: %d \n", resource_id);
+ testapp_print("\n Start Time: %lld \n", start_time);
+
+ testapp_print("\n Input End Time:\n");
+ if (0 >= scanf("%lld", &end_time)) {
+ testapp_print("Invalid input ");
+ return FALSE;
+ }
+ testapp_print("\n End Time: %lld \n", end_time);
- error_code = battery_monitor_get_usage_by_app_id_for_resource_id(app_name, resource_id, duration, &battery_usage);
+ error_code = battery_monitor_get_power_usage_by_app_id_for_resource_id(app_name, resource_id, start_time, end_time, &battery_usage);
if (error_code == BATTERY_MONITOR_ERROR_NONE)
- testapp_print (" Battery Usage for APPID [%s], of RID [%d] is [%d]", app_name, resource_id, battery_usage);
+ testapp_print (" Battery Usage for APPID [%s], of RID [%d] is [%lf]", app_name, resource_id, battery_usage);
return FALSE;
}
switch (selected_number) {
case 1:
- bmt_testapp_get_total_usage_by_app_id();
+ bmt_testapp_get_total_power_usage_by_app_id_for_ci();
break;
-
case 2:
- bmt_testapp_get_total_usage_by_resource_id();
+ bmt_testapp_get_total_power_usage_by_resource_id_ci();
break;
-
case 3:
- bmt_testapp_get_total_usage_by_app_id_for_all_resource_id();
+ bmt_testapp_get_total_power_usage_by_app_id_for_all_resource_id_ci();
break;
-
case 4:
- bmt_testapp_get_total_usage_by_app_id_for_resource_id();
- break;
+ bmt_testapp_get_power_usage_by_app_id_for_resource_id_ci();
case 0:
go_to_loop = FALSE;
testapp_print("==========================================\n");
testapp_print(" USAGE MENU \n");
testapp_print("==========================================\n");
- testapp_print(" 1. Get Total Usage By App ID\n");
- testapp_print(" 2. Get Total Usage By Resource ID\n");
- testapp_print(" 3. Get App Usage for All Resource IDs\n");
- testapp_print(" 4. Get App Usage for a Resource ID\n");
+ testapp_print(" ===== FOR CUSTOM INTERVALS ===== \n");
+ testapp_print(" 1. Get Total Usage By App ID for CI\n");
+ testapp_print(" 2. Get Total Usage By Resource ID for CI\n");
+ testapp_print(" 3. Get App Usage for All Resource IDs for CI\n");
+ testapp_print(" 4. Get App Usage for a Resource ID for CI\n");
+
testapp_print(" 5. Dummy menu entry (Don't Use)\n");
testapp_print(" 0. Go to Main Menu\n");
testapp_print("------------------------------------------\n\n");
testapp_print(" 2 ==> BM_RESOURCE_ID_CPU \n");
testapp_print(" 3 ==> BM_RESOURCE_ID_DISPLAY \n");
testapp_print(" 4 ==> BM_RESOURCE_ID_DEVICE_NETWORK \n");
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
testapp_print(" 5 ==> BM_RESOURCE_ID_GPS_SENSOR \n");
- testapp_print(" 6 ==> BM_RESOURCE_ID_HRM_SENSOR \n");
- #endif /* DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN */
- testapp_print("==========================================\n");
- testapp_print(" TIME LOOK UP TABLE \n");
- testapp_print("==========================================\n");
- testapp_print(" 0 ==> BM_DURATION_TYPE_1DAY \n");
- testapp_print(" 1 ==> BM_DURATION_TYPE_1WEEK \n");
- testapp_print("==========================================\n");
- testapp_print(" APP ID LOOK UP TABLE \n");
- testapp_print("==========================================\n");
- testapp_print(" appidX \n");
- testapp_print(" appidY \n");
- testapp_print(" appidZ \n");
testapp_print("------------------------------------------\n");
testapp_print("------------------------------------------\n");
break;