Fixed TPLDOCKER-382 related to ethernet cable
authorhwajeong.son <hwajeong.son@samsung.com>
Mon, 1 Oct 2018 10:50:22 +0000 (19:50 +0900)
committerhwajeong.son <hwajeong.son@samsung.com>
Mon, 1 Oct 2018 10:50:22 +0000 (19:50 +0900)
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 <nshero.lee@samsung.com>
Removed unnecessary value in print log

src/adaptor.c
src/setup_network.c

index aa4beaa6deb11bfade29750ffb1f423262e55c50..e52d02ccd4db841b3c5e78878cea4ac90b8a94f2 100755 (executable)
@@ -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 = {
index 6199fbc3cec3eee19455a5fb1d860f5e98f61b58..e873ebb083f61c0c2b5ba2ffa0a1f7b0831a4944 100755 (executable)
@@ -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)) {