From 367270edb04b381136c94436336d437c7333d629 Mon Sep 17 00:00:00 2001 From: likuanxin Date: Fri, 29 Dec 2023 16:06:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=BC=80wpa=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: likuanxin --- .../hdi_interface/wifi_hdi_wpa_proxy.c | 20 ++++++++++-- .../hdi_interface/wifi_hdi_wpa_proxy.h | 2 ++ .../hdi_interface/wifi_hdi_wpa_sta_impl.c | 1 + .../hdi_client/wifi_hdi_wpa_callback.cpp | 1 + .../wifi_sta_hal_interface.cpp | 32 +++++++++---------- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c index 0a71dddfa..52615695f 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c @@ -40,16 +40,19 @@ static pthread_mutex_t g_wpaObjMutex = PTHREAD_MUTEX_INITIALIZER; static unsigned int g_wpaRefCount = 0; static struct IWpaInterface *g_wpaObj = NULL; static struct HDIDeviceManager *g_devMgr = NULL; +static unsigned int g_wpaStubProcessDeath = 29189; WifiErrorNo HdiWpaStart() { LOGI("HdiWpaStart start..."); pthread_mutex_lock(&g_wpaObjMutex); - if (g_wpaRefCount != 0) { + if (g_wpaRefCount != 0 && g_wpaObj != NULL && g_devMgr != NULL) { ++g_wpaRefCount; pthread_mutex_unlock(&g_wpaObjMutex); - LOGI("%{public}s wpa ref count: %d", __func__, g_wpaRefCount); + LOGI("%{public}s wpa ref count: %{public}d", __func__, g_wpaRefCount); return WIFI_IDL_OPT_OK; + } else { + g_wpaRefCount = 0; } g_devMgr = HDIDeviceManagerGet(); @@ -143,6 +146,7 @@ WifiErrorNo HdiAddWpaIface(const char *ifName, const char *confName) int32_t ret = g_wpaObj->AddWpaIface(g_wpaObj, ifName, confName); if (ret != HDF_SUCCESS) { LOGE("%{public}s AddWpaIface failed: %{public}d", __func__, ret); + HdiWpaResetGlobalObj(ret); pthread_mutex_unlock(&g_wpaObjMutex); return WIFI_IDL_OPT_FAILED; } @@ -171,6 +175,7 @@ WifiErrorNo HdiRemoveWpaIface(const char *ifName) int32_t ret = g_wpaObj->RemoveWpaIface(g_wpaObj, ifName); if (ret != HDF_SUCCESS) { LOGE("%{public}s RemoveWpaIface failed: %{public}d", __func__, ret); + HdiWpaResetGlobalObj(ret); pthread_mutex_unlock(&g_wpaObjMutex); return WIFI_IDL_OPT_FAILED; } @@ -259,4 +264,15 @@ WifiErrorNo CopyConfigFile(const char* configName) LOGE("Copy config file failed: %{public}s", configName); return WIFI_IDL_OPT_FAILED; } + +void HdiWpaResetGlobalObj(int errorCode) +{ + if (g_wpaStubProcessDeath == errorCode) { + g_wpaRefCount = 0; + g_wpaObj = NULL; + g_devMgr = NULL; + LOGE("%{public}s reset wpa g_wpaObj", __func__); + } + HdiWpaStart(); +} #endif \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.h index 019643786..f15fe36ec 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.h @@ -111,6 +111,8 @@ WifiErrorNo CopyUserFile(const char *srcFilePath, const char* destFilePath); */ WifiErrorNo CopyConfigFile(const char* configName); +void HdiWpaResetGlobalObj(int errorCode); + #ifdef __cplusplus } #endif diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_sta_impl.c b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_sta_impl.c index 936166279..0c85587c0 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_sta_impl.c +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_sta_impl.c @@ -79,6 +79,7 @@ static WifiErrorNo RegisterEventCallback() if (result != HDF_SUCCESS) { pthread_mutex_unlock(&g_hdiCallbackMutex); LOGE("RegisterEventCallback: RegisterEventCallback failed result:%{public}d", result); + HdiWpaResetGlobalObj(result); return WIFI_IDL_OPT_FAILED; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_callback.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_callback.cpp index bd5e77d3e..fbe416203 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_callback.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_callback.cpp @@ -93,6 +93,7 @@ int32_t OnEventStateChanged(struct IWpaCallback *self, if (cbk.onWpaStateChanged) { cbk.onWpaStateChanged(statechangedParam->status); } + LOGI("OnEventStateChanged:callback out status = %{public}d",statechangedParam->status); return 0; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.cpp index 4fbc08f19..088fa3812 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.cpp @@ -48,38 +48,38 @@ WifiStaHalInterface &WifiStaHalInterface::GetInstance(void) WifiErrorNo WifiStaHalInterface::StartWifi(void) { - WifiErrorNo ret = WIFI_IDL_OPT_OK; + int32_t ret = WIFI_IDL_OPT_OK; #ifdef HDI_WPA_INTERFACE_SUPPORT CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_IDL_OPT_FAILED); - ret = mHdiWpaClient->StartWifi(); + ret |= mHdiWpaClient->StartWifi(); #else CHECK_NULL_AND_RETURN(mIdlClient, WIFI_IDL_OPT_FAILED); - ret = mIdlClient->StartWifi(); + ret |= mIdlClient->StartWifi(); #endif #ifdef HDI_INTERFACE_SUPPORT CHECK_NULL_AND_RETURN(mHdiClient, WIFI_IDL_OPT_FAILED); - ret = mHdiClient->StartWifi(); + ret |= mHdiClient->StartWifi(); #endif - return ret; + return (WifiErrorNo)ret; } WifiErrorNo WifiStaHalInterface::StopWifi(void) { - WifiErrorNo ret = WIFI_IDL_OPT_OK; -#ifdef HDI_WPA_INTERFACE_SUPPORT - CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_IDL_OPT_FAILED); - ret = mHdiWpaClient->StopWifi(); -#else - CHECK_NULL_AND_RETURN(mIdlClient, WIFI_IDL_OPT_FAILED); - ret = mIdlClient->StopWifi(); -#endif - + int32_t ret = WIFI_IDL_OPT_OK; #ifdef HDI_INTERFACE_SUPPORT CHECK_NULL_AND_RETURN(mHdiClient, WIFI_IDL_OPT_FAILED); - ret = mHdiClient->StopWifi(); + ret |= mHdiClient->StopWifi(); #endif - return ret; + +#ifdef HDI_WPA_INTERFACE_SUPPORT + CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_IDL_OPT_FAILED); + ret |= mHdiWpaClient->StopWifi(); +#else + CHECK_NULL_AND_RETURN(mIdlClient, WIFI_IDL_OPT_FAILED); + ret |= mIdlClient->StopWifi(); +#endif + return (WifiErrorNo)ret; } WifiErrorNo WifiStaHalInterface::Connect(int networkId)