Remove unused code 67/244267/2
authorDewal Agarwal <d1.agarwal@samsung.com>
Wed, 16 Sep 2020 12:01:28 +0000 (17:31 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Wed, 16 Sep 2020 12:15:01 +0000 (17:45 +0530)
Change-Id: I1be7973960185b40469d3782d2cf6ec737ccbbae
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
include/bm_server_db.h
src/bm_power_engine.c
src/bm_server_db.c

index af36574..a7cedd2 100644 (file)
@@ -189,14 +189,10 @@ int initialize_database(void);
 
 int deinitialize_database(void);
 
-appid_usage_s *bm_server_query_app_usage_by_appid(const char *app_id, int period_type, int *error_code);
-
 appid_usage_s *bm_server_query_app_usage_by_appid_ci(const char *app_id, long long s_time, long long e_time, int *error_code);
 
 int bm_server_app_usage_insert_to_db(appid_usage_s *bm_app_type);
 
-resourceid_usage_s *bm_server_query_resource_usage_resourceid(const char *resource_id, int period_type, int *error_code);
-
 resourceid_usage_s *bm_server_query_resource_usage_resourceid_ci(const char *resource_id, long long s_time, long long e_time, int *error_code);
 
 resourceid_usage_s *bm_server_query_resource_base_usage_resourceid_ci(const char *resource_id, long long s_time, long long e_time, int *error_code);
index a034da3..5763f50 100644 (file)
@@ -1371,65 +1371,6 @@ 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)
-{
-       ENTER;
-
-       int ret_val = DEVICE_ERROR_NONE;
-       int battery_percent = 0;
-       bool is_charging = false;
-
-       ret_val = device_battery_get_percent(&battery_percent);
-       BM_RETURN_VAL((ret_val == DEVICE_ERROR_NONE), {},
-               BATTERY_MONITOR_ERROR_INTERNAL, "failed to get battery percent");
-
-       ret_val = device_battery_is_charging(&is_charging);
-       BM_RETURN_VAL((ret_val == DEVICE_ERROR_NONE), {},
-               BATTERY_MONITOR_ERROR_INTERNAL, "failed to get charging status");
-
-       device_battery_level_e battery_level;
-       ret_val = device_battery_get_level_status(&battery_level);
-       BM_RETURN_VAL((ret_val == DEVICE_ERROR_NONE), {},
-               BATTERY_MONITOR_ERROR_INTERNAL, "failed to get warning status");
-
-       switch (battery_level) {
-       case DEVICE_BATTERY_LEVEL_EMPTY:
-               _DBG("battery level - EMPTY");
-               break;
-       case DEVICE_BATTERY_LEVEL_CRITICAL:
-               _DBG("battery level - CRITICAL");
-               break;
-       case DEVICE_BATTERY_LEVEL_LOW:
-               _DBG("battery level - LOW");
-               break;
-       case DEVICE_BATTERY_LEVEL_HIGH:
-               _DBG("battery level - HIGH");
-               break;
-       case DEVICE_BATTERY_LEVEL_FULL:
-               _DBG("battery level - FULL");
-               break;
-       default:
-               _DBG("invalid battery-level");
-               break;
-       }
-
-       _INFO("battery percent[%d] & charging status[%s]",
-               battery_percent, (is_charging == true) ? "TRUE" : "FALSE");
-
-       int sP_power_battery = 0;
-
-       ret_val = bm_get_battery_power_params(&sP_power_battery);
-       if (ret_val != BATTERY_MONITOR_ERROR_NONE)
-               _ERR("failed to get battery power params");
-
-       _DBG("received battery power params - battery[%d]", sP_power_battery);
-
-       ret_val = BATTERY_MONITOR_ERROR_NONE;
-
-       EXIT;
-       return ret_val;
-}
-
 int bm_get_data_from_handles(void)
 {
        ENTER;
@@ -1512,12 +1453,6 @@ int bm_get_data_from_handles(void)
        _DBG("completed gps data request");
 #endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
 
-       /* parsing battery data */
-       _DBG("parsing battery data");
-       ret_val = bm_battery_calc_power_and_commit();
-       BM_CHECK_VAL((ret_val == BATTERY_MONITOR_ERROR_NONE), "battery power calc failure");
-       _DBG("completed battery data request");
-
        ret_val = bm_insert_appid_session_usage_to_db();
        BM_CHECK_VAL((ret_val == BATTERY_MONITOR_ERROR_NONE), "battery session logging failure");
 
index 407c82a..9ef3761 100644 (file)
@@ -18,8 +18,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
 #include <sys/stat.h>
 #include <glib.h>
 #include <db-util.h>
@@ -346,18 +344,6 @@ static int bm_query_app_usage_convert_to_sql_ci(const char *str, long s_t, long
        return count;
 }
 
-static int bm_query_app_usage_convert_to_sql(const char *str, long s_t, bm_stmt hstmt)
-{
-       ENTER;
-
-       int count = 1;
-       bm_query_bind_text(hstmt, count++, str);
-       bm_query_bind_int(hstmt, count++, s_t);
-
-       EXIT;
-       return count;
-}
-
 static int bm_appid_map_usage_convert_to_sql(const char* app_id, bm_stmt hstmt, char *sql_value)
 {
        ENTER;
@@ -1521,88 +1507,6 @@ CATCH:
        return NULL;
 }
 
-static appid_usage_s* bm_query_usage_by_appid(sqlite3 *bm_db_handle, const char *app_id, int *error_code, int period_type)
-{
-       ENTER;
-
-       long int duration  = 0;
-       duration = bm_get_time_bias(period_type);
-       if (duration == 0) {
-               _ERR("Invalid period_type [%d]", period_type);
-               return NULL;
-       }
-       _DBG("Value for duration is [%ld]", duration);
-
-       bm_stmt hstmt = NULL;
-       char query[BATTERY_MONITOR_SQL_LEN_MAX] = {0, };
-       int rc = 0;
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-       BM_RETURN_VAL((app_id != NULL), { *error_code = BATTERY_MONITOR_ERROR_INVALID_PARAMETER; },
-                                               NULL, ("APP ID IS NULL"));
-       BM_RETURN_VAL((bm_db_handle != NULL), { *error_code = BATTERY_MONITOR_ERROR_DB_NOT_OPENED; },
-                                               NULL, ("The database isn't connected."));
-       BM_MEMSET(query, 0x00, BATTERY_MONITOR_SQL_LEN_MAX);
-
-       BM_SNPRINTF(query, sizeof(query), "SELECT AppId, sum(rId_ble), sum(rId_wifi), sum(rId_cpu), \
-               sum(rId_display), sum(rId_device_network), sum(rId_gps) FROM %s WHERE \
-               AppId = ? AND log_time >= ?", BATTERY_MONITOR_APP_ID_USAGE_TABLE);
-
-       hstmt = bm_prepare_query(bm_db_handle, query);
-       if (bm_db_err_code(bm_db_handle) == SQLITE_PERM) {
-               _ERR("Access failed(%s)", bm_db_err_msg(bm_db_handle));
-               *error_code = BATTERY_MONITOR_ERROR_PERMISSION_DENIED;
-               return NULL;
-       }
-
-       bm_query_app_usage_convert_to_sql(app_id, duration, hstmt);
-       appid_usage_s *bm_app_type = NULL;
-       rc = bm_query_step(hstmt);
-       BM_CATCH_ERROR_P(rc == SQLITE_ROW, {}, BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND,
-                               ("The record isn't found.(%s)\n", app_id));
-
-       bm_app_type = (appid_usage_s *)calloc(1, sizeof(appid_usage_s));
-       if (bm_app_type == NULL) {
-               _ERR("memory allocation failed");
-               if (hstmt != NULL) {
-                       rc = bm_query_finalize(hstmt);
-                       BM_RETURN_VAL((rc == BATTERY_MONITOR_ERROR_NONE), { *error_code = rc; },
-                                               NULL, ("finalize error"));
-                       hstmt = NULL;
-               }
-               *error_code = BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
-               return NULL;
-       }
-
-       bm_convert_column_to_appid_usage(hstmt, bm_app_type);
-
-       rc = bm_query_finalize(hstmt);
-       BM_CATCH_ERROR_P((rc == BATTERY_MONITOR_ERROR_NONE), {}, rc, ("finalize error"));
-       hstmt = NULL;
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-CATCH:
-       if (hstmt != NULL) {
-               rc = bm_query_finalize(hstmt);
-               if (rc != BATTERY_MONITOR_ERROR_NONE) {
-                       *error_code = rc;
-                       _ERR("finalize error");
-               }
-               hstmt = NULL;
-       }
-       if ((*error_code != BATTERY_MONITOR_ERROR_NONE) && bm_app_type) {
-               BM_FREE(bm_app_type);
-               bm_app_type = NULL;
-       }
-       if ((*error_code == BATTERY_MONITOR_ERROR_NONE) && bm_app_type != NULL) {
-               _INFO("Returning appid usage");
-               return bm_app_type;
-       }
-
-       EXIT;
-       return NULL;
-}
-
 static appid_usage_s* bm_query_usage_by_appid_ci(sqlite3 *bm_db_handle, const char *app_id, long long s_time, long long e_time, int *error_code)
 {
        ENTER;
@@ -1825,86 +1729,6 @@ CATCH:
        return error_code;
 }
 
-static resourceid_usage_s* bm_query_usage_by_resourceid(sqlite3 *bm_db_handle, const char *resource_id, int *error_code, int period_type)
-{
-       ENTER;
-
-       long int duration  = 0;
-       duration = bm_get_time_bias(period_type);
-       if (duration == 0) {
-               _ERR("Invalid period_type [%d]", period_type);
-               return NULL;
-       }
-
-       _DBG("Value for duration is [%ld]", duration);
-
-       bm_stmt hstmt = NULL;
-       char query[BATTERY_MONITOR_SQL_LEN_MAX] = {0, };
-       int rc = 0;
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-       BM_RETURN_VAL((resource_id != NULL), { *error_code = BATTERY_MONITOR_ERROR_INVALID_PARAMETER; },
-                                       NULL, ("RESOURCE ID IS NULL"));
-       BM_RETURN_VAL((bm_db_handle != NULL), { *error_code = BATTERY_MONITOR_ERROR_DB_NOT_OPENED; },
-                                       NULL, ("The database isn't connected."));
-       BM_MEMSET(query, 0x00, BATTERY_MONITOR_SQL_LEN_MAX);
-       BM_SNPRINTF(query, sizeof(query), "SELECT ResourceId, sum(usage) FROM %s WHERE ResourceId = '%s' \
-                       AND log_time >= %ld", BATTERY_MONITOR_RESOURCE_ID_USAGE_TABLE, resource_id, duration);
-
-       hstmt = bm_prepare_query(bm_db_handle, query);
-       if (bm_db_err_code(bm_db_handle) == SQLITE_PERM) {
-               _ERR("Access failed(%s)", bm_db_err_msg(bm_db_handle));
-               *error_code = BATTERY_MONITOR_ERROR_PERMISSION_DENIED;
-               return NULL;
-       }
-
-       resourceid_usage_s *bm_resource_type = NULL;
-
-       rc = bm_query_step(hstmt);
-       BM_CATCH_ERROR_P(rc == SQLITE_ROW, {}, BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND, ("The record isn't found.(%s)\n", resource_id));
-
-       bm_resource_type = (resourceid_usage_s *)calloc(1, sizeof(resourceid_usage_s));
-       if (bm_resource_type == NULL) {
-               _ERR("memory allocation failed");
-               if (hstmt != NULL) {
-                       rc = bm_query_finalize(hstmt);
-                       BM_RETURN_VAL((rc == BATTERY_MONITOR_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error"));
-                       hstmt = NULL;
-               }
-               *error_code = BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
-               return NULL;
-       }
-
-       bm_convert_column_to_resourceid_usage(hstmt, bm_resource_type);
-
-       rc = bm_query_finalize(hstmt);
-       BM_CATCH_ERROR_P((rc == BATTERY_MONITOR_ERROR_NONE), {}, rc, ("finalize error"));
-       hstmt = NULL;
-
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-CATCH:
-       if (hstmt != NULL) {
-               rc = bm_query_finalize(hstmt);
-               if (rc != BATTERY_MONITOR_ERROR_NONE) {
-                       *error_code = rc;
-                       _ERR("finalize error");
-               }
-               hstmt = NULL;
-       }
-       if ((*error_code != BATTERY_MONITOR_ERROR_NONE) && bm_resource_type) {
-               BM_FREE(bm_resource_type);
-               bm_resource_type = NULL;
-       }
-       if ((*error_code == BATTERY_MONITOR_ERROR_NONE) && bm_resource_type != NULL) {
-               _INFO("Returning appid usage");
-               return bm_resource_type;
-       }
-
-       EXIT;
-       return NULL;
-}
-
 static resourceid_usage_s* bm_query_usage_by_resourceid_ci(sqlite3 *bm_db_handle, const char *resource_id, long long s_time, long long e_time, int *error_code)
 {
        ENTER;
@@ -2448,22 +2272,6 @@ int bm_server_app_usage_insert_to_db(appid_usage_s *bm_app_type)
 }
 
 /* For App usage related queries */
-appid_usage_s *bm_server_query_app_usage_by_appid(const char *app_id, int period_type, int *error_code)
-{
-       ENTER;
-
-       appid_usage_s *bm_app_type = NULL;
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-       BM_RETURN_VAL((g_hBatteryMonitorDB != NULL), { *error_code =  BATTERY_MONITOR_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected."));
-       BM_RETURN_VAL((app_id != NULL), { *error_code = BATTERY_MONITOR_ERROR_INVALID_PARAMETER; }, NULL, ("The Battery Monitor Handle is NULL"));
-
-       bm_app_type = bm_query_usage_by_appid(g_hBatteryMonitorDB, app_id, error_code, period_type);
-
-       EXIT;
-       return bm_app_type;
-}
-
 appid_usage_s *bm_server_query_app_usage_by_appid_ci(const char *app_id, long long s_time, long long e_time, int *error_code)
 {
        ENTER;
@@ -2481,22 +2289,6 @@ appid_usage_s *bm_server_query_app_usage_by_appid_ci(const char *app_id, long lo
 }
 
 /* For Resource usage related queries */
-resourceid_usage_s *bm_server_query_resource_usage_resourceid(const char *resource_id, int period_type, int *error_code)
-{
-       ENTER;
-
-       resourceid_usage_s *bm_resource_type = NULL;
-       *error_code = BATTERY_MONITOR_ERROR_NONE;
-
-       BM_RETURN_VAL((g_hBatteryMonitorDB != NULL), { *error_code = BATTERY_MONITOR_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected."));
-       BM_RETURN_VAL((resource_id != NULL), { *error_code = BATTERY_MONITOR_ERROR_INVALID_PARAMETER; }, NULL, ("The Battery Monitor Handle is NULL"));
-
-       bm_resource_type = bm_query_usage_by_resourceid(g_hBatteryMonitorDB, resource_id, error_code, period_type);
-
-       EXIT;
-       return bm_resource_type;
-}
-
 resourceid_usage_s *bm_server_query_resource_usage_resourceid_ci(const char *resource_id, long long s_time, long long e_time, int *error_code)
 {
        resourceid_usage_s *bm_resource_type = NULL;