return g_variant_builder_end(&builder);
}
+//LCOV_EXCL_START
static runtime_info_error_e errno_to_runtime_info_error(int err)
{
switch (err) {
return RUNTIME_INFO_ERROR_NO_DATA;
}
}
+//LCOV_EXCL_STOP
/* Handler function which handles dbus related instructions
* Creates the method call to resourced and receives the reply (if successful)
/* Fall through */
case USAGE_TYPE_APP_MEMORY:
case USAGE_TYPE_APP_CPU:
- if (!error) {
- //LCOV_EXCL_START : system error
+ if (!error) { //LCOV_EXCL_START : system error
_E("INVALID_PARAMETER(0x%08x): error parameter cannot be null",
RUNTIME_INFO_ERROR_INVALID_PARAMETER);
return NULL;
/* Populate the entries of info array using the data received from resourced */
len = g_variant_n_children(reply);
if (len <= 0) {
+ //LCOV_EXCL_START
_E("NO_DATA(0x%08x) : there is no registered app", RUNTIME_INFO_ERROR_NO_DATA);
g_variant_unref(reply);
return RUNTIME_INFO_ERROR_NO_DATA;
+ //LCOV_EXCL_STOP
}
usages = calloc(1, sizeof(struct app_usages_s));
if (!usages) {
+ //LCOV_EXCL_START
_E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY);
g_variant_unref(reply);
return RUNTIME_INFO_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
}
usages->len = (int)len;
usages->list = calloc(len, sizeof(struct app_usage_s));
if (!usages->list) {
+ //LCOV_EXCL_START
_E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY);
free(usages);
g_variant_unref(reply);
return RUNTIME_INFO_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
}
g_variant_iter_init(&iter, reply);
fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
+ //LCOV_EXCL_START
_E("IO_ERROR(0x%08x) : failed to open file to read memory usage",
RUNTIME_INFO_ERROR_IO_ERROR);
return RUNTIME_INFO_ERROR_IO_ERROR;
+ //LCOV_EXCL_STOP
}
info->total = info->free = info->cache = 0;
/* Populate the entries of info array using the data received from resourced */
*info = (process_memory_info_s *)malloc(size * sizeof(process_memory_info_s));
if (!(*info)) {
+ //LCOV_EXCL_START
_E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY);
g_variant_unref(reply);
return RUNTIME_INFO_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
}
g_variant_iter_init(&iter, reply);
return RUNTIME_INFO_ERROR_NONE;
}
+//LCOV_EXCL_START Internal API
static int get_process_memory_info_direct(int *pid, int size, process_memory_info_key_e key, int **info)
{
int ret_hal, i;
/* Get the needed information from resourced daemon using dbus */
reply = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_SWAP, pid, size, &error);
if (!reply) {
- //LCOV_EXCL_START : system error
_E("DBUS_METHOD_CALL: call to resourced not successful");
return error;
- //LCOV_EXCL_STOP
}
/* Check whether the received usage has expected format or not */
if (g_strcmp0(g_variant_get_type_string(reply), "a(i)") ||
g_variant_n_children(reply) != size) {
- //LCOV_EXCL_START : system error
_E("DBUS_METHOD_CALL: received dbus message is not in expected format");
g_variant_unref(reply);
return RUNTIME_INFO_ERROR_REMOTE_IO;
- //LCOV_EXCL_STOP
}
/* Populate the entries of info array using the data received from resourced */
return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
}
}
+//LCOV_EXCL_STOP
API int runtime_info_get_cpu_usage(runtime_cpu_usage_s *usage)
{
cpuinfo_fp = fopen("/proc/stat", "r");
if (cpuinfo_fp == NULL) {
+ //LCOV_EXCL_START
_E("IO_ERROR(0x%08x) : failed to open file to read cpu usage",
RUNTIME_INFO_ERROR_IO_ERROR);
return RUNTIME_INFO_ERROR_IO_ERROR;
+ //LCOV_EXCL_STOP
}
while (fgets(buf, sizeof(buf), cpuinfo_fp) != NULL) {
int sum;
FILE *fp = fopen("/proc/zoneinfo", "r");
if (!fp) {
+ //LCOV_EXCL_START
_E("IO_ERROR(0x%08x) : failed to open file to read memory size",
RUNTIME_INFO_ERROR_IO_ERROR);
return RUNTIME_INFO_ERROR_IO_ERROR;
+ //LCOV_EXCL_STOP
}
if (!size) {