From 1c62bfd2cd6b070c7e4fa9396a7fb5f0b1015a06 Mon Sep 17 00:00:00 2001 From: "hwajeong.son" Date: Mon, 1 Oct 2018 19:50:22 +0900 Subject: [PATCH] Fixed TPLDOCKER-382 related to ethernet cable If the cable is detached, config.json is removed. In this case, it has to be retried when the cable is connected. Therefore, the flag file has to be kept Change-Id: Ic1b52e8cc5a1e4a00acb59ca48e53c30381873e1 Signed-off-by: nshero.lee Removed unnecessary value in print log --- src/adaptor.c | 8 ++++++-- src/setup_network.c | 30 +++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/adaptor.c b/src/adaptor.c index aa4beaa..e52d02c 100755 --- a/src/adaptor.c +++ b/src/adaptor.c @@ -62,8 +62,12 @@ gboolean setup_cb(gpointer data) sa_inputfile_release_resource(&config); - sa_inputfile_clear_completion_flag(); - sa_inputfile_remove(); + if ((sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET) && sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI)) + && (sa_inputfile_get_completion_flag(SA_FILE_CONFIG_SYSTEM))) { + _D("Setting is done clear all"); + sa_inputfile_clear_completion_flag(); + sa_inputfile_remove(); + } } static GSourceFuncs SourceFuncs = { diff --git a/src/setup_network.c b/src/setup_network.c index 6199fbc..e873ebb 100755 --- a/src/setup_network.c +++ b/src/setup_network.c @@ -463,7 +463,7 @@ static int __eth_update_ip_info(sa_eth_s * info, connection_profile_h profile, c static int __eth_update_ip(sa_eth_s * info) { - int rv = 0; + int ret = 0; connection_profile_type_e prof_type; connection_profile_h profile; @@ -475,8 +475,13 @@ static int __eth_update_ip(sa_eth_s * info) return -1; } - if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) { - _D("profile connection error!! \n"); + // If ethernet cable is detached, it should be retried after rebooting. + // return 1 is retry case, 0 is non-error and -1 is error to be completed + ret = connection_profile_get_type(profile, &prof_type); + if (ret == CONNECTION_ERROR_INVALID_PARAMETER) { + _D("profile connection error!! [%d]", ret); + return 1; + } else if (ret != CONNECTION_ERROR_NONE) { return -1; } @@ -498,7 +503,7 @@ static int __eth_update_ip(sa_eth_s * info) } _D("operation sucess\n"); - return 1; + return ret; } static int __eth_register_client(void) @@ -539,17 +544,19 @@ static int __eth_deregister_client(void) static int __ethernet_connect_main(sa_eth_s * info) { + int ret = 0; + if (info == NULL) return -1; if (__eth_register_client() == 1) { - __eth_update_ip(info); + ret = __eth_update_ip(info); __eth_deregister_client(); } else _D("connection error!!!\n"); - return 0; + return ret; } static int __network_get_wifi_state(connection_h connection, connection_wifi_state_e * wifi_state) @@ -661,9 +668,18 @@ static sa_error_e __network_connect(sa_network_s * info) if ((info->eth->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET)) { retEth = __ethernet_connect_main(info->eth); _D("return ethernet [%d]", retEth); + if (retEth == 1) + _D("retry after rebooting, do not remove completion flag"); + else + sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); + } else { + // if eth info is null, ethernet completion flag is set + sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); } + } else { + // if eth info is null, ethernet completion flag is set + sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); } - sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); if (info->wifi != NULL) { if ((info->wifi->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI)) { -- 2.34.1