From 97cbcc63fbddd24784402867599bf74f0b72c057 Mon Sep 17 00:00:00 2001 From: hj kim Date: Thu, 14 May 2020 07:58:39 +0900 Subject: [PATCH] Remove unnecessary duplicated code when application is deleted from app_list table, it will trigger to server_info and latest_meta table. if app is not latest, info for that app will be deleted from server_info and latest_meta table. in mc_db_remove_application(), app_list table is updated by calling __mc_db_delete_from_list() and do __mc_db_deactivate_server(). but __mc_db_deactivate_server() try to remove application info from the server_info table again. Change-Id: Id4e82f0db44de7b785f25a5d7c30cfce75c791a2 --- svc/media_controller_db_util.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/svc/media_controller_db_util.c b/svc/media_controller_db_util.c index b745f20..ccebb91 100644 --- a/svc/media_controller_db_util.c +++ b/svc/media_controller_db_util.c @@ -238,31 +238,6 @@ static int __mc_db_activate_server(sqlite3 *db_handle, const char *app_id) return ret; } -static int __mc_db_deactivate_server(sqlite3 *db_handle, const char *app_id) -{ - int ret = MEDIA_CONTROLLER_ERROR_NONE; - char *sql_str = NULL; - - mc_debug_fenter(); - - mc_retvm_if(!app_id, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid app_id"); - - /* Update server_state to deactivated, if the server is latest. - * Remove server from app_list, if it is not latest. - */ - if (__mc_db_is_latest(db_handle, app_id)) { - ret = __mc_update_latest_server_info_to_db(db_handle, MC_SERVER_STATE_DEACTIVATE, MC_PLAYBACK_STATE_STOPPED); - } else { - sql_str = sqlite3_mprintf("DELETE FROM %q WHERE name=%Q", MC_DB_TABLE_SERVER_INFO, app_id); - ret = mc_db_util_update_db(db_handle, sql_str); - SQLITE3_SAFE_FREE(sql_str); - } - - mc_debug_fleave(); - - return ret; -} - static int __mc_db_insert_to_list(sqlite3 *db_handle, const char *app_id, mc_priv_type_e priv_type) { int ret = MEDIA_CONTROLLER_ERROR_NONE; @@ -904,11 +879,9 @@ int mc_db_remove_application(uid_t uid, const char *app_id, const mc_priv_type_e if (ret != MEDIA_CONTROLLER_ERROR_NONE) mc_secure_error("__mc_db_delete_from_list error : %d", ret); - /* Update application information if it is server */ - if (priv_type == MC_PRIV_TYPE_SERVER) { - ret = __mc_db_deactivate_server(db_handle, app_id); - if (ret != MEDIA_CONTROLLER_ERROR_NONE) - mc_secure_error("__mc_db_deactivate_server_table error : %d", ret); + /* Update application information if it is latest server */ + if ((priv_type == MC_PRIV_TYPE_SERVER) && (__mc_db_is_latest(db_handle, app_id))) { + ret = __mc_update_latest_server_info_to_db(db_handle, MC_SERVER_STATE_DEACTIVATE, MC_PLAYBACK_STATE_STOPPED); } mc_db_disconnect(db_handle); -- 2.7.4