适配wpa字符串修改

Signed-off-by: likuanxin <likuanxin@huawei.com>
This commit is contained in:
likuanxin 2023-12-23 17:45:19 +08:00
parent 8d887e2816
commit 2bd3c22a7d
3 changed files with 22 additions and 10 deletions

View File

@ -218,7 +218,9 @@ WifiErrorNo CopyUserFile(const char *srcFilePath, const char* destFilePath)
LOGE("CopyUserFile() failed, read srcFilePath:%{public}s error!", srcFilePath);
break;
}
write(destFd, buf, bytes);
if (write(destFd, buf, bytes) < 0) {
LOGE("CopyUserFile() failed, write destFilePath:%{public}s error!", destFilePath);
}
}
} while (0);
if (srcFd>=0) {

View File

@ -26,13 +26,13 @@ constexpr int WIFI_HDI_STR_MAC_LENGTH = 17;
int32_t OnEventDisconnected(struct IWpaCallback *self,
const struct HdiWpaDisconnectParam *disconectParam, const char* ifName)
{
LOGI("OnEventDisconnected: callback enter!");
if (disconectParam == NULL) {
LOGE("OnEventDisconnected: invalid parameter!");
return 1;
}
uint32_t bssidLen = disconectParam->bssidLen;
std::string strBssid = OHOS::Wifi::ConvertArrayToHex(disconectParam->bssidLen,
disconectParam->bssidLen);
std::string strBssid = OHOS::Wifi::ConvertArrayToHex(disconectParam->bssid, bssidLen);
char szBssid[WIFI_HDI_STR_MAC_LENGTH +1] = {0};
ConvertMacToStr(disconectParam->bssid, bssidLen, szBssid, sizeof(szBssid));
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
@ -45,13 +45,13 @@ int32_t OnEventDisconnected(struct IWpaCallback *self,
int32_t OnEventConnected(struct IWpaCallback *self,
const struct HdiWpaConnectParam *connectParam, const char* ifName)
{
LOGI("OnEventConnected: callback enter!");
if (connectParam == NULL) {
LOGE("OnEventConnected: invalid parameter!");
return 1;
}
uint32_t bssidLen = connectParam->bssidLen;
std::string strBssid = OHOS::Wifi::ConvertArrayToHex(connectParam->bssidLen,
connectParam->bssidLen);
std::string strBssid = OHOS::Wifi::ConvertArrayToHex(connectParam->bssid, bssidLen);
char szBssid[WIFI_HDI_STR_MAC_LENGTH +1] = {0};
ConvertMacToStr(connectParam->bssid, bssidLen, szBssid, sizeof(szBssid));
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
@ -64,14 +64,18 @@ int32_t OnEventConnected(struct IWpaCallback *self,
int32_t OnEventBssidChanged(struct IWpaCallback *self,
const struct HdiWpaBssidChangedParam *bssidChangedParam, const char* ifName)
{
LOGI("OnEventBssidChanged: callback enter!");
if (bssidChangedParam == NULL) {
LOGE("OnEventBssidChanged: invalid parameter!");
return 1;
}
uint32_t bssidLen = bssidChangedParam->bssidLen;
std::string strBssid = OHOS::Wifi::ConvertArrayToHex(bssidChangedParam->bssid, bssidLen);
char szBssid[WIFI_HDI_STR_MAC_LENGTH +1] = {0};
ConvertMacToStr(disconectParam->bssid, bssidLen, szBssid, sizeof(szBssid));
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
if (cbk.onBssidChanged) {
cbk.onBssidChanged((const char *)bssidChangedParam->reason, (const char *)bssidChangedParam->bssid);
cbk.onBssidChanged((const char *)bssidChangedParam->reason, szBssid);
}
return 0;
}
@ -79,6 +83,7 @@ int32_t OnEventBssidChanged(struct IWpaCallback *self,
int32_t OnEventStateChanged(struct IWpaCallback *self,
const struct HdiWpaStateChangedParam *statechangedParam, const char* ifName)
{
LOGI("OnEventStateChanged: callback enter!");
if (statechangedParam == NULL) {
LOGE("OnEventStateChanged: invalid parameter!");
return 1;
@ -94,6 +99,7 @@ int32_t OnEventStateChanged(struct IWpaCallback *self,
int32_t OnEventTempDisabled(struct IWpaCallback *self,
const struct HdiWpaTempDisabledParam *tempDisabledParam, const char *ifName)
{
LOGI("OnEventTempDisabled: callback enter!");
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
if (cbk.onWpaSsidWrongKey) {
cbk.onWpaSsidWrongKey(1);
@ -104,6 +110,7 @@ int32_t OnEventTempDisabled(struct IWpaCallback *self,
int32_t OnEventAssociateReject(struct IWpaCallback *self,
const struct HdiWpaAssociateRejectParam *associateRejectParam, const char *ifName)
{
LOGI("OnEventAssociateReject: callback enter!");
if (associateRejectParam == NULL) {
LOGE("OnEventAssociateReject: invalid parameter!");
return 1;
@ -118,6 +125,7 @@ int32_t OnEventAssociateReject(struct IWpaCallback *self,
int32_t OnEventWpsOverlap(struct IWpaCallback *self, const char *ifName)
{
LOGI("OnEventWpsOverlap: callback enter!");
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
if (cbk.onWpsOverlap) {
cbk.onWpsOverlap(1);
@ -127,6 +135,7 @@ int32_t OnEventWpsOverlap(struct IWpaCallback *self, const char *ifName)
int32_t OnEventWpsTimeout(struct IWpaCallback *self, const char *ifName)
{
LOGI("OnEventWpsTimeout: callback enter!");
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
if (cbk.onWpsTimeOut) {
cbk.onWpsTimeOut(1);
@ -137,6 +146,7 @@ int32_t OnEventWpsTimeout(struct IWpaCallback *self, const char *ifName)
int32_t OnEventScanResult(struct IWpaCallback *self,
const struct HdiWpaRecvScanResultParam *recvScanResultParam, const char* ifName)
{
LOGI("OnEventScanResult: callback enter!");
if (recvScanResultParam == NULL) {
LOGE("OnEventScanResult: invalid parameter!");
return 1;

View File

@ -2,9 +2,9 @@
"jobs" : [{
"name" : "early-boot",
"cmds" : [
"mkdir /data/service/el1/public/wifi 0770 wifi wifi",
"mkdir /data/service/el1/public/wifi/wpa_supplicant 0770 wifi wifi",
"mkdir /data/service/el1/public/wifi/sockets 0770 wifi wifi",
"mkdir /data/service/el1/public/wifi 0770 wifi wifi_group",
"mkdir /data/service/el1/public/wifi/wpa_supplicant 0770 wifi wifi_group",
"mkdir /data/service/el1/public/wifi/sockets 0770 wifi wifi_group",
"mkdir /data/service/el1/public/dhcp 0770 dhcp dhcp"
]
}, {