Merge "[RDKB][common][wifi hal get device info take too long time]"
diff --git a/src/logan_wifi/wifi_hal.c b/src/logan_wifi/wifi_hal.c
index 89cf46c..93fead0 100644
--- a/src/logan_wifi/wifi_hal.c
+++ b/src/logan_wifi/wifi_hal.c
@@ -2761,6 +2761,9 @@
 	WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
 }
 
+typedef long time_t;
+static time_t radio_up_time[MAX_NUM_RADIOS];
+
 static void
 wifiBringUpInterfacesForRadio(int radio_idx)
 {
@@ -2854,6 +2857,7 @@
 {
     int radio_idx;
     int band_idx;
+	struct timeval tv_now;
 
     WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
 
@@ -2863,6 +2867,9 @@
             break;
         }
         wifiBringUpInterfacesForRadio(radio_idx);
+
+		gettimeofday(&tv_now, NULL);
+		radio_up_time[radio_idx] = tv_now.tv_sec;
     }
     WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
 }
@@ -3524,9 +3531,6 @@
 	return RETURN_OK;
 }
 
-typedef long time_t;
-static time_t radio_up_time[MAX_NUM_RADIOS];
-
 enum mwctl_chan_width {
 	MWCTL_CHAN_WIDTH_20,
 	MWCTL_CHAN_WIDTH_40,
@@ -3741,10 +3745,6 @@
 				}
 			}
 		}
-		if (time(&radio_up_time[radioIndex]) < 0) {
-			wifi_debug(DEBUG_ERROR, "GET time fail\n");
-			return RETURN_ERR;
-		}
 	}
 
 	WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
@@ -14478,19 +14478,18 @@
 
 INT wifi_getRadioUpTime(INT radioIndex, ULONG *output)
 {
-	time_t now;
+	ULONG currentTime;
+	struct timeval tv_now;
 
-	now = time(NULL);
-	if (now < 0) {
-		wifi_debug(DEBUG_ERROR, "GET time fail\n");
-		return RETURN_ERR;
-	}
-	if (now > radio_up_time[radioIndex])
-		*output = now - radio_up_time[radioIndex];
-	else {
-		*output = 0;
-		return RETURN_ERR;
+	gettimeofday(&tv_now, NULL);
+	currentTime = tv_now.tv_sec;
+
+	if (currentTime >= radio_up_time[radioIndex]) {
+		*output = currentTime - radio_up_time[radioIndex];
 	}
+    else {
+		*output = 0xFFFFFFFFUL - radio_up_time[radioIndex] + currentTime;
+    }
 
 	return RETURN_OK;
 }
@@ -20195,6 +20194,8 @@
 	int ApIndex;
 	int ret, bss_num, i;
 	char ret_buf[MAX_BUF_SIZE] = {0};
+	BOOL enabled = FALSE;
+	struct timeval tv_now;
 
 	ret = wifi_BandProfileRead(0, index, "BssidNum", ret_buf, sizeof(ret_buf), "1");
 	if (ret != 0) {
@@ -20215,6 +20216,19 @@
 	WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
 
 	multiple_set = TRUE;
+	if (wifi_getRadioEnable(index, &enabled) != RETURN_OK)
+	{
+		wifi_debug(DEBUG_ERROR, "wifi_getRadioEnable return error.\n");
+		return RETURN_ERR;
+	}
+	if (enabled == FALSE && operationParam->enable == TRUE) {
+		wifi_setRadioEnable(index, TRUE);
+		gettimeofday(&tv_now, NULL);
+		radio_up_time[index] = tv_now.tv_sec;
+	} else if (enabled == TRUE && operationParam->enable == FALSE) {
+		wifi_setRadioEnable(index, FALSE);
+		return RETURN_OK;
+	}
 	if (wifi_getRadioOperatingParameters(index, &current_param) != RETURN_OK) {
 		wifi_debug(DEBUG_ERROR, "wifi_getRadioOperatingParameters return error.\n");
 		goto err;
@@ -20412,7 +20426,6 @@
 			wifi_quick_reload_ap(ApIndex);
 		}
 	}
-	
 
 	WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);