Fix autoconnect issue at reboot in TW3 81/256581/5 submit/tizen/20210421.161229
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 7 Apr 2021 11:21:44 +0000 (16:51 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Wed, 21 Apr 2021 07:08:31 +0000 (12:38 +0530)
Change-Id: I7104f40a29f5e45cd2b6ba0391f36d7c37bfa0a2
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/connman.spec
src/connman.h
src/device.c
src/inet.c

index ed890d1..ac63c63 100644 (file)
@@ -6,7 +6,7 @@
 
 Name:           connman
 Version:        1.38
-Release:        5
+Release:        6
 License:        GPL-2.0+
 Summary:        Connection Manager
 Url:            http://connman.net
index f4a2f44..97bb80a 100755 (executable)
@@ -645,6 +645,8 @@ int __connman_rfkill_block(enum connman_service_type type, bool block);
 #if defined TIZEN_EXT
 char *index2ident(int index, const char *prefix);
 char *index2addr(int index);
+char *_get_wifi_ident(void);
+char *_get_wifi_addr(void);
 #endif
 
 #include <connman/network.h>
index fa5a001..ffec3f2 100755 (executable)
@@ -1771,6 +1771,87 @@ void __connman_device_stop_scan(enum connman_service_type type)
 }
 
 #if defined TIZEN_EXT
+#define WIFI_MAC "/opt/etc/.mac.info"
+#define MAC_ADDR_LEN 18
+
+char *_get_wifi_addr(void)
+{
+       FILE *fp = NULL;
+       char* rv = 0;
+       char wifi_mac[MAC_ADDR_LEN + 1];
+       char *str;
+
+       fp = fopen(WIFI_MAC, "r");
+       if (!fp){
+               connman_error("[%s] not present", WIFI_MAC);
+               return NULL;
+       }
+
+       rv = fgets(wifi_mac, MAC_ADDR_LEN, fp);
+       if (!rv) {
+               connman_error("Failed to get wifi mac address");
+               fclose(fp);
+               return NULL;
+       }
+
+       str = g_try_malloc0(MAC_ADDR_LEN);
+       if (!str) {
+               connman_error("memory allocation failed");
+               fclose(fp);
+               return NULL;
+       }
+
+       snprintf(str, MAC_ADDR_LEN, "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
+                       g_ascii_tolower(wifi_mac[0]), g_ascii_tolower(wifi_mac[1]),
+                       g_ascii_tolower(wifi_mac[3]), g_ascii_tolower(wifi_mac[4]),
+                       g_ascii_tolower(wifi_mac[6]), g_ascii_tolower(wifi_mac[7]),
+                       g_ascii_tolower(wifi_mac[9]), g_ascii_tolower(wifi_mac[10]),
+                       g_ascii_tolower(wifi_mac[12]), g_ascii_tolower(wifi_mac[13]),
+                       g_ascii_tolower(wifi_mac[15]), g_ascii_tolower(wifi_mac[16]));
+       fclose(fp);
+       return str;
+}
+
+char *_get_wifi_ident(void)
+{
+       FILE *fp = NULL;
+       char* rv = 0;
+       char wifi_mac[MAC_ADDR_LEN + 1];
+       char *str;
+
+       fp = fopen(WIFI_MAC, "r");
+       if (!fp){
+               connman_error("[%s] not present", WIFI_MAC);
+               return NULL;
+       }
+
+       rv = fgets(wifi_mac, MAC_ADDR_LEN, fp);
+       if (!rv) {
+               connman_error("Failed to get wifi mac address");
+               fclose(fp);
+               return NULL;
+       }
+
+       str = g_try_malloc0(MAC_ADDR_LEN);
+       if (!str) {
+               connman_error("memory allocation failed");
+               fclose(fp);
+               return NULL;
+       }
+
+       snprintf(str, MAC_ADDR_LEN, "%c%c%c%c%c%c%c%c%c%c%c%c",
+                       g_ascii_tolower(wifi_mac[0]), g_ascii_tolower(wifi_mac[1]),
+                       g_ascii_tolower(wifi_mac[3]), g_ascii_tolower(wifi_mac[4]),
+                       g_ascii_tolower(wifi_mac[6]), g_ascii_tolower(wifi_mac[7]),
+                       g_ascii_tolower(wifi_mac[9]), g_ascii_tolower(wifi_mac[10]),
+                       g_ascii_tolower(wifi_mac[12]), g_ascii_tolower(wifi_mac[13]),
+                       g_ascii_tolower(wifi_mac[15]), g_ascii_tolower(wifi_mac[16]));
+       fclose(fp);
+       return str;
+}
+#endif
+
+#if defined TIZEN_EXT
 char *index2ident(int index, const char *prefix)
 #else
 static char *index2ident(int index, const char *prefix)
@@ -1897,7 +1978,17 @@ struct connman_device *connman_device_create_from_index(int index)
        case CONNMAN_DEVICE_TYPE_ETHERNET:
        case CONNMAN_DEVICE_TYPE_GADGET:
        case CONNMAN_DEVICE_TYPE_WIFI:
+#if defined TIZEN_EXT
+               if (type == CONNMAN_DEVICE_TYPE_WIFI)
+                       name = _get_wifi_ident();
+               if (!name)
+#endif
                name = index2ident(index, "");
+#if defined TIZEN_EXT
+               if (type == CONNMAN_DEVICE_TYPE_WIFI)
+                       addr = _get_wifi_addr();
+               if (!addr)
+#endif
                addr = index2addr(index);
                break;
        case CONNMAN_DEVICE_TYPE_BLUETOOTH:
@@ -1922,6 +2013,10 @@ struct connman_device *connman_device_create_from_index(int index)
                ident = index2ident(index, NULL);
                break;
        case CONNMAN_DEVICE_TYPE_WIFI:
+#if defined TIZEN_EXT
+               ident = _get_wifi_ident();
+               if (!ident)
+#endif
                ident = index2ident(index, NULL);
                break;
        case CONNMAN_DEVICE_TYPE_BLUETOOTH:
index e0ef7db..4814546 100644 (file)
@@ -451,8 +451,15 @@ void connman_inet_update_device_ident(struct connman_device *device)
        case CONNMAN_DEVICE_TYPE_ETHERNET:
        case CONNMAN_DEVICE_TYPE_GADGET:
        case CONNMAN_DEVICE_TYPE_WIFI:
-               addr = index2addr(index);
-               ident = index2ident(index, NULL);
+               if (type == CONNMAN_DEVICE_TYPE_WIFI)
+                       addr = _get_wifi_addr();
+               if (!addr)
+                       addr = index2addr(index);
+
+               if (type == CONNMAN_DEVICE_TYPE_WIFI)
+                       ident = _get_wifi_ident();
+               if (!ident)
+                       ident = index2ident(index, NULL);
                break;
        case CONNMAN_DEVICE_TYPE_CELLULAR:
                ident = index2ident(index, NULL);