diff --git a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_lock_info.h b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_lock_info.h deleted file mode 100644 index 7e1d17cea675e7439ca2bb5da18f433f1b1a7787..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_lock_info.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFILOCKINFO_H -#define OHOS_WIFILOCKINFO_H - -#include -#include "wifi_msg.h" -#include "wifi_errcode.h" - -namespace OHOS { -namespace Wifi { -class WifiLockInfo { -public: - /** - * @Description Construct a new Wifi Lock object - * - * @param lockMode - lock type - * @param tag - lock name, which is a unique identifier - */ - WifiLockInfo(const WifiLockMode &lockType, const std::string &tag); - - /** - * @Description Construct a new Default Wifi Lock object - * - */ - WifiLockInfo(); - - /** - * @Description Destroy the Wifi Lock Info object - * - */ - ~WifiLockInfo(); - - /** - * @Description Acquire the Wi-Fi lock. - * - * @param lockType - WifiLockMode object - * @param tag - Lock tag - * @return ErrCode - operation result - */ - ErrCode Acquire(); - - /** - * @Description Release Wi-Fi lock. - * - * @param tag - Lock tag - * @return ErrCode - operation result - */ - ErrCode Release(); - - /** - * @Description Set wifi lock reference counted flag, whether used reference count mode - * - * @param refCounted - true / false - */ - void SetReferenceCounted(bool refCounted); - - /** - * @Description Check mHeld's value - * - * @return true - * @return false - */ - bool IsHeld(); - - /** - * @Description Set the Lock Type object - * - * @param lockType - lock type - */ - void SetLockType(const WifiLockMode &lockType); - - /** - * @Description Get the Lock Type object - * - * @return WifiLockMode - lock type - */ - WifiLockMode GetLockType() const; - - /** - * @Description Set the lock Tag object - * - * @param tag - lock tag info - */ - void SetTag(const std::string &tag); - - /** - * @Description Get the Lock Tag object - * - * @return std::string - lock tag info - */ - std::string GetTag() const; - -private: - std::string mTag; - int mRefCount; - WifiLockMode mLockType; - bool mRefCounted; - bool mHeld; -}; -} // namespace Wifi -} // namespace OHOS -#endif diff --git a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h index affa711ac272b594093fd0ea8cd4c7e04b120dfd..9ab1d70b66da2d88a50f49a01f1ef2aa54adc121 100644 --- a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h +++ b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h @@ -140,20 +140,6 @@ enum class IsWpsConnected { WPS_CONNECTED = 0, WPS_INVALID = -1, }; -/* WifiLock mode */ -enum class WifiLockMode { - WIFI_MODE_FULL = 0, - WIFI_MODE_SCAN_ONLY = 1, - WIFI_MODE_FULL_HIGH_PERF = 2, - WIFI_MODE_FULL_LOW_LATENCY = 3, - WIFI_MODE_NO_LOCKS_HELD = 4 -}; - -enum class LowLatecySupport { - LOW_LATENCY_SUPPORT_UNDEFINED = 0, - LOW_LATENCY_SUPPORTED = 1, - LOW_LATENCY_NOT_SUPPORTED = 2 -}; /* WPS config */ struct WpsConfig { @@ -357,41 +343,8 @@ struct WifiDeviceConfig { int priority; /* is hidden network */ bool hiddenSSID; - /* Is enable WPAI Certified */ - bool isEnableWPAICertified; - /** - * support encryption mode, use bit define enable/disable; - * 0: NONE,1:WPA_PSK,2:WPA_EAP,3:IEEE8021X example: - * value is 7 and binary is 0111, this defines - * support NONE, WPA_PSK and WPA_EAP - */ - unsigned int allowedKeyManagement; - /** - * support encryption protocols, use bit define enable/disable - * 0: WPA, 1: RSN example: value is 2 and binary is 0010, - * this defines support RSN. - */ - int allowedProtocols; - /** - * support auth algorithms, use bit define enable/disable; - * bit 0: OPEN 1: SHARED 2 LEAP example: value is 3 and binary - * is 0011, this defines support OPEN and SHARED。 - */ - int allowedAuthAlgorithms; - /** - * support PairwiseCiphers, use bit define enable/disable; - * 0: NONE 1: TKIP 2:CCMP example: value is 3 and binary is 0011, - * this defines support NONE and TKIP. - */ - int allowedPairwiseCiphers; /* Random mac address */ std::string macAddress; - /** - * support GroupCiphers, use bit define enable/disable; - * 0: WEP40, 1: WEP104, 2: TKIP, 3: CCMP example: value is 7 and - * binary is 0111, this defines support WEP40, WEP104 and TKIP. - */ - int allowedGroupCiphers; WifiIpConfig wifiIpConfig; WifiEapConfig wifiEapConfig; WifiProxyConfig wifiProxyconfig; @@ -410,12 +363,6 @@ struct WifiDeviceConfig { wepTxKeyIndex = 0; priority = 0; hiddenSSID = false; - isEnableWPAICertified = false; - allowedKeyManagement = 0; - allowedProtocols = 0; - allowedAuthAlgorithms = 0; - allowedPairwiseCiphers = 0; - allowedGroupCiphers = 0; wifiPrivacySetting = WifiPrivacyConfig::RANDOMMAC; rssi = -100; } @@ -473,27 +420,6 @@ struct WifiMockState { } }; -struct SingleAppForbid { - int appID; - ScanIntervalMode scanIntervalMode; - int lessThanIntervalNum; - time_t continueScanTime; - time_t blockListScanTime; - int expScanCount; - int fixedScanCount; - time_t fixedCurrentTime; - SingleAppForbid() - { - appID = 0; - lessThanIntervalNum = 0; - continueScanTime = 0; - blockListScanTime = 0; - expScanCount = 0; - fixedScanCount = 0; - fixedCurrentTime = 0; - } -}; - /* DHCP info */ struct DhcpInfo { int ipAddress; /* ip address */ diff --git a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_multicast_lock_info.h b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_multicast_lock_info.h deleted file mode 100644 index 6dd7843c819c61aae598c12568dd274ed48c25b8..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_multicast_lock_info.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIMULTICASTLOCKINFO_H -#define OHOS_WIFIMULTICASTLOCKINFO_H - -#include -#include "wifi_errcode.h" - -namespace OHOS { -namespace Wifi { -class WifiMulticastLockInfo { -public: - /** - * @Description Construct a new Wifi Multicast Lock Info object - * - * @param tag - lock tag info - */ - WifiMulticastLockInfo(const std::string &tag); - - /** - * @Description Construct a new Default Wifi Multicast Lock Info object - * - */ - WifiMulticastLockInfo(); - - /** - * @Description Destroy the Wifi Multicast Lock Info object - * - */ - ~WifiMulticastLockInfo(); - - /** - * @Description Acquire multicast lock. - * - * @param tag - Lock tag - * @return ErrCode - operation result - */ - ErrCode Acquire(); - - /** - * @Description Release multicast lock. - * - * @param tag - Lock tag - * @return ErrCode - operation result - */ - ErrCode Release(); - - /** - * @Description Set wifi lock reference counted flag, whether used reference count mode - * - * @param refCounted - true / false - */ - void SetReferenceCounted(bool refCounted); - - /** - * @Description Check mHeld's value - * - * @return true - * @return false - */ - bool IsHeld(); - - /** - * @Description Set the Tag object - * - * @param tag - lock tag info - */ - void SetTag(const std::string &tag); - - /** - * @Description Get the Tag object - * - * @return std::string - lock tag info - */ - std::string GetTag() const; - -private: - std::string mTag; - int mRefCount; - bool mRefCounted; - bool mHeld; -}; -} // namespace Wifi -} // namespace OHOS -#endif diff --git a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_scan_msg.h b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_scan_msg.h index 36cd34486db690b76a36d0041ab41d7ace97a343..a619ec0f14ecbd1685c49783d3b1d799e4c4ea4d 100644 --- a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_scan_msg.h +++ b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_scan_msg.h @@ -19,6 +19,7 @@ #include #include #include +#include namespace OHOS { namespace Wifi { @@ -82,7 +83,7 @@ struct WifiScanInfo { std::string capabilities; int frequency; int level; /* signal level */ - long timestamp; + int64_t timestamp; WifiScanInfo() { diff --git a/interfaces/innerkits/native_cpp/wifi_standard/src/wifi_device_proxy.cpp b/interfaces/innerkits/native_cpp/wifi_standard/src/wifi_device_proxy.cpp index f65e0e92563c104002a5cdf7c24ef802d3c5bc56..d7b13323edafc5fc0dab69bbadb63e270d53aeb5 100644 --- a/interfaces/innerkits/native_cpp/wifi_standard/src/wifi_device_proxy.cpp +++ b/interfaces/innerkits/native_cpp/wifi_standard/src/wifi_device_proxy.cpp @@ -124,12 +124,6 @@ void WifiDeviceProxy::WriteDeviceConfig(const WifiDeviceConfig &config, MessageP data.WriteInt32(config.wepTxKeyIndex); data.WriteInt32(config.priority); data.WriteBool(config.hiddenSSID); - data.WriteBool(config.isEnableWPAICertified); - data.WriteInt32(config.allowedKeyManagement); - data.WriteInt32(config.allowedProtocols); - data.WriteInt32(config.allowedAuthAlgorithms); - data.WriteInt32(config.allowedPairwiseCiphers); - data.WriteInt32(config.allowedGroupCiphers); data.WriteInt32((int)config.wifiIpConfig.assignMethod); WriteIpAddress(data, config.wifiIpConfig.staticIpAddress.ipAddress.address); data.WriteInt32(config.wifiIpConfig.staticIpAddress.ipAddress.prefixLength); @@ -242,12 +236,6 @@ void WifiDeviceProxy::ParseDeviceConfigs(MessageParcel &reply, std::vector #include "common.h" #include "context.h" @@ -59,6 +60,15 @@ int WriteInt(Context *context, int i); */ int WriteLong(Context *context, long L); +/** + * @Description Write data of the int64 type + * + * @param context - Communication Context + * @param i - int64 integer + * @return int - 0 Success; -1 Failed + */ +int WriteInt64(Context *context, int64_t i); + /** * @Description Write data of the double type * @@ -132,6 +142,15 @@ int ReadInt(Context *context, int *i); */ int ReadLong(Context *context, long *L); +/** + * @Description Reads data of the int64 type from the context + * + * @param context - Communication Context + * @param i - pointer to a int64 + * @return int - 0 Success; < 0 read error + */ +int ReadInt64(Context *context, int64_t *i); + /** * @Description Reads data of the double type from the context * diff --git a/services/wifi_standard/ipc_framework/cRPC/src/serial.c b/services/wifi_standard/ipc_framework/cRPC/src/serial.c index 98252759f8ec207b2c33a018d9b679a0f8b23a5c..3bec7315fe7e863acacbd5ff4078bfbe87179ec2 100644 --- a/services/wifi_standard/ipc_framework/cRPC/src/serial.c +++ b/services/wifi_standard/ipc_framework/cRPC/src/serial.c @@ -82,6 +82,19 @@ int WriteLong(Context *context, long lData) return ContextAppendWrite(context, szTmp, strlen(szTmp)); } +int WriteInt64(Context *context, int64_t iData) +{ + if (context == NULL) { + return -1; + } + + char szTmp[TMP_CHAR_LEN] = {0}; + if (snprintf_s(szTmp, sizeof(szTmp), sizeof(szTmp) - 1, "%lld%c", iData, context->cSplit) < 0) { + return -1; + } + return ContextAppendWrite(context, szTmp, strlen(szTmp)); +} + int WriteDouble(Context *context, double dData) { if (context == NULL) { @@ -276,6 +289,22 @@ int ReadLong(Context *context, long *pLong) return 0; } +int ReadInt64(Context *context, int64_t *pInt64) +{ + if (context == NULL) { + return -1; + } + + char szTmp[TMP_CHAR_LEN] = {0}; + int len = ReadNextNum(context, szTmp, sizeof(szTmp)); + if (len < 0) { + return len; + } + *pInt64 = atoll(szTmp); + context->nPos += len + 1; + return 0; +} + int ReadDouble(Context *context, double *dData) { if (context == NULL) { diff --git a/services/wifi_standard/wifi_framework/common/config/wifi_config_file_spec.cpp b/services/wifi_standard/wifi_framework/common/config/wifi_config_file_spec.cpp index d86b2f3880f7090d4ce0a15e4618ff453c60fcb7..a1b9112de92034bb1dc25422b0d3340c9d836548 100644 --- a/services/wifi_standard/wifi_framework/common/config/wifi_config_file_spec.cpp +++ b/services/wifi_standard/wifi_framework/common/config/wifi_config_file_spec.cpp @@ -37,12 +37,6 @@ static void ClearWifiDeviceConfig(WifiDeviceConfig &item) item.wepTxKeyIndex = 0; item.priority = 0; item.hiddenSSID = false; - item.isEnableWPAICertified = false; - item.allowedKeyManagement = 0; - item.allowedProtocols = 0; - item.allowedAuthAlgorithms = 0; - item.allowedPairwiseCiphers = 0; - item.allowedGroupCiphers = 0; return; } @@ -146,18 +140,6 @@ static void SetWifiDeviceConfig(WifiDeviceConfig &item, const std::string &key, } if (key == "hiddenSSID") { item.hiddenSSID = std::stoi(value); - } else if (key == "isEnableWPAICertified") { - item.isEnableWPAICertified = std::stoi(value); - } else if (key == "allowedKeyManagement") { - item.allowedKeyManagement = std::stoi(value); - } else if (key == "allowedProtocols") { - item.allowedProtocols = std::stoi(value); - } else if (key == "allowedAuthAlgorithms") { - item.allowedAuthAlgorithms = std::stoi(value); - } else if (key == "allowedPairwiseCiphers") { - item.allowedPairwiseCiphers = std::stoi(value); - } else if (key == "allowedGroupCiphers") { - item.allowedGroupCiphers = std::stoi(value); } else if (key.compare(0, strlen("wepKeys"), "wepKeys") == 0) { int pos = std::stoi(key.substr(strlen("wepKeys") + 1)); if (pos >= 0 && pos < WEPKEYS_SIZE) { @@ -282,12 +264,6 @@ static std::string OutPutWifiDeviceConfig(WifiDeviceConfig &item) ss << "wepTxKeyIndex=" << item.wepTxKeyIndex << std::endl; ss << "priority=" << item.priority << std::endl; ss << "hiddenSSID=" << (int)item.hiddenSSID << std::endl; - ss << "isEnableWPAICertified=" << (int)item.isEnableWPAICertified << std::endl; - ss << "allowedKeyManagement=" << item.allowedKeyManagement << std::endl; - ss << "allowedProtocols=" << item.allowedProtocols << std::endl; - ss << "allowedAuthAlgorithms=" << item.allowedAuthAlgorithms << std::endl; - ss << "allowedPairwiseCiphers=" << item.allowedPairwiseCiphers << std::endl; - ss << "allowedGroupCiphers=" << item.allowedGroupCiphers << std::endl; for (int i = 0; i < WEPKEYS_SIZE; ++i) { ss << "wepKeys_" << i << "=" << item.wepKeys[i] << std::endl; } diff --git a/services/wifi_standard/wifi_framework/common/config/wifi_settings.cpp b/services/wifi_standard/wifi_framework/common/config/wifi_settings.cpp index fb88edf4278a89589b884df53acf401a8ccf59a7..2a894c7f08b6ef05ba8cedb7d0b2d5ab5d36156e 100644 --- a/services/wifi_standard/wifi_framework/common/config/wifi_settings.cpp +++ b/services/wifi_standard/wifi_framework/common/config/wifi_settings.cpp @@ -134,7 +134,7 @@ int WifiSettings::GetScanInfoList(std::vector &results) { struct timespec clkTime = {0, 0}; clock_gettime(CLOCK_MONOTONIC, &clkTime); - long curr = clkTime.tv_sec * MSEC * MSEC + clkTime.tv_nsec / MSEC; /* us */ + int64_t curr = static_cast(clkTime.tv_sec) * MSEC * MSEC + clkTime.tv_nsec / MSEC; /* us */ std::unique_lock lock(mInfoMutex); for (auto iter = mWifiScanInfoList.begin(); iter != mWifiScanInfoList.end(); ++iter) { if (iter->timestamp + WIFI_GET_SCAN_RESULT_VALID_TIMESTAMP * MSEC * MSEC < curr) { diff --git a/services/wifi_standard/wifi_framework/common/include/wifi_internal_msg.h b/services/wifi_standard/wifi_framework/common/include/wifi_internal_msg.h index f5137d8d2c6b120b5c42d4c2900b96f43b1d16b3..27cdfba3080ca41b11a896ded6bd8d24dfe10bc8 100644 --- a/services/wifi_standard/wifi_framework/common/include/wifi_internal_msg.h +++ b/services/wifi_standard/wifi_framework/common/include/wifi_internal_msg.h @@ -193,6 +193,27 @@ struct WifiEventCallbackMsg { } }; +struct SingleAppForbid { + int appID; + ScanIntervalMode scanIntervalMode; + int lessThanIntervalNum; + time_t continueScanTime; + time_t blockListScanTime; + int expScanCount; + int fixedScanCount; + time_t fixedCurrentTime; + SingleAppForbid() + { + appID = 0; + lessThanIntervalNum = 0; + continueScanTime = 0; + blockListScanTime = 0; + expScanCount = 0; + fixedScanCount = 0; + fixedCurrentTime = 0; + } +}; + enum class DhcpIpType { /* dhcp IP type: ipv4 ipv6 mix */ DHCP_IPTYPE_IPV4, DHCP_IPTYPE_IPV6, diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/handler.cpp b/services/wifi_standard/wifi_framework/wifi_manage/common/handler.cpp index 942611e0e90f07b86eae248160c9a207b40be1b0..f6f1029210e1bdca2a1422905e06bc18d3029ca4 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/handler.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/handler.cpp @@ -79,12 +79,12 @@ void *Handler::RunHandleThreadFunc(void *pInstance) } Handler *pHandler = (Handler *)pInstance; - pHandler->GetAndHandleMessage(); + pHandler->GetAndDistributeMessage(); return nullptr; } -void Handler::GetAndHandleMessage() +void Handler::GetAndDistributeMessage() { if (pMyQueue == nullptr) { LOGE("pMyQueue is null.\n"); @@ -98,8 +98,8 @@ void Handler::GetAndHandleMessage() continue; } - DispatchMessage(msg); - MessageManage::GetInstance().Recycle(msg); + DistributeMessage(msg); + MessageManage::GetInstance().ReclaimMsg(msg); } return; @@ -113,19 +113,19 @@ void Handler::SendMessage(InternalMessage *msg) } LOGD("Handler::SendMessage msg:%{public}d", msg->GetMessageName()); - SendMessageDelayed(msg, 0); + MessageExecutedLater(msg, 0); return; } -void Handler::SendMessageDelayed(InternalMessage *msg, long delayMillis) +void Handler::MessageExecutedLater(InternalMessage *msg, int64_t delayTimeMs) { if (msg == nullptr) { - LOGE("Handler::SendMessageDelayed: msg is null."); + LOGE("Handler::MessageExecutedLater: msg is null."); return; } - LOGD("Handler::SendMessageDelayed msg:%{public}d", msg->GetMessageName()); - long delayTime = delayMillis; + LOGD("Handler::MessageExecutedLater msg:%{public}d", msg->GetMessageName()); + int64_t delayTime = delayTimeMs; if (delayTime < 0) { delayTime = 0; } @@ -136,26 +136,26 @@ void Handler::SendMessageDelayed(InternalMessage *msg, long delayMillis) LOGE("gettimeofday failed.\n"); return; } - long nowTime = curTime.tv_sec * USEC_1000 + curTime.tv_usec / USEC_1000; + int64_t nowTime = static_cast(curTime.tv_sec) * USEC_1000 + curTime.tv_usec / USEC_1000; - SendMessageAtTime(msg, nowTime + delayTime); + MessageExecutedAtTime(msg, nowTime + delayTime); return; } -void Handler::SendMessageAtTime(InternalMessage *msg, long uptimeMillis) +void Handler::MessageExecutedAtTime(InternalMessage *msg, int64_t execTime) { if (msg == nullptr) { - LOGE("Handler::SendMessageAtTime: msg is null."); + LOGE("Handler::MessageExecutedAtTime: msg is null."); return; } - LOGD("Handler::SendMessageAtTime msg: %{public}d", msg->GetMessageName()); + LOGD("Handler::MessageExecutedAtTime msg: %{public}d", msg->GetMessageName()); if (pMyQueue == nullptr) { LOGE("pMyQueue is null.\n"); return; } - if (pMyQueue->AddMessageToQueue(msg, uptimeMillis) != true) { + if (pMyQueue->AddMessageToQueue(msg, execTime) != true) { LOGE("AddMessageToQueue failed.\n"); return; } @@ -163,14 +163,14 @@ void Handler::SendMessageAtTime(InternalMessage *msg, long uptimeMillis) return; } -void Handler::SendMessageAtFrontOfQueue(InternalMessage *msg) +void Handler::PlaceMessageTopOfQueue(InternalMessage *msg) { if (msg == nullptr) { - LOGE("Handler::SendMessageAtFrontOfQueue: msg is null."); + LOGE("Handler::PlaceMessageTopOfQueue: msg is null."); return; } - LOGD("Handler::SendMessageAtFrontOfQueue msg: %{public}d", msg->GetMessageName()); + LOGD("Handler::PlaceMessageTopOfQueue msg: %{public}d", msg->GetMessageName()); if (pMyQueue == nullptr) { LOGE("pMyQueue is null.\n"); return; @@ -200,12 +200,12 @@ void Handler::DeleteMessageFromQueue(int messageName) return; } -void Handler::DispatchMessage(InternalMessage *msg) +void Handler::DistributeMessage(InternalMessage *msg) { if (msg == nullptr) { return; } - HandleMessage(msg); + ExecuteMessage(msg); return; } } // namespace Wifi diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/handler.h b/services/wifi_standard/wifi_framework/wifi_manage/common/handler.h index dc9fa245609195f9430eacc90cce60d4327a58f7..fda258c967e61f8ff9fc62492fdee6ab0665e7b8 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/handler.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/handler.h @@ -67,28 +67,28 @@ public: /** * @Description : Send a message, place the message in the message queue, and - process the message after delayMillis is delayed. + process the message after delayTimeMs is delayed. * * @param msg - Message to be sent.[in] - * @param delayMillis - Delay Time.[in] + * @param delayTimeMs - Delay Time.[in] */ - void SendMessageDelayed(InternalMessage *msg, long delayMillis); + void MessageExecutedLater(InternalMessage *msg, int64_t delayTimeMs); /** * @Description : Send a message, place the message in the message queue, and - process the message at the uptimeMillis time point. + process the message at the execTime time point. * * @param msg - Message to be sent.[in] - * @param uptimeMillis - Time when a message is processed.[in] + * @param execTime - Time when a message is processed.[in] */ - void SendMessageAtTime(InternalMessage *msg, long uptimeMillis); + void MessageExecutedAtTime(InternalMessage *msg, int64_t execTime); /** * @Description : Send a message and place the message at the top of the message queue. * * @param msg - Message to be sent.[in] */ - void SendMessageAtFrontOfQueue(InternalMessage *msg); + void PlaceMessageTopOfQueue(InternalMessage *msg); /** * @Description : Delete messages from the queue. @@ -102,24 +102,24 @@ public: * * @param msg - Messages to be processed.[in] */ - void DispatchMessage(InternalMessage *msg); + void DistributeMessage(InternalMessage *msg); /** - * @Description : Invoke the ProcessMessage interface of the current state + * @Description : Invoke the ExecuteStateMsg interface of the current state to process messages sent to the state machine. The entry/exit of the state machine is also called, and the delayed message is put back into queue when transitioning to a new state. * * @param msg - Messages.[in] */ - virtual void HandleMessage(InternalMessage *msg) = 0; + virtual void ExecuteMessage(InternalMessage *msg) = 0; /** * @Description : Obtains messages from the message queue, distributes the messages, and recycles the messages. * */ - void GetAndHandleMessage(); + void GetAndDistributeMessage(); private: /* message queue. */ diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.cpp b/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.cpp index f66af22a978a883b927eea1608826d1f0e25a87d..797d39d5a36e1a8e8ed54fe4ebdc4c1e51ba802e 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.cpp @@ -75,14 +75,12 @@ void MessageBody::CopyMessageBody(const MessageBody &origBody) InternalMessage::InternalMessage() : mMsgName(0), - mArg1(0), - mArg2(0), + mParam1(0), + mParam2(0), pMessageObj(nullptr), mObjSize(0), - pReplyTo(nullptr), - mSendingUid(0), - pNext(nullptr), - mWhen(0) + pNextMsg(nullptr), + mHandleTime(0) {} InternalMessage::~InternalMessage() @@ -100,14 +98,14 @@ int InternalMessage::GetMessageName() const return mMsgName; } -int InternalMessage::GetArg1() const +int InternalMessage::GetParam1() const { - return mArg1; + return mParam1; } -int InternalMessage::GetArg2() const +int InternalMessage::GetParam2() const { - return mArg2; + return mParam2; } const char *InternalMessage::GetMessageObj() const @@ -141,24 +139,14 @@ void InternalMessage::CopyMessageBody(const MessageBody &origBody) return; } -InternalMessage *InternalMessage::GetReplyTo() const +InternalMessage *InternalMessage::GetNextMsg() const { - return pReplyTo; + return pNextMsg; } -int InternalMessage::GetSendingUid() const +int64_t InternalMessage::GetHandleTime() const { - return mSendingUid; -} - -InternalMessage *InternalMessage::GetNext() const -{ - return pNext; -} - -long InternalMessage::GetWhen() const -{ - return mWhen; + return mHandleTime; } void InternalMessage::SetMessageName(int msgName) @@ -167,15 +155,15 @@ void InternalMessage::SetMessageName(int msgName) return; } -void InternalMessage::SetArg1(int arg1) +void InternalMessage::SetParam1(int param1) { - mArg1 = arg1; + mParam1 = param1; return; } -void InternalMessage::SetArg2(int arg2) +void InternalMessage::SetParam2(int param2) { - mArg2 = arg2; + mParam2 = param2; return; } @@ -207,27 +195,15 @@ void InternalMessage::ClearMessageBody() return; } -void InternalMessage::SetReplyTo(InternalMessage *replyTo) -{ - pReplyTo = replyTo; - return; -} - -void InternalMessage::SetSendingUid(int sendingUid) -{ - mSendingUid = sendingUid; - return; -} - -void InternalMessage::SetNext(InternalMessage *next) +void InternalMessage::SetNextMsg(InternalMessage *nextMsg) { - pNext = next; + pNextMsg = nextMsg; return; } -void InternalMessage::SetWhen(long when) +void InternalMessage::SetHandleTime(int64_t time) { - mWhen = when; + mHandleTime = time; return; } @@ -241,7 +217,7 @@ MessageManage &MessageManage::GetInstance() return *msgManage; } -MessageManage::MessageManage() : MAX_POOL_SIZE(MAX_POOL_SIZE_INIT), pSPool(nullptr), pSPoolSize(0) +MessageManage::MessageManage() : pMsgPool(nullptr), mMsgPoolSize(0) {} MessageManage::~MessageManage() @@ -250,15 +226,15 @@ MessageManage::~MessageManage() return; } -InternalMessage *MessageManage::Obtain() +InternalMessage *MessageManage::CreateMessage() { { std::unique_lock lock(mPoolMutex); - if (pSPool != nullptr) { - InternalMessage *m = pSPool; - pSPool = m->GetNext(); - m->SetNext(nullptr); - pSPoolSize--; + if (pMsgPool != nullptr) { + InternalMessage *m = pMsgPool; + pMsgPool = m->GetNextMsg(); + m->SetNextMsg(nullptr); + mMsgPoolSize--; return m; } } @@ -267,26 +243,24 @@ InternalMessage *MessageManage::Obtain() return pMessage; } -InternalMessage *MessageManage::Obtain(const InternalMessage *orig) +InternalMessage *MessageManage::CreateMessage(const InternalMessage *orig) { - InternalMessage *m = Obtain(); + InternalMessage *m = CreateMessage(); if (m == nullptr) { return nullptr; } m->SetMessageName(orig->GetMessageName()); - m->SetArg1(orig->GetArg1()); - m->SetArg2(orig->GetArg2()); + m->SetParam1(orig->GetParam1()); + m->SetParam2(orig->GetParam2()); m->CopyMessageBody(orig->GetMessageBody()); - m->SetReplyTo(orig->GetReplyTo()); - m->SetSendingUid(orig->GetSendingUid()); return m; } -InternalMessage *MessageManage::Obtain(int messageName) +InternalMessage *MessageManage::CreateMessage(int messageName) { - InternalMessage *m = Obtain(); + InternalMessage *m = CreateMessage(); if (m == nullptr) { return nullptr; } @@ -295,39 +269,37 @@ InternalMessage *MessageManage::Obtain(int messageName) return m; } -InternalMessage *MessageManage::Obtain(int messageName, int arg1, int arg2) +InternalMessage *MessageManage::CreateMessage(int messageName, int param1, int param2) { - InternalMessage *m = Obtain(); + InternalMessage *m = CreateMessage(); if (m == nullptr) { return nullptr; } m->SetMessageName(messageName); - m->SetArg1(arg1); - m->SetArg2(arg2); + m->SetParam1(param1); + m->SetParam2(param2); return m; } -void MessageManage::Recycle(InternalMessage *m) +void MessageManage::ReclaimMsg(InternalMessage *m) { if (m == nullptr) { return; } m->SetMessageName(0); - m->SetArg1(0); - m->SetArg2(0); + m->SetParam1(0); + m->SetParam2(0); m->ReleaseMessageObj(); m->ClearMessageBody(); - m->SetReplyTo(nullptr); - m->SetSendingUid(-1); { std::unique_lock lock(mPoolMutex); - if (pSPoolSize < MAX_POOL_SIZE) { - m->SetNext(pSPool); - pSPool = m; - pSPoolSize++; + if (mMsgPoolSize < MAX_MSG_NUM_IN_POOL) { + m->SetNextMsg(pMsgPool); + pMsgPool = m; + mMsgPoolSize++; return; } } @@ -339,10 +311,10 @@ void MessageManage::Recycle(InternalMessage *m) void MessageManage::ReleasePool() { std::unique_lock lock(mPoolMutex); - InternalMessage *current = pSPool; + InternalMessage *current = pMsgPool; InternalMessage *next = nullptr; while (current != nullptr) { - next = current->GetNext(); + next = current->GetNextMsg(); delete current; current = next; } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.h b/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.h index 538eff8c186f0b2d91084823f03e64a620d1849b..4fcc7724396b25db3146c967f2d763a8e3dcf1e2 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/internal_message.h @@ -100,14 +100,14 @@ public: * * @return int */ - int GetArg1() const; + int GetParam1() const; /** * @Description : Obtains the second parameter in the message body. * * @return int */ - int GetArg2() const; + int GetParam2() const; /** * @Description : Obtains the message object. @@ -151,33 +151,19 @@ public: */ void CopyMessageBody(const MessageBody &origBody); - /** - * @Description : Get reply. - * - * @return InternalMessage* - */ - InternalMessage *GetReplyTo() const; - - /** - * @Description : Get sending uid. - * - * @return int - */ - int GetSendingUid() const; - /** * @Description : Get next message. * * @return InternalMessage* */ - InternalMessage *GetNext() const; + InternalMessage *GetNextMsg() const; /** * @Description : Obtains time. * - * @return long + * @return int64_t */ - long GetWhen() const; + int64_t GetHandleTime() const; /** * @Description : Set message name. @@ -189,16 +175,16 @@ public: /** * @Description : Set the first parameter in the message body. * - * @param arg1 - The first parameter.[in] + * @param param1 - The first parameter.[in] */ - void SetArg1(int arg1); + void SetParam1(int param1); /** * @Description : Set the second parameter in the message body. * - * @param arg2 - The second parameter.[in] + * @param param2 - The second parameter.[in] */ - void SetArg2(int arg2); + void SetParam2(int param2); /** * @Description : Release Message Object. @@ -226,54 +212,36 @@ public: */ void ClearMessageBody(); - /** - * @Description : Set reply message pointer. - * - * @param replyTo - reply meassage pointer.[in] - */ - void SetReplyTo(InternalMessage *replyTo); - - /** - * @Description : Sets the UID to be sent. - * - * @param sendingUid - UID to be sent.[in] - */ - void SetSendingUid(int sendingUid); - /** * @Description : Sets next message. * * @param next - The next message.[in] */ - void SetNext(InternalMessage *next); + void SetNextMsg(InternalMessage *nextMsg); /** * @Description : Set the time. * - * @param when - Time.[in] + * @param time - Time.[in] */ - void SetWhen(long when); + void SetHandleTime(int64_t time); /* Message Name */ int mMsgName; /* Parameter 1 */ - int mArg1; + int mParam1; /* Parameter 2 */ - int mArg2; + int mParam2; /* Message body, which can be empty and can be directly copied. */ char *pMessageObj; /* Message bodies that cannot be directly copied */ MessageBody mMessageBody; /* Message body length */ int mObjSize; - /* Replying to a Message */ - InternalMessage *pReplyTo; - /* Sender UID */ - int mSendingUid; /* Next message in the resource pool or message queue */ - InternalMessage *pNext; + InternalMessage *pNextMsg; /* Message execution time */ - long mWhen; + int64_t mHandleTime; }; class MessageManage { public: @@ -289,7 +257,7 @@ public: * * @return InternalMessage* */ - InternalMessage *Obtain(); + InternalMessage *CreateMessage(); /** * @Description : Obtain original messages. @@ -297,7 +265,7 @@ public: * @param orig - Original messages.[in] * @return InternalMessage* */ - InternalMessage *Obtain(const InternalMessage *orig); + InternalMessage *CreateMessage(const InternalMessage *orig); /** * @Description : Obtains the message name. @@ -305,24 +273,24 @@ public: * @param messageName - Message name.[in] * @return InternalMessage* */ - InternalMessage *Obtain(int messageName); + InternalMessage *CreateMessage(int messageName); /** * @Description : Obtaining Message Information. * * @param messageName - Message name.[in] - * @param arg1 - arg1.[in] - * @param arg2 - arg2.[in] + * @param param1 - param1.[in] + * @param param2 - param2.[in] * @return InternalMessage* */ - InternalMessage *Obtain(int messageName, int arg1, int arg2); + InternalMessage *CreateMessage(int messageName, int param1, int param2); /** * @Description :Recycle message. * * @param m - message.[in] */ - void Recycle(InternalMessage *m); + void ReclaimMsg(InternalMessage *m); /** * @Description : Release pool. @@ -345,11 +313,11 @@ public: private: /* Maximum number of messages in the message resource pool */ - const int MAX_POOL_SIZE; + const int MAX_MSG_NUM_IN_POOL = 50; /* Message resource pool */ - InternalMessage *pSPool; + InternalMessage *pMsgPool; /* Number of messages in the message resource pool */ - int pSPoolSize; + int mMsgPoolSize; /* Mutex for operating the message resource pool */ std::mutex mPoolMutex; static std::unique_ptr msgManage; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.cpp b/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.cpp index eddbabea9f875a41a7157a7ed6ab2a259ca0c573..e6376dff9198218b3ab6b6ba6d36e25a2e7e3b94 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.cpp @@ -33,7 +33,7 @@ MessageQueue::~MessageQueue() InternalMessage *current = pMessageQueue; InternalMessage *next = nullptr; while (current != nullptr) { - next = current->GetNext(); + next = current->GetNextMsg(); delete current; current = next; } @@ -41,7 +41,7 @@ MessageQueue::~MessageQueue() return; } -bool MessageQueue::AddMessageToQueue(InternalMessage *message, long when) +bool MessageQueue::AddMessageToQueue(InternalMessage *message, int64_t handleTime) { if (message == nullptr) { LOGE("message is null.\n"); @@ -49,12 +49,12 @@ bool MessageQueue::AddMessageToQueue(InternalMessage *message, long when) } if (mNeedQuit) { - MessageManage::GetInstance().Recycle(message); + MessageManage::GetInstance().ReclaimMsg(message); LOGE("Already quit the message queue.\n"); return false; } - message->SetWhen(when); + message->SetHandleTime(handleTime); bool needWake = false; /* * If the queue is empty, the current message needs to be executed @@ -65,8 +65,8 @@ bool MessageQueue::AddMessageToQueue(InternalMessage *message, long when) { std::unique_lock lck(mMtxQueue); InternalMessage *pTop = pMessageQueue; - if (pTop == nullptr || when == 0 || when < pTop->GetWhen()) { - message->SetNext(pTop); + if (pTop == nullptr || handleTime == 0 || handleTime < pTop->GetHandleTime()) { + message->SetNextMsg(pTop); pMessageQueue = message; needWake = mIsBlocked; /* Inserts messages in the middle of the queue based on the execution time. */ @@ -75,10 +75,10 @@ bool MessageQueue::AddMessageToQueue(InternalMessage *message, long when) InternalMessage *pCurrent = pTop; while (pCurrent != nullptr) { pPrev = pCurrent; - pCurrent = pCurrent->GetNext(); - if (pCurrent == nullptr || when < pCurrent->GetWhen()) { - message->SetNext(pCurrent); - pPrev->SetNext(message); + pCurrent = pCurrent->GetNextMsg(); + if (pCurrent == nullptr || handleTime < pCurrent->GetHandleTime()) { + message->SetNextMsg(pCurrent); + pPrev->SetNextMsg(message); break; } } @@ -106,18 +106,18 @@ bool MessageQueue::DeleteMessageFromQueue(int messageName) InternalMessage *pCurrent = pTop; while (pCurrent != nullptr) { InternalMessage *pPrev = pCurrent; - pCurrent = pCurrent->GetNext(); + pCurrent = pCurrent->GetNextMsg(); if ((pCurrent != nullptr) && (pCurrent->GetMessageName() == messageName)) { - InternalMessage *pNext = pCurrent->GetNext(); - pPrev->SetNext(pNext); - MessageManage::GetInstance().Recycle(pCurrent); - pCurrent = pNext; + InternalMessage *pNextMsg = pCurrent->GetNextMsg(); + pPrev->SetNextMsg(pNextMsg); + MessageManage::GetInstance().ReclaimMsg(pCurrent); + pCurrent = pNextMsg; } } if (pTop->GetMessageName() == messageName) { - pMessageQueue = pTop->GetNext(); - MessageManage::GetInstance().Recycle(pTop); + pMessageQueue = pTop->GetNextMsg(); + MessageManage::GetInstance().ReclaimMsg(pTop); } return true; @@ -135,21 +135,21 @@ InternalMessage *MessageQueue::GetNextMessage() LOGE("gettimeofday failed.\n"); return nullptr; } - long nowTime = curTime.tv_sec * TIME_USEC_1000 + curTime.tv_usec / TIME_USEC_1000; + int64_t nowTime = static_cast(curTime.tv_sec) * TIME_USEC_1000 + curTime.tv_usec / TIME_USEC_1000; { std::unique_lock lck(mMtxQueue); InternalMessage *curMsg = pMessageQueue; if (curMsg != nullptr) { - if (nowTime < curMsg->GetWhen()) { + if (nowTime < curMsg->GetHandleTime()) { /* The execution time of the first message is not reached. The remaining time is blocked here. */ - nextBlockTime = curMsg->GetWhen() - nowTime; + nextBlockTime = curMsg->GetHandleTime() - nowTime; } else { /* Return the first message. */ mIsBlocked = false; - pMessageQueue = curMsg->GetNext(); - curMsg->SetNext(nullptr); + pMessageQueue = curMsg->GetNextMsg(); + curMsg->SetNextMsg(nullptr); return curMsg; } } else { diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.h b/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.h index 29334fb5581b6e6d5e22c35fee44a2fa350624d9..a31371f4b685ea16b6ac10bc5822fba793410266 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/message_queue.h @@ -43,10 +43,10 @@ public: * @Description : Inserting Messages into Queues. * * @param message - Message to be inserted.[in] - * @param when - Message execution time.[in] + * @param handleTime - Message execution time.[in] * @return true : success, false : failed. */ - bool AddMessageToQueue(InternalMessage *message, long when); + bool AddMessageToQueue(InternalMessage *message, int64_t handleTime); /** * @Description : Delete messages from the queue. diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/state.cpp b/services/wifi_standard/wifi_framework/wifi_manage/common/state.cpp index a95df165d94630db6c1e82fde474850dfa3a39d6..9346721e9c0fcdc171770c6c6fd41b8930f8d96e 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/state.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/state.cpp @@ -20,15 +20,15 @@ namespace OHOS { namespace Wifi { -State::State(const std::string &name) : mName(name) +State::State(const std::string &name) : mStateName(name) {} State::~State() {} -std::string State::GetName() +std::string State::GetStateName() { - return mName; + return mStateName; } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/state.h b/services/wifi_standard/wifi_framework/wifi_manage/common/state.h index 66fb7a7674f6348a4231cfb841b74185b3f6f699..9ab806aec22113aae49d7b8107336bcb24453413 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/state.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/state.h @@ -37,18 +37,18 @@ public: virtual ~State(); public: - virtual void Enter() = 0; - virtual void Exit() = 0; - virtual bool ProcessMessage(InternalMessage *msg) = 0; + virtual void GoInState() = 0; + virtual void GoOutState() = 0; + virtual bool ExecuteStateMsg(InternalMessage *msg) = 0; /** * @Description : Obtains state name. * * @return std::string */ - std::string GetName(); + std::string GetStateName(); - std::string mName; + std::string mStateName; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.cpp b/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.cpp index da48d7b902d9660bc26e083bc0b215af6e3a9e9a..541a1371569d7438f2e078ea3dfa831226aeacc0 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.cpp @@ -20,52 +20,51 @@ namespace OHOS { namespace Wifi { -static const int SM_QUIT_CMD = -1; static const int SM_INIT_CMD = -2; -StateMachine::StateMachine(const std::string &name) : pSmHandler(nullptr), mStateName(name) +StateMachine::StateMachine(const std::string &name) : pStateMachineHandler(nullptr), mStateName(name) {} StateMachine::~StateMachine() { LOGD("StateMachine::~StateMachine"); - if (pSmHandler != nullptr) { - delete pSmHandler; + if (pStateMachineHandler != nullptr) { + delete pStateMachineHandler; } } bool StateMachine::InitialStateMachine() { - pSmHandler = new (std::nothrow) SmHandler(this); - if (pSmHandler == nullptr) { - LOGE("pSmHandler alloc failed.\n"); + pStateMachineHandler = new (std::nothrow) StateMachineHandler(this); + if (pStateMachineHandler == nullptr) { + LOGE("pStateMachineHandler alloc failed.\n"); return false; } - if (!pSmHandler->InitialSmHandler()) { - LOGE("InitialSmHandler failed.\n"); + if (!pStateMachineHandler->InitialSmHandler()) { + LOGE("InitialStateMachineHandler failed.\n"); return false; } return true; } -void StateMachine::Start() +void StateMachine::StartStateMachine() { - if (pSmHandler == nullptr) { - LOGE("Start StateMachine failed, smHandler is nullptr!"); + if (pStateMachineHandler == nullptr) { + LOGE("Start StateMachine failed, pStateMachineHandler is nullptr!"); return; } - pSmHandler->CompleteConstruction(); + pStateMachineHandler->BuildTreeComplete(); return; } -void StateMachine::SetHandler(SmHandler *smHandler) +void StateMachine::SetHandler(StateMachineHandler *handler) { - pSmHandler = smHandler; + pStateMachineHandler = handler; } -void StateMachine::UnhandledMessage(InternalMessage *msg) +void StateMachine::NotExecutedMessage(InternalMessage *msg) { if (msg == nullptr) { return; @@ -73,78 +72,79 @@ void StateMachine::UnhandledMessage(InternalMessage *msg) LOGD("msg not handled msg:%{public}d", msg->GetMessageName()); } -void StateMachine::AddState(State *state, State *parent) +void StateMachine::StatePlus(State *state, State *upper) { - pSmHandler->AddState(state, parent); + pStateMachineHandler->StatePlus(state, upper); } -void StateMachine::RemoveState(State *state) +void StateMachine::StateDelete(State *state) { - pSmHandler->RemoveState(state); + pStateMachineHandler->StateDelete(state); } -void StateMachine::SetInitialState(State *initialState) +void StateMachine::SetFirstState(State *firstState) { - pSmHandler->SetInitialState(initialState); + pStateMachineHandler->SetFirstState(firstState); } -void StateMachine::TransitionTo(State *destState) + +void StateMachine::SwitchState(State *targetState) { - pSmHandler->TransitionTo(destState); + pStateMachineHandler->SwitchState(targetState); } -void StateMachine::DeferMessage(InternalMessage *msg) +void StateMachine::DelayMessage(InternalMessage *msg) { - pSmHandler->DeferMessage(msg); + pStateMachineHandler->DelayMessage(msg); } void StateMachine::StopHandlerThread() { - pSmHandler->StopHandlerThread(); + pStateMachineHandler->StopHandlerThread(); } -InternalMessage *StateMachine::ObtainMessage() +InternalMessage *StateMachine::CreateMessage() { - return MessageManage::GetInstance().Obtain(); + return MessageManage::GetInstance().CreateMessage(); } -InternalMessage *StateMachine::ObtainMessage(InternalMessage *orig) +InternalMessage *StateMachine::CreateMessage(InternalMessage *orig) { if (orig == nullptr) { return nullptr; } - return MessageManage::GetInstance().Obtain(orig); + return MessageManage::GetInstance().CreateMessage(orig); } -InternalMessage *StateMachine::ObtainMessage(int what) +InternalMessage *StateMachine::CreateMessage(int msgName) { - return MessageManage::GetInstance().Obtain(what); + return MessageManage::GetInstance().CreateMessage(msgName); } -InternalMessage *StateMachine::ObtainMessage(int what, int arg1) +InternalMessage *StateMachine::CreateMessage(int msgName, int param1) { - return MessageManage::GetInstance().Obtain(what, arg1, 0); + return MessageManage::GetInstance().CreateMessage(msgName, param1, 0); } -InternalMessage *StateMachine::ObtainMessage(int what, int arg1, int arg2) +InternalMessage *StateMachine::CreateMessage(int msgName, int param1, int param2) { - return MessageManage::GetInstance().Obtain(what, arg1, arg2); + return MessageManage::GetInstance().CreateMessage(msgName, param1, param2); } -void StateMachine::SendMessage(int what) +void StateMachine::SendMessage(int msgName) { - pSmHandler->SendMessage(ObtainMessage(what)); + pStateMachineHandler->SendMessage(CreateMessage(msgName)); return; } -void StateMachine::SendMessage(int what, int arg1) +void StateMachine::SendMessage(int msgName, int param1) { - pSmHandler->SendMessage(ObtainMessage(what, arg1)); + pStateMachineHandler->SendMessage(CreateMessage(msgName, param1)); return; } -void StateMachine::SendMessage(int what, int arg1, int arg2) +void StateMachine::SendMessage(int msgName, int param1, int param2) { - pSmHandler->SendMessage(ObtainMessage(what, arg1, arg2)); + pStateMachineHandler->SendMessage(CreateMessage(msgName, param1, param2)); return; } @@ -153,129 +153,106 @@ void StateMachine::SendMessage(InternalMessage *msg) if (msg == nullptr) { return; } - pSmHandler->SendMessage(msg); + pStateMachineHandler->SendMessage(msg); return; } -void StateMachine::SendMessageDelayed(int what, long delayMillis) +void StateMachine::MessageExecutedLater(int msgName, int64_t delayTimeMs) { - pSmHandler->SendMessageDelayed(ObtainMessage(what), delayMillis); + pStateMachineHandler->MessageExecutedLater(CreateMessage(msgName), delayTimeMs); return; } -void StateMachine::SendMessageDelayed(int what, int arg1, long delayMillis) +void StateMachine::MessageExecutedLater(int msgName, int param1, int64_t delayTimeMs) { - pSmHandler->SendMessageDelayed(ObtainMessage(what, arg1), delayMillis); + pStateMachineHandler->MessageExecutedLater(CreateMessage(msgName, param1), delayTimeMs); return; } -void StateMachine::SendMessageDelayed(int what, int arg1, int arg2, long delayMillis) +void StateMachine::MessageExecutedLater(int msgName, int param1, int param2, int64_t delayTimeMs) { - pSmHandler->SendMessageDelayed(ObtainMessage(what, arg1, arg2), delayMillis); + pStateMachineHandler->MessageExecutedLater(CreateMessage(msgName, param1, param2), delayTimeMs); return; } -void StateMachine::SendMessageDelayed(InternalMessage *msg, long delayMillis) +void StateMachine::MessageExecutedLater(InternalMessage *msg, int64_t delayTimeMs) { - pSmHandler->SendMessageDelayed(msg, delayMillis); + pStateMachineHandler->MessageExecutedLater(msg, delayTimeMs); return; } -void StateMachine::StartTimer(int timerName, long interval) +void StateMachine::StartTimer(int timerName, int64_t interval) { - LOGD("Enter StateMachine::StartTimer, timerName is %{public}d, interval is %ld.", timerName, interval); - SendMessageDelayed(timerName, interval); + LOGD("Enter StateMachine::StartTimer, timerName is %{public}d, interval is %lld.", timerName, interval); + MessageExecutedLater(timerName, interval); return; } void StateMachine::StopTimer(int timerName) { LOGD("Enter StateMachine::StopTimer, timerName is %{public}d.", timerName); - pSmHandler->DeleteMessageFromQueue(timerName); + pStateMachineHandler->DeleteMessageFromQueue(timerName); return; } -SmHandler::SmHandler(StateMachine *pStateMgr) -{ - mStateInfo.clear(); - mStateList.clear(); - mStateListTopIndex = -1; - mSequenceStateList.clear(); - mSequenceStateListCount = 0; - mDeferredMessages.clear(); - pSM = pStateMgr; - pInitialState = nullptr; - pDestState = nullptr; - mHasQuit = false; - mIsConstructionCompleted = false; - mTransitionInProgress = false; +StateMachineHandler::StateMachineHandler(StateMachine *pStateMgr) +{ + mStateInfoMap.clear(); + mStateVector.clear(); + mStateVectorTopIndex = -1; + mSequenceStateVector.clear(); + mSequenceStateVectorCount = 0; + mDelayedMessages.clear(); + pStateMachine = pStateMgr; + pFirstState = nullptr; + pTargetState = nullptr; + mQuitFlag = false; + mBuildCompleteFlag = false; + mSwitchingStateFlag = false; pCurrentMsg = nullptr; - pQuittingState = nullptr; - pHaltingState = nullptr; } -SmHandler::~SmHandler() +StateMachineHandler::~StateMachineHandler() { - LOGD("SmHandler::~SmHandler"); - if (pQuittingState != nullptr) { - delete pQuittingState; - } - - if (pHaltingState != nullptr) { - delete pHaltingState; - } - + LOGD("StateMachineHandler::~StateMachineHandler"); StopHandlerThread(); - ReleaseDeferredMessages(); - CleanupAfterQuitting(); - + ReleaseDelayedMessages(); + ClearWhenQuit(); return; } -bool SmHandler::InitialSmHandler() +bool StateMachineHandler::InitialSmHandler() { if (!InitialHandler()) { return false; } - - pQuittingState = new (std::nothrow) QuittingState(); - if (pQuittingState == nullptr) { - LOGE("Failed to init quitting state!"); - return false; - } - - pHaltingState = new (std::nothrow) HaltingState(); - if (pHaltingState == nullptr) { - LOGE("Failed to init halting state!"); - return false; - } - return true; } -StateInfo *SmHandler::AddState(State *state, State *parent) +StateInfo *StateMachineHandler::StatePlus(State *state, State *upper) { - LOGD("SmHandler::AddState function."); + LOGD("StateMachineHandler::StatePlus function."); - StateInfo *parentStateInfo = nullptr; - StateInfoMap::iterator it = mStateInfo.begin(); - if (parent != nullptr) { - it = mStateInfo.find(parent->GetName()); - if (it != mStateInfo.end()) { - parentStateInfo = it->second; + StateInfo *upperStateInfo = nullptr; + StateInfoMap::iterator it = mStateInfoMap.begin(); + if (upper != nullptr) { + it = mStateInfoMap.find(upper->GetStateName()); + if (it != mStateInfoMap.end()) { + upperStateInfo = it->second; } - if (parentStateInfo == nullptr) { - LOGD("parentStateInfo is null, add parent first. parent->GetName():%{public}s", parent->GetName().c_str()); - /* Recursively add our parent as it's not been added yet. */ - AddState(parent, nullptr); + if (upperStateInfo == nullptr) { + LOGD("upperStateInfo is null, add upper first. upper->GetStateName():%{public}s", + upper->GetStateName().c_str()); + /* Recursively add our upper as it's not been added yet. */ + StatePlus(upper, nullptr); } else { - LOGD("parentStateInfo is not null, go on."); + LOGD("upperStateInfo is not null, go on."); } } StateInfo *stateInfo = nullptr; - it = mStateInfo.find(state->GetName()); - if (it != mStateInfo.end()) { + it = mStateInfoMap.find(state->GetStateName()); + if (it != mStateInfoMap.end()) { stateInfo = it->second; } if (stateInfo == nullptr) { @@ -284,16 +261,16 @@ StateInfo *SmHandler::AddState(State *state, State *parent) LOGE("failed to new StateInfo!"); return nullptr; } - mStateInfo.insert(StateInfoMap::value_type(state->GetName(), stateInfo)); + mStateInfoMap.insert(StateInfoMap::value_type(state->GetStateName(), stateInfo)); } /* Validate that we aren't adding the same state in two different hierarchies. */ - if (stateInfo->parentStateInfo != nullptr && stateInfo->parentStateInfo != parentStateInfo) { + if (stateInfo->upperStateInfo != nullptr && stateInfo->upperStateInfo != upperStateInfo) { LOGE("The same state cannot be added to two different hierarchies!"); } stateInfo->state = state; - stateInfo->parentStateInfo = parentStateInfo; + stateInfo->upperStateInfo = upperStateInfo; stateInfo->active = false; LOGD("successfully added a new state!"); @@ -301,49 +278,49 @@ StateInfo *SmHandler::AddState(State *state, State *parent) return stateInfo; } -void SmHandler::RemoveState(State *state) +void StateMachineHandler::StateDelete(State *state) { - StateInfoMap::iterator it = mStateInfo.find(state->GetName()); + StateInfoMap::iterator it = mStateInfoMap.find(state->GetStateName()); StateInfo *stateInfo = nullptr; - if (it != mStateInfo.end()) { + if (it != mStateInfoMap.end()) { stateInfo = it->second; } if (stateInfo == nullptr || stateInfo->active) { return; } - it = mStateInfo.begin(); - while (it != mStateInfo.end()) { - if (it->second->parentStateInfo == stateInfo) { + it = mStateInfoMap.begin(); + while (it != mStateInfoMap.end()) { + if (it->second->upperStateInfo == stateInfo) { return; } ++it; } - it = mStateInfo.find(state->GetName()); - if (it != mStateInfo.end()) { + it = mStateInfoMap.find(state->GetStateName()); + if (it != mStateInfoMap.end()) { delete it->second; it->second = nullptr; - mStateInfo.erase(it); + mStateInfoMap.erase(it); } } -void SmHandler::SetInitialState(State *initialState) +void StateMachineHandler::SetFirstState(State *firstState) { - pInitialState = initialState; + pFirstState = firstState; } -void SmHandler::CompleteConstruction() +void StateMachineHandler::BuildTreeComplete() { /* Determines the maximum depth of the state hierarchy. */ int maxDepth = 0; - StateInfoMap::iterator it = mStateInfo.begin(); - while (it != mStateInfo.end()) { + StateInfoMap::iterator it = mStateInfoMap.begin(); + while (it != mStateInfoMap.end()) { int depth = 0; StateInfo *tempStateInfo = it->second; while (tempStateInfo != nullptr) { depth++; - tempStateInfo = tempStateInfo->parentStateInfo; + tempStateInfo = tempStateInfo->upperStateInfo; } if (maxDepth < depth) { @@ -353,49 +330,45 @@ void SmHandler::CompleteConstruction() ++it; } - LOGD("SmHandler::CompleteConstruction, maxDepth:%{public}d", maxDepth); - mStateList.reserve(maxDepth); - mSequenceStateList.reserve(maxDepth); - - SetupInitialStateVector(); - - SendMessageAtTime(pSM->ObtainMessage(SM_INIT_CMD), 0); - + LOGD("StateMachineHandler::BuildTreeComplete, maxDepth:%{public}d", maxDepth); + mStateVector.reserve(maxDepth); + mSequenceStateVector.reserve(maxDepth); + BuildStateInitVector(); + MessageExecutedAtTime(pStateMachine->CreateMessage(SM_INIT_CMD), 0); return; } -void SmHandler::SetupInitialStateVector() +void StateMachineHandler::BuildStateInitVector() { - LOGD("SmHandler::SetupInitialStateVector"); + LOGD("StateMachineHandler::BuildStateInitVector"); - if (pInitialState == nullptr) { - LOGE("SmHandler::SetupInitialStateVector please set initial state first!"); + if (pFirstState == nullptr) { + LOGE("StateMachineHandler::BuildStateInitVector please set initial state first!"); return; } - StateInfoMap::iterator it = mStateInfo.find(pInitialState->GetName()); + StateInfoMap::iterator it = mStateInfoMap.find(pFirstState->GetStateName()); StateInfo *startStateInfo = nullptr; - if (it != mStateInfo.end()) { + if (it != mStateInfoMap.end()) { startStateInfo = it->second; } - for (mSequenceStateListCount = 0; startStateInfo != nullptr; mSequenceStateListCount++) { - mSequenceStateList[mSequenceStateListCount] = startStateInfo; - startStateInfo = startStateInfo->parentStateInfo; + for (mSequenceStateVectorCount = 0; startStateInfo != nullptr; mSequenceStateVectorCount++) { + mSequenceStateVector[mSequenceStateVectorCount] = startStateInfo; + startStateInfo = startStateInfo->upperStateInfo; } - /* Clearing the stateList. */ - mStateListTopIndex = -1; - - MoveSequenceStateListToStateList(); + /* Clearing the StateVector. */ + mStateVectorTopIndex = -1; + MoveSequenceToStateVector(); } -StateInfo *SmHandler::SetupTempStateStackWithStatesToEnter(State *destState) +StateInfo *StateMachineHandler::BuildSequenceStateVector(State *targetState) { - mSequenceStateListCount = 0; - StateInfoMap::iterator it = mStateInfo.find(destState->GetName()); + mSequenceStateVectorCount = 0; + StateInfoMap::iterator it = mStateInfoMap.find(targetState->GetStateName()); StateInfo *curStateInfo = nullptr; - if (it != mStateInfo.end()) { + if (it != mStateInfoMap.end()) { curStateInfo = it->second; } @@ -404,246 +377,227 @@ StateInfo *SmHandler::SetupTempStateStackWithStatesToEnter(State *destState) } do { - mSequenceStateList[mSequenceStateListCount++] = curStateInfo; - curStateInfo = curStateInfo->parentStateInfo; + mSequenceStateVector[mSequenceStateVectorCount++] = curStateInfo; + curStateInfo = curStateInfo->upperStateInfo; } while ((curStateInfo != nullptr) && (!curStateInfo->active)); return curStateInfo; } -void SmHandler::MoveDeferredMessageAtFrontOfQueue() +void StateMachineHandler::PlaceDelayedMsgQueueTop() { - LOGD("Enter SmHandler::MoveDeferredMessageAtFrontOfQueue."); + LOGD("Enter StateMachineHandler::PlaceDelayedMsgQueueTop."); - for (int i = mDeferredMessages.size() - 1; i >= 0; i--) { - InternalMessage *curMsg = mDeferredMessages[i]; + for (int i = mDelayedMessages.size() - 1; i >= 0; i--) { + InternalMessage *curMsg = mDelayedMessages[i]; if (curMsg == nullptr) { - LOGE("SmHandler::MoveDeferredMessageAtFrontOfQueue: curMsg is null."); + LOGE("StateMachineHandler::PlaceDelayedMsgQueueTop: curMsg is null."); continue; } - SendMessageAtFrontOfQueue(curMsg); + PlaceMessageTopOfQueue(curMsg); } - mDeferredMessages.clear(); + mDelayedMessages.clear(); return; } -void SmHandler::ReleaseDeferredMessages() +void StateMachineHandler::ReleaseDelayedMessages() { - for (int i = mDeferredMessages.size() - 1; i >= 0; i--) { - InternalMessage *curMsg = mDeferredMessages[i]; + for (int i = mDelayedMessages.size() - 1; i >= 0; i--) { + InternalMessage *curMsg = mDelayedMessages[i]; if (curMsg != nullptr) { delete curMsg; } } - mDeferredMessages.clear(); + mDelayedMessages.clear(); return; } -int SmHandler::MoveSequenceStateListToStateList() +int StateMachineHandler::MoveSequenceToStateVector() { - LOGD("SmHandler::MoveSequenceStateListToStateList mSequenceStateListCount:%{public}d", mSequenceStateListCount); + LOGD("StateMachineHandler::MoveSequenceToStateVector mSequenceStateVectorCount:%{public}d", + mSequenceStateVectorCount); - int newIndex = mStateListTopIndex + 1; - int i = mSequenceStateListCount - 1; + int newIndex = mStateVectorTopIndex + 1; + int i = mSequenceStateVectorCount - 1; int j = newIndex; while (i >= 0) { - mStateList[j] = mSequenceStateList[i]; + mStateVector[j] = mSequenceStateVector[i]; j += 1; i -= 1; } - mStateListTopIndex = j - 1; - + mStateVectorTopIndex = j - 1; return newIndex; } -void SmHandler::TransitionTo(State *destState) +void StateMachineHandler::SwitchState(State *targetState) { - pDestState = static_cast(destState); + pTargetState = static_cast(targetState); } -void SmHandler::CleanupAfterQuitting() +void StateMachineHandler::ClearWhenQuit() { - pSM->SetHandler(nullptr); - pSM = nullptr; + pStateMachine->SetHandler(nullptr); + pStateMachine = nullptr; pCurrentMsg = nullptr; - mStateList.clear(); - mSequenceStateList.clear(); - mDeferredMessages.clear(); - pInitialState = nullptr; - pDestState = nullptr; - mHasQuit = true; - - StateInfoMap::iterator it = mStateInfo.begin(); - while (it != mStateInfo.end()) { + mStateVector.clear(); + mSequenceStateVector.clear(); + mDelayedMessages.clear(); + pFirstState = nullptr; + pTargetState = nullptr; + mQuitFlag = true; + + StateInfoMap::iterator it = mStateInfoMap.begin(); + while (it != mStateInfoMap.end()) { delete it->second; it->second = nullptr; - it = mStateInfo.erase(it); + it = mStateInfoMap.erase(it); } - mStateInfo.clear(); + mStateInfoMap.clear(); } -void SmHandler::PerformTransitions(State *msgProcessedState, InternalMessage *msg) +void StateMachineHandler::PerformSwitchState(State *msgProcessedState, InternalMessage *msg) { if (msgProcessedState == nullptr || msg == nullptr) { LOGE("poniter is null."); } - State *destState = pDestState; - - if (destState != nullptr) { - LOGD("SmHandler::PerformTransitions destState name is: %{public}s", destState->GetName().c_str()); + State *targetState = pTargetState; + if (targetState != nullptr) { + LOGD("StateMachineHandler::PerformSwitchState targetState name is: %{public}s", + targetState->GetStateName().c_str()); while (true) { - StateInfo *commonStateInfo = SetupTempStateStackWithStatesToEnter(destState); - mTransitionInProgress = true; - InvokeExitMethods(commonStateInfo); + StateInfo *commonStateInfo = BuildSequenceStateVector(targetState); + mSwitchingStateFlag = true; + CallTreeStateExits(commonStateInfo); - int stateListEnteringIndex = MoveSequenceStateListToStateList(); - InvokeEnterMethods(stateListEnteringIndex); + int stateListEnteringIndex = MoveSequenceToStateVector(); + CallTreeStateEnters(stateListEnteringIndex); - MoveDeferredMessageAtFrontOfQueue(); + PlaceDelayedMsgQueueTop(); - if (destState != pDestState) { - destState = pDestState; + if (targetState != pTargetState) { + targetState = pTargetState; } else { break; } } - pDestState = nullptr; - } - - if (destState != nullptr) { - if (destState->GetName() == pQuittingState->GetName()) { - pSM->OnQuitting(); - CleanupAfterQuitting(); - } else if (destState->GetName() == pHaltingState->GetName()) { - pSM->OnHalting(); - } + pTargetState = nullptr; } return; } -void SmHandler::HandleMessage(InternalMessage *msg) +void StateMachineHandler::ExecuteMessage(InternalMessage *msg) { if (msg == nullptr) { return; } - if (!mHasQuit) { - if (pSM != nullptr && msg->GetMessageName() != SM_INIT_CMD && msg->GetMessageName() != SM_QUIT_CMD) { + if (!mQuitFlag) { + if (pStateMachine != nullptr && msg->GetMessageName() != SM_INIT_CMD) { } pCurrentMsg = msg; State *msgProcessedState = nullptr; - if (mIsConstructionCompleted) { - LOGD("SmHandler::HandleMessage ProcessMsg!"); - msgProcessedState = ProcessMsg(msg); - } else if (!mIsConstructionCompleted && msg->GetMessageName() == SM_INIT_CMD) { - LOGD("SmHandler::HandleMessage msg: SM_INIT_CMD"); - mIsConstructionCompleted = true; - InvokeEnterMethods(0); + if (mBuildCompleteFlag) { + LOGD("StateMachineHandler::ExecuteMessage ExecuteTreeStateMsg!"); + msgProcessedState = ExecuteTreeStateMsg(msg); + } else if (!mBuildCompleteFlag && msg->GetMessageName() == SM_INIT_CMD) { + LOGD("StateMachineHandler::ExecuteMessage msg: SM_INIT_CMD"); + mBuildCompleteFlag = true; + CallTreeStateEnters(0); } else { LOGE("The start method not called!"); } - if (pSM != nullptr) { - PerformTransitions(msgProcessedState, msg); + if (pStateMachine != nullptr) { + PerformSwitchState(msgProcessedState, msg); } else { LOGE("poniter is null."); } - if (pSM != nullptr && msg->GetMessageName() != SM_INIT_CMD && msg->GetMessageName() != SM_QUIT_CMD) { + if (pStateMachine != nullptr && msg->GetMessageName() != SM_INIT_CMD) { } } return; } -void SmHandler::DeferMessage(InternalMessage *msg) +void StateMachineHandler::DelayMessage(InternalMessage *msg) { + LOGD("Enter StateMachineHandler::DelayMessage."); if (msg == nullptr) { return; } - LOGD("Enter SmHandler::DeferMessage."); - InternalMessage *newMsg = pSM->ObtainMessage(msg); + InternalMessage *newMsg = pStateMachine->CreateMessage(msg); if (newMsg == nullptr) { - LOGE("SmHandler::DeferMessage: newMsg is null."); + LOGE("StateMachineHandler::DelayMessage: newMsg is null."); return; } - - mDeferredMessages.push_back(newMsg); + mDelayedMessages.push_back(newMsg); return; } -State *SmHandler::ProcessMsg(InternalMessage *msg) +State *StateMachineHandler::ExecuteTreeStateMsg(InternalMessage *msg) { + LOGD("StateMachineHandler::ExecuteTreeStateMsg mStateVectorTopIndex:%{public}d", mStateVectorTopIndex); if (msg == nullptr) { return nullptr; } - LOGD("SmHandler::ProcessMsg mStateListTopIndex:%{public}d", mStateListTopIndex); - StateInfo *curStateInfo = mStateList[mStateListTopIndex]; + + StateInfo *curStateInfo = mStateVector[mStateVectorTopIndex]; if (curStateInfo == nullptr) { LOGE("StateInfo is null."); return nullptr; } - if (IsQuit(msg)) { - TransitionTo(static_cast(pQuittingState)); - } else { - while (curStateInfo->state && (!curStateInfo->state->ProcessMessage(msg))) { - curStateInfo = curStateInfo->parentStateInfo; + while (curStateInfo->state && (!curStateInfo->state->ExecuteStateMsg(msg))) { + curStateInfo = curStateInfo->upperStateInfo; - if (curStateInfo == nullptr) { - pSM->UnhandledMessage(msg); - break; - } + if (curStateInfo == nullptr) { + pStateMachine->NotExecutedMessage(msg); + break; } } return (curStateInfo != nullptr) ? curStateInfo->state : nullptr; } -void SmHandler::InvokeExitMethods(StateInfo *commonStateInfo) +void StateMachineHandler::CallTreeStateExits(StateInfo *commonStateInfo) { - while ((mStateListTopIndex >= 0) && (mStateList[mStateListTopIndex] != commonStateInfo)) { - if (mStateList[mStateListTopIndex] != nullptr) { - State *curState = mStateList[mStateListTopIndex]->state; + while ((mStateVectorTopIndex >= 0) && (mStateVector[mStateVectorTopIndex] != commonStateInfo)) { + if (mStateVector[mStateVectorTopIndex] != nullptr) { + State *curState = mStateVector[mStateVectorTopIndex]->state; if (curState != nullptr) { - curState->Exit(); + curState->GoOutState(); } - mStateList[mStateListTopIndex]->active = false; + mStateVector[mStateVectorTopIndex]->active = false; } - mStateListTopIndex -= 1; + mStateVectorTopIndex -= 1; } } -void SmHandler::InvokeEnterMethods(int index) +void StateMachineHandler::CallTreeStateEnters(int index) { - for (int i = index; i <= mStateListTopIndex; i++) { - if (index == mStateListTopIndex) { + for (int i = index; i <= mStateVectorTopIndex; i++) { + if (index == mStateVectorTopIndex) { /* Last enter state for transition. */ - mTransitionInProgress = false; + mSwitchingStateFlag = false; } - LOGD("SmHandler::InvokeEnterMethods mStateListTopIndex:%{public}d, i: %{public}d", mStateListTopIndex, i); - if (mStateList[i] != nullptr && mStateList[i]->state != nullptr) { - mStateList[i]->state->Enter(); - mStateList[i]->active = true; + LOGD("StateMachineHandler::CallTreeStateEnters mStateVectorTopIndex:%{public}d, i: %{public}d", + mStateVectorTopIndex, + i); + if (mStateVector[i] != nullptr && mStateVector[i]->state != nullptr) { + mStateVector[i]->state->GoInState(); + mStateVector[i]->active = true; } } /* ensure flag set to false if no methods called. */ - mTransitionInProgress = false; -} - -bool SmHandler::IsQuit(InternalMessage *msg) -{ - if (msg == nullptr) { - return false; - } - return (msg->GetMessageName() == SM_QUIT_CMD); + mSwitchingStateFlag = false; } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.h b/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.h index e36181d2ffb5a144622efcfef382af418f12bcb4..00900cbadd22b7a425327090bc8fa6bf2cd94164 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/common/state_machine.h @@ -27,15 +27,15 @@ namespace OHOS { namespace Wifi { #define CMD_SET_OPERATIONAL_MODE 1 /* Message Processed */ -static const bool HANDLED = true; +static const bool EXECUTED = true; /* The message is not processed. */ -static const bool NOT_HANDLED = false; +static const bool NOT_EXECUTED = false; -class SmHandler; +class StateMachineHandler; class StateMachine { public: /** - * @Description : SmHandler Initialization Function + * @Description : StateMachine Initialization Function * * @return true :success, false : failed. */ @@ -45,23 +45,21 @@ public: * @Description : Start StateMachine. * */ - void Start(); - virtual void OnQuitting() = 0; - virtual void OnHalting() = 0; + void StartStateMachine(); /** * @Description : Set Handler. * - * @param smHandler - SmHandler instance.[in] + * @param handler - StateMachineHandler instance.[in] */ - void SetHandler(SmHandler *smHandler); + void SetHandler(StateMachineHandler *handler); /** * @Description : The Message is not handled. * * @param msg - Message object.[in] */ - void UnhandledMessage(InternalMessage *msg); + void NotExecutedMessage(InternalMessage *msg); /** * @Description Stop Handler Thread. @@ -75,7 +73,7 @@ public: * @param timerName - Timer Name.[in] * @param interval - Timer duration, in milliseconds.[in] */ - void StartTimer(int timerName, long interval); + void StartTimer(int timerName, int64_t interval); /** * @Description : Stop the timer. @@ -89,7 +87,7 @@ public: * * @return InternalMessage* : Pointer to the constructed internal message. */ - InternalMessage *ObtainMessage(); + InternalMessage *CreateMessage(); /** * @Description : Construct an information message based on @@ -98,61 +96,61 @@ public: * @param orig - Original message.[in] * @return InternalMessage* : Pointer to the constructed internal message. */ - InternalMessage *ObtainMessage(InternalMessage *orig); + InternalMessage *CreateMessage(InternalMessage *orig); /** * @Description : Construct internal messages. * - * @param what - Message Name.[in] + * @param msgName - Message Name.[in] * @return InternalMessage* : Pointer to the constructed internal message. */ - InternalMessage *ObtainMessage(int what); + InternalMessage *CreateMessage(int msgName); /** * @Description : Construct internal messages. * - * @param what - Message Name.[in] - * @param arg1 - Message parameters.[in] + * @param msgName - Message Name.[in] + * @param param1 - Message parameters.[in] * @return InternalMessage* : Pointer to the constructed internal message. */ - InternalMessage *ObtainMessage(int what, int arg1); + InternalMessage *CreateMessage(int msgName, int param1); /** * @Description : Construct internal messages. * - * @param what - Message Name.[in] - * @param arg1 - Message parameters.[in] - * @param arg2 - Message parameters.[in] + * @param msgName - Message Name.[in] + * @param param1 - Message parameters.[in] + * @param param2 - Message parameters.[in] * @return InternalMessage* : Pointer to the constructed internal message. */ - InternalMessage *ObtainMessage(int what, int arg1, int arg2); + InternalMessage *CreateMessage(int msgName, int param1, int param2); /** * @Description : Constructs internal messages and places the * messages in the message queue of the state machine. * - * @param what - Message name.[in] + * @param msgName - Message name.[in] */ - void SendMessage(int what); + void SendMessage(int msgName); /** * @Description : Constructs internal messages and places the messages * in the message queue of the state machine. * - * @param what - Message name.[in] - * @param arg1 - Message parameter.[in] + * @param msgName - Message name.[in] + * @param param1 - Message parameter.[in] */ - void SendMessage(int what, int arg1); + void SendMessage(int msgName, int param1); /** * @Description : Constructs internal messages and places the messages * in the message queue of the state machine. * - * @param what - Message name.[in] - * @param arg1 - Message parameter.[in] - * @param arg2 - Message parameter.[in] + * @param msgName - Message name.[in] + * @param param1 - Message parameter.[in] + * @param param2 - Message parameter.[in] */ - void SendMessage(int what, int arg1, int arg2); + void SendMessage(int msgName, int param1, int param2); /** * @Description : Puts messages into the message queue of the state machine. @@ -166,33 +164,33 @@ public: * message queue of the state machine. The messages are processed * after the specified delay time. * - * @param what - Message Name.[in] - * @param delayMillis - Delay time, in milliseconds.[in] + * @param msgName - Message Name.[in] + * @param delayTimeMs - Delay time, in milliseconds.[in] */ - void SendMessageDelayed(int what, long delayMillis); + void MessageExecutedLater(int msgName, int64_t delayTimeMs); /** * @Description : Constructs internal messages and places them in the * message queue of the state machine. The messages are processed * after the specified delay time. * - * @param what - Message Name.[in] - * @param arg1 - Message parameters.[in] - * @param delayMillis - Delay time, in milliseconds.[in] + * @param msgName - Message Name.[in] + * @param param1 - Message parameters.[in] + * @param delayTimeMs - Delay time, in milliseconds.[in] */ - void SendMessageDelayed(int what, int arg1, long delayMillis); + void MessageExecutedLater(int msgName, int param1, int64_t delayTimeMs); /** * @Description : Constructs internal messages and places them in the * message queue of the state machine. The messages are processed * after the specified delay time. * - * @param what - Message Name.[in] - * @param arg1 - Message parameters.[in] - * @param arg2 - Message parameters.[in] - * @param delayMillis - Delay time, in milliseconds.[in] + * @param msgName - Message Name.[in] + * @param param1 - Message parameters.[in] + * @param param2 - Message parameters.[in] + * @param delayTimeMs - Delay time, in milliseconds.[in] */ - void SendMessageDelayed(int what, int arg1, int arg2, long delayMillis); + void MessageExecutedLater(int msgName, int param1, int param2, int64_t delayTimeMs); /** * @Description : Constructs internal messages and places them in the @@ -200,9 +198,9 @@ public: * after the specified delay time. * * @param msg - Message to be sent.[in] - * @param delayMillis - Delay time, in milliseconds.[in] + * @param delayTimeMs - Delay time, in milliseconds.[in] */ - void SendMessageDelayed(InternalMessage *msg, long delayMillis); + void MessageExecutedLater(InternalMessage *msg, int64_t delayTimeMs); protected: /** @@ -222,104 +220,70 @@ protected: * @Description : Add state. * * @param state - state.[in] - * @param parent - parent state.[in] + * @param upper - upper state.[in] */ - void AddState(State *state, State *parent); + void StatePlus(State *state, State *upper); /** * @Description : Remove state. * * @param state - state.[in] */ - void RemoveState(State *state); + void StateDelete(State *state); /** * @Description : Set initial state. * - * @param initialState - Initial state.[in] + * @param firstState - Initial state.[in] */ - void SetInitialState(State *initialState); + void SetFirstState(State *firstState); /** * @Description : Transition to orther state. * - * @param destState - state.[in] + * @param targetState - state.[in] */ - void TransitionTo(State *destState); + void SwitchState(State *targetState); /** * @Description : Delay Message. * * @param msg - Message object.[in] */ - void DeferMessage(InternalMessage *msg); + void DelayMessage(InternalMessage *msg); private: - SmHandler *pSmHandler; + StateMachineHandler *pStateMachineHandler; std::string mStateName; }; typedef struct StateInfo { State *state; - StateInfo *parentStateInfo; + StateInfo *upperStateInfo; bool active; } StateInfo; -class SmHandler : public Handler { +class StateMachineHandler : public Handler { public: - class QuittingState : public State { - public: - QuittingState() : State("QuittingState") - {} - ~QuittingState() - {} - void Enter() - {} - void Exit() - {} - bool ProcessMessage(InternalMessage *msg) - { - if (msg == nullptr) { - return NOT_HANDLED; - } - return NOT_HANDLED; - } - }; - - class HaltingState : public State { - public: - HaltingState() : State("HaltingState") - {} - ~HaltingState() - {} - void Enter() - {} - void Exit() - {} - bool ProcessMessage(InternalMessage *msg) - { - if (msg == nullptr) { - return NOT_HANDLED; - } - return HANDLED; - } - }; + using StateInfoMap = std::map; + using StateVector = std::vector; + using DelayedMessage = std::vector; /** * @Description : Construct a new state machine Handler:: StateMachine Handler object. * * @param pStateMgr - Handler pointer.[in] */ - explicit SmHandler(StateMachine *pStateMgr); + explicit StateMachineHandler(StateMachine *pStateMgr); /** * @Description : Destroy the StateMachine Handler:: StateMachine Handler object. * */ - ~SmHandler(); + ~StateMachineHandler(); /** - * @Description : SmHandler Initialization Function. + * @Description : StateMachineHandler Initialization Function. * * @return true : success, false : failed. */ @@ -329,72 +293,72 @@ public: * @Description : Add a new state. * * @param state - State to be added.[in] - * @param parent - parent of state.[in] + * @param upper - upper of state.[in] * @return StateInfo* */ - StateInfo *AddState(State *state, State *parent); + StateInfo *StatePlus(State *state, State *upper); /** * @Description : Delete a state. * * @param state - State to be deleted.[in] */ - void RemoveState(State *state); + void StateDelete(State *state); /** * @Description : Sets the Initialization State. * - * @param initialState - Initialization State.[in] + * @param firstState - Initialization State.[in] */ - void SetInitialState(State *initialState); + void SetFirstState(State *firstState); /** * @Description : State transition function. * - * @param destState - Destination State.[in] + * @param targetState - Destination State.[in] */ - void TransitionTo(State *destState); + void SwitchState(State *targetState); /** * @Description : Delay Message Processing Function. * * @param msg - Message body pointer.[in] */ - void DeferMessage(InternalMessage *msg); + void DelayMessage(InternalMessage *msg); /** * @Description : The state machine is constructed. * */ - void CompleteConstruction(); + void BuildTreeComplete(); private: /** * @Description : Sets the initial state sequence. * */ - void SetupInitialStateVector(); + void BuildStateInitVector(); /** - * @Description : Writes the inactive parent states of destState - * and destState to the sequenceStateList list. + * @Description : Writes the inactive upper states of targetState + * and targetState to the sequenceStateVector list. * - * @param destState - Target State Machine.[in] + * @param targetState - Target State Machine.[in] * @return StateInfo* */ - StateInfo *SetupTempStateStackWithStatesToEnter(State *destState); + StateInfo *BuildSequenceStateVector(State *targetState); /** - * @Description : Move Deferred Message At Front Of Queue. + * @Description : Move Delayed Message At Front Of Queue. * */ - void MoveDeferredMessageAtFrontOfQueue(); + void PlaceDelayedMsgQueueTop(); /** - * @Description : Release all messages in deferred Messages. + * @Description : Release all messages in delayed Messages. * */ - void ReleaseDeferredMessages(); + void ReleaseDelayedMessages(); /** * @Description : Fill the status in the sequential status @@ -402,23 +366,23 @@ private: * * @return int */ - int MoveSequenceStateListToStateList(); + int MoveSequenceToStateVector(); /** - * @Description : Invoke the ProcessMessage interface of the current state + * @Description : Invoke the ExecuteStateMsg interface of the current state * to process messages sent to the state machine. The entry/exit of the * state machine is also called, and the delayed messagei s put back * into queue when transitioning to a new state. * * @param msg - Messages.[in] */ - void HandleMessage(InternalMessage *msg); + void ExecuteMessage(InternalMessage *msg) override; /** * @Description : Clean up After Quitting. * */ - void CleanupAfterQuitting(); + void ClearWhenQuit(); /** * @Description : Performing Status Transitions. @@ -426,81 +390,65 @@ private: * @param msgProcessedState - Message processing status.[in] * @param msg - Messages.[in] */ - void PerformTransitions(State *msgProcessedState, InternalMessage *msg); + void PerformSwitchState(State *msgProcessedState, InternalMessage *msg); /** * @Description : Process messages. If the current state doesnot process it, - * the parent state processing is called, and so on. If all parent states - * are not processed, invoke the UnhandledMessage method of the state machine. + * the upper state processing is called, and so on. If all upper states + * are not processed, invoke the NotExecutedMessage method of the state machine. * * @param msg - Message body pointer.[in] * @return State* */ - State *ProcessMsg(InternalMessage *msg); + State *ExecuteTreeStateMsg(InternalMessage *msg); /** - * @Description : Invoke Exit() for each state from the first - * state in the list to the public parent state. + * @Description : Invoke GoOutState() for each state from the first + * state in the list to the public upper state. * - * @param commonStateInfo - common parent state machine.[in] + * @param commonStateInfo - common upper state machine.[in] */ - void InvokeExitMethods(StateInfo *commonStateInfo); + void CallTreeStateExits(StateInfo *commonStateInfo); /** - * @Description : Call the Enter method from the start state + * @Description : Call the GoInState method from the start state * index to the top of the state stack. * * @param index - Start state index of the * state machine list. */ - void InvokeEnterMethods(int index); - - /** - * @Description : Is Quit or not - * - * @param msg - Message body pointer.[in] - * @return true : success, false: failed. - */ - bool IsQuit(InternalMessage *msg); + void CallTreeStateEnters(int index); private: - typedef std::map StateInfoMap; - typedef std::vector StateList; - typedef std::vector DeferredMessage; - /* All state mappings of the state machine */ - StateInfoMap mStateInfo; - /* From child state to parent state list */ - StateList mStateList; - /* Top index of mStateList */ - int mStateListTopIndex; - /* From parent state to child state list */ - StateList mSequenceStateList; - /* Top of mSequenceStateList */ - int mSequenceStateListCount; - /* Deferred Message Queue */ - DeferredMessage mDeferredMessages; + StateInfoMap mStateInfoMap; + /* From child state to upper state list */ + StateVector mStateVector; + /* Top index of mStateVector */ + int mStateVectorTopIndex; + /* From upper state to child state list */ + StateVector mSequenceStateVector; + /* Top of mSequenceStateVector */ + int mSequenceStateVectorCount; + /* Delayed Message Queue */ + DelayedMessage mDelayedMessages; /* State machine instance */ - StateMachine *pSM; + StateMachine *pStateMachine; /* Initial state */ - State *pInitialState; + State *pFirstState; /* Target Status */ - State *pDestState; + State *pTargetState; /* StateMachine exit or not */ - bool mHasQuit; + bool mQuitFlag; /* Whether the state machine has been built */ - bool mIsConstructionCompleted; + bool mBuildCompleteFlag; /* * All State exit/enter calls are true before the * last enter call in the target state. */ - bool mTransitionInProgress; + bool mSwitchingStateFlag; /* Current Message */ InternalMessage *pCurrentMsg; - /* Exit state */ - QuittingState *pQuittingState; - /* Pauses */ - HaltingState *pHaltingState; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/BUILD.gn b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/BUILD.gn index 73a8258122d37f9585cf247360dd066389638b76..2e5bf01adfd2ebbbd673dcad574bad911afd79d7 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/BUILD.gn +++ b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/BUILD.gn @@ -89,13 +89,9 @@ ohos_shared_library("wifi_idl_client") { "wifi_ap_hal_interface.cpp", "wifi_base_hal_interface.cpp", "wifi_chip_hal_interface.cpp", - "wifi_device_manager.cpp", - "wifi_hal_interface.cpp", "wifi_idl_client.cpp", - "wifi_interface_manager.cpp", "wifi_sta_hal_interface.cpp", "wifi_supplicant_hal_interface.cpp", - "wifi_vendor_interface.cpp", ] configs = [ ":wifi_fw_common_header" ] diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_sta_iface.c b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_sta_iface.c index 5b9288f974648d77fa7f47eeb66ea9a0cc2dae67..b90b9b5bae0808c494549b4fe0477146a558d571 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_sta_iface.c +++ b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_sta_iface.c @@ -530,7 +530,7 @@ WifiErrorNo GetScanResults(ScanResult *results, int *size) ReadInt(context, &results[i].signalLevel); ReadStr(context, results[i].capability, WIFI_SCAN_RESULT_CAPABILITIES_LENGTH); ReadStr(context, results[i].ssid, WIFI_SSID_LENGTH); - ReadLong(context, &results[i].timestamp); + ReadInt64(context, &results[i].timestamp); } } ReadClientEnd(client); diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_struct.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_struct.h index fb945224b13e58205fee6a3f66bbdf50af8b73cb..7a062e9c57c900c0fab6d88981aab0ef90352bf1 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_struct.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface/i_wifi_struct.h @@ -25,7 +25,7 @@ typedef char BOOL; #define TRUE 1 #define FALSE 0 -#define WIFI_SSID_LENGTH 128 +#define WIFI_SSID_LENGTH 132 #define WIFI_BSSID_LENGTH 128 #define WIFI_SCAN_RESULT_ELEMENT_LENGTH 256 #define WIFI_SCAN_RESULT_CAPABILITIES_LENGTH 256 @@ -96,7 +96,7 @@ typedef struct ScanResult { char infoElement[WIFI_SCAN_RESULT_ELEMENT_LENGTH]; int frequency; int signalLevel; - long timestamp; + int64_t timestamp; char capability[WIFI_SCAN_RESULT_CAPABILITIES_LENGTH]; int associated; } ScanResult; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.cpp b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.cpp deleted file mode 100644 index 7bb021dfad3e603174d32bfaa0616daf552bbaa7..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wifi_device_manager.h" -#include "wifi_log.h" -#include "i_wifi.h" -#include "i_wifi_chip.h" - -#undef LOG_TAG -#define LOG_TAG "OHWIFI_IDLCLIENT_WIFI_DEVICE_MANAGER" - -namespace OHOS { -namespace Wifi { -WifiInterfaceCreateInfo::WifiInterfaceCreateInfo():chipModde(0) -{} - -WifiInterfaceCreateInfo::~WifiInterfaceCreateInfo() -{} - -IWifiClientIface *WifiDeviceManager::CreateStaInterface(const std::string &ifaceName) -{ - LOGD("CreateStaInterface iface %s", ifaceName.c_str()); - return (IWifiClientIface *)CreateInterface(TYPE_STA); -} - -bool WifiDeviceManager::RemoveStaInterface(const IWifiIface &iface) -{ - return RemoveInterface(iface); -} - -IWifiApIface *WifiDeviceManager::CreateApInterface(const std::string &ifaceName) -{ - LOGD("CreateApInterface iface %s", ifaceName.c_str()); - return (IWifiApIface *)CreateInterface(TYPE_AP); -} - -bool WifiDeviceManager::RemoveApInterface(const IWifiIface &iface) -{ - return RemoveInterface(iface); -} - -bool WifiDeviceManager::IsSupported() -{ - return true; -} - -bool WifiDeviceManager::IsStarted() -{ - return false; -} - -void WifiDeviceManager::GetSupportedIfaceTypes(std::vector &ifaceTypes) -{ - LOGD("GetSupportedIfaceTypes begin size %{public}d", ifaceTypes.size()); - return; -} - -IWifiIface *WifiDeviceManager::CreateInterface(const int &ifaceType) -{ - std::vector chipInfos; - GetChipInfos(chipInfos); - if (chipInfos.size() == 0) { - StopWifi(); - } - - IWifiIface *iface = TryToCreateInterface(chipInfos, ifaceType); - return iface; -} - -IWifiIface *WifiDeviceManager::TryToCreateInterface(const std::vector &chipInfos, const int &ifaceType) -{ - LOGD("TryToCreateInterface chip size %{public}d", chipInfos.size()); - WifiInterfaceCreateInfo ifaceCreateInfo; - IWifiIface *iface = ReConfigChip(ifaceCreateInfo, ifaceType); - return iface; -} - -IWifiIface *WifiDeviceManager::ReConfigChip(WifiInterfaceCreateInfo &ifaceCreateInfo, const int &ifaceType) -{ - bool isModeChange = - !ifaceCreateInfo.chipInfo.currentModeId || ifaceCreateInfo.chipInfo.currentModeId == ifaceCreateInfo.chipModde; - if (isModeChange) { - std::vector wifiIfaceInfos; - WifiIfaceInfo ifaceInfo; - std::map>::iterator itor = ifaceCreateInfo.chipInfo.wifiInterfaces.begin(); - while (itor != ifaceCreateInfo.chipInfo.wifiInterfaces.end()) { - wifiIfaceInfos.clear(); - wifiIfaceInfos.swap(itor->second); - - std::vector::iterator iter = wifiIfaceInfos.begin(); - while (iter != wifiIfaceInfos.end()) { - ifaceInfo = *iter; - RemoveInterface(ifaceInfo.iface); - iter++; - } - - itor++; - } - } else { - WifiIfaceInfo ifaceInfo; - std::vector::iterator iter = ifaceCreateInfo.toBeRemovedInterfaces.begin(); - while (iter != ifaceCreateInfo.toBeRemovedInterfaces.end()) { - ifaceInfo = *iter; - RemoveInterface(ifaceInfo.iface); - iter++; - } - } - - /* create new interface */ - IWifiIface *wifiIface = nullptr; - WifiErrorNo errorNo = CreateIface(ifaceType, wifiIface); - if (errorNo != WIFI_IDL_OPT_OK) { - LOGE("create new interface failed!"); - return nullptr; - } - - return wifiIface; -} - -bool WifiDeviceManager::RemoveInterface(const IWifiIface &iface) -{ - std::string strName = std::string(iface.name); - WifiErrorNo error = RemoveIface(strName.c_str()); - if (error != WIFI_IDL_OPT_OK) { - LOGE("remove interface %s failed!", iface.name); - return false; - } - - return true; -} - -void WifiDeviceManager::GetChipInfos(std::vector &chipInfos) -{ - LOGD("GetChipInfos chip size %{public}d", chipInfos.size()); - uint8_t ids[8] = {0}; - int32_t len = 0; - WifiErrorNo error = GetWifiChipIds(ids, &len); - if (error != WIFI_IDL_OPT_OK) { - LOGE("GetWifiChipIds failed!"); - return; - } -} - -bool WifiDeviceManager::StartWifi() -{ - InitWifi(); - return false; -} - -void WifiDeviceManager::InitWifi() -{ - StopWifi(); -} - -void WifiDeviceManager::StopWifi() -{ - return; -} -} // namespace Wifi -} // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.h deleted file mode 100644 index 28dae527f28ffa2db4499ec0e628310f1d1b1b7b..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_device_manager.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIDEVICEMANAGER_H -#define OHOS_WIFIDEVICEMANAGER_H - -#include -#include -#include -#include "i_wifi_struct.h" - -namespace OHOS { -namespace Wifi { -class WifiIfaceInfo { -public: - std::string name; - IWifiIface iface; -}; - -class WifiChipInfo { -public: - IWifiChip chip; - int chipId; - std::vector chipModes; - int currentModeId; - std::map> wifiInterfaces; -}; - -class WifiInterfaceCreateInfo { -public: - WifiInterfaceCreateInfo(); - ~WifiInterfaceCreateInfo(); - WifiChipInfo chipInfo; - int chipModde; - std::vector toBeRemovedInterfaces; -}; - -class WifiDeviceManager { -public: - /** - * @Description Create a Sta Interface object. - * - * @param ifaceName - * @return IWifiClientIface* - */ - IWifiClientIface *CreateStaInterface(const std::string &ifaceName); - /** - * @Description Remove Sta Interface. - * - * @param iface - * @return true - * @return false - */ - bool RemoveStaInterface(const IWifiIface &iface); - /** - * @Description Create a Ap Interface object. - * - * @param ifaceName - * @return IWifiApIface* - */ - IWifiApIface *CreateApInterface(const std::string &ifaceName); - /** - * @Description Remove Ap Interface. - * - * @param iface - * @return true - * @return false - */ - bool RemoveApInterface(const IWifiIface &iface); - /** - * @Description Check is supported. - * - * @return true - * @return false - */ - bool IsSupported(); - /** - * @Description Check is Started. - * - * @return true - * @return false - */ - bool IsStarted(); - /** - * @Description Get the Supported Iface Types. - * - * @param ifaceTypes - */ - void GetSupportedIfaceTypes(std::vector &ifaceTypes); - -private: - IWifiIface *CreateInterface(const int &ifaceType); - IWifiIface *TryToCreateInterface(const std::vector &chipInfos, const int &ifaceType); - IWifiIface *ReConfigChip(WifiInterfaceCreateInfo &ifaceCreateInfo, const int &ifaceType); - bool RemoveInterface(const IWifiIface &iface); - void GetChipInfos(std::vector &chipInfos); - bool StartWifi(); - void InitWifi(); - void StopWifi(); -}; -} // namespace Wifi -} // namespace OHOS -#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.cpp b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.cpp deleted file mode 100644 index c475a03c4754d116e4df8a3950e40fc815a780f7..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wifi_hal_interface.h" -#include "wifi_log.h" - -#undef LOG_TAG -#define LOG_TAG "OHWIFI_IDLCLIENT_WIFI_HAL_INTERFACE" - -namespace OHOS { -namespace Wifi { -WifiHalInterface &WifiHalInterface::GetInstance(void) -{ - static WifiHalInterface instance; - return instance; -} - -int WifiHalInterface::CreateStaInterface(InterfaceType type, WifiInterfaceInfo *iface) -{ - iface = mIfaceMgr.AllocInteface(type); - if (iface == nullptr) { - LOGE("CreateStaInterface:alloc interface error!"); - return -1; - } - - if (mVendorInterface.IsVendorHalSupported()) { - mVendorInterface.CreateStaInterface(iface->name); - } else { - LOGW("CreateStaInterface:Vendor Hal is not supported."); - iface->name = "wlan0"; - } - - if (iface->name.empty()) { - LOGE("Create STA iface Failed in vendor HAL."); - mIfaceMgr.RemoveInterface(iface->id); - return -1; - } - - LOGD("CreateStaInterface Successfully,and name is %s", iface->name.c_str()); - OnInterfaceStateChanged(*iface, IsWifiInterfaceUp(iface->name)); - - /* get wifi insterface support feature */ - iface->featureSet = mVendorInterface.GetSupportedFeatureSet(iface->name); - return 0; -} - -int WifiHalInterface::CreateApInterface(WifiInterfaceInfo *iface) -{ - iface = mIfaceMgr.AllocInteface(IFACE_TYPE_AP); - if (iface == nullptr) { - LOGE("CreateApInterface:alloc interface error!"); - return -1; - } - - if (mVendorInterface.IsVendorHalSupported()) { - mVendorInterface.CreateStaInterface(iface->name); - } else { - LOGW("CreateApInterface:Vendor Hal is not supported."); - iface->name = "wlan1"; - } - - if (iface->name.empty()) { - LOGE("Create AP iface Failed in vendor HAL."); - mIfaceMgr.RemoveInterface(iface->id); - return -1; - } - - LOGD("CreateApInterface Successfully,and name is %s", iface->name.c_str()); - OnInterfaceStateChanged(*iface, IsWifiInterfaceUp(iface->name)); - - /* get wifi insterface support feature */ - iface->featureSet = mVendorInterface.GetSupportedFeatureSet(iface->name); - return 0; -} - -bool WifiHalInterface::RemoveStaInterface(const WifiInterfaceInfo *iface) -{ - if (mVendorInterface.IsVendorHalSupported()) { - return mVendorInterface.RemoveStaInterface(iface->name); - } else { - LOGW("RemoveStaInterface:Vendor Hal is not supported."); - if (mIfaceMgr.RemoveInterface(iface->id)) { - OnInterfaceDestroyed(*iface); - LOGI("remove interface name = %s,id = %{public}d successfully!", iface->name.c_str(), iface->id); - return true; - } - } - - return false; -} - -bool WifiHalInterface::RemoveApInterface(const WifiInterfaceInfo *iface) -{ - if (mVendorInterface.IsVendorHalSupported()) { - return mVendorInterface.RemoveApInterface(iface->name); - } else { - LOGW("RemoveApInterface:Vendor Hal is not supported."); - if (mIfaceMgr.RemoveInterface(iface->id)) { - OnInterfaceDestroyed(*iface); - LOGI("remove interface name = %s,id = %{public}d successfully!", iface->name.c_str(), iface->id); - return true; - } - } - - return false; -} - -bool WifiHalInterface::ShutDownInterface(const std::string &ifaceName) -{ - WifiInterfaceInfo *iface = mIfaceMgr.GetInterface(ifaceName); - if (iface == nullptr) { - return false; - } - if (iface->type == IFACE_TYPE_STA_FOR_CONNECTIVITY || iface->type == IFACE_TYPE_STA_FOR_SCAN) { - return RemoveStaInterface(iface); - } else if (iface->type == IFACE_TYPE_AP) { - return RemoveApInterface(iface); - } - - LOGI("interface %s is no need to remove!", ifaceName.c_str()); - return true; -} - -bool WifiHalInterface::IsWifiInterfaceUp(const std::string &ifaceName) -{ - LOGD("IsWifiInterfaceUp iface %s", ifaceName.c_str()); - return false; -} - -void WifiHalInterface::OnInterfaceStateChanged(WifiInterfaceInfo &iface, bool bIsUp) -{ - if (bIsUp == iface.isUp) { - LOGD("interface status is unchanged on index %{public}d is %{public}d", iface.id, bIsUp); - return; - } - - LOGD("interface %s old status is %{public}d,new status is %{public}d", iface.name.c_str(), iface.isUp, bIsUp); - iface.isUp = bIsUp; -} - -void WifiHalInterface::OnInterfaceDestroyed(const WifiInterfaceInfo &iface) -{ - if (iface.type == IFACE_TYPE_STA_FOR_CONNECTIVITY) { - OnStaInterfaceForConnectivityDestroyed(iface); - } else if (iface.type == IFACE_TYPE_STA_FOR_SCAN) { - OnStaInterfaceForScanDestroyed(iface); - } else if (iface.type == IFACE_TYPE_AP) { - OnApInterfaceForConnectivityDestroyed(iface); - } -} -void WifiHalInterface::OnStaInterfaceForScanDestroyed(const WifiInterfaceInfo &iface) -{ - LOGD("OnStaInterfaceForScanDestroyed iface type %{public}d", iface.type); - return; -} - -void WifiHalInterface::OnStaInterfaceForConnectivityDestroyed(const WifiInterfaceInfo &iface) -{ - LOGD("OnStaInterfaceForConnectivityDestroyed iface type %{public}d", iface.type); - return; -} - -void WifiHalInterface::OnApInterfaceForConnectivityDestroyed(const WifiInterfaceInfo &iface) -{ - LOGD("OnApInterfaceForConnectivityDestroyed iface type %{public}d", iface.type); - return; -} -} // namespace Wifi -} // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.h deleted file mode 100644 index 3de2f515c9a4d06179485de44b23195a29f9deeb..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_hal_interface.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIHALINTERFACE_H -#define OHOS_WIFIHALINTERFACE_H - -#include -#include "wifi_interface_manager.h" -#include "wifi_vendor_interface.h" - -namespace OHOS { -namespace Wifi { -class WifiHalInterface { -public: - /** - * @Description Get the Instance object. - * - * @return WifiHalInterface& - */ - static WifiHalInterface &GetInstance(void); - /** - * @Description Create a Sta Interface object. - * - * @param type - * @param iface - * @return int - */ - int CreateStaInterface(InterfaceType type, WifiInterfaceInfo *iface); - /** - * @Description Create a Ap Interface object. - * - * @param iface - * @return int - */ - int CreateApInterface(WifiInterfaceInfo *iface); - /** - * @Description Remove Sta Interface. - * - * @param iface - * @return true - * @return false - */ - bool RemoveStaInterface(const WifiInterfaceInfo *iface); - /** - * @Description Remove Ap Interface. - * - * @param iface - * @return true - * @return false - */ - bool RemoveApInterface(const WifiInterfaceInfo *iface); - /** - * @Description Shut Down Interface. - * - * @param ifaceName - * @return true - * @return false - */ - bool ShutDownInterface(const std::string &ifaceName); - /** - * @Description Is Wifi Interface Up. - * - * @param ifaceName - * @return true - * @return false - */ - bool IsWifiInterfaceUp(const std::string &ifaceName); - -private: - void OnInterfaceStateChanged(WifiInterfaceInfo &iface, bool bIsUp); - void OnInterfaceDestroyed(const WifiInterfaceInfo &iface); - void OnStaInterfaceForScanDestroyed(const WifiInterfaceInfo &iface); - void OnStaInterfaceForConnectivityDestroyed(const WifiInterfaceInfo &iface); - void OnApInterfaceForConnectivityDestroyed(const WifiInterfaceInfo &iface); - -private: - WifiInterfaceManager mIfaceMgr; - WifiVendorInterface mVendorInterface; -}; -} // namespace Wifi -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_idl_struct.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_idl_struct.h index b5d3e10190d3658a0c9a86eb34b71d4c0959a66d..47e3344dbd82935232c7931cdf048767423c19d7 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_idl_struct.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_idl_struct.h @@ -27,7 +27,7 @@ struct WifiIdlDeviceConfig { int networkId; int priority; int scanSsid; - int authAlgorithms; /* WifiDeviceConfig.allowedAuthAlgorithms */ + int authAlgorithms; int wepKeyIdx; std::string wepKeys[MAX_WEPKEYS_SIZE]; /* max set 4 wepkeys */ std::string ssid; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_info.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_info.h deleted file mode 100644 index 0167583c80534d6bb3a0884df65b5970600fd8a7..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_info.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIINTERFACEINFO_H -#define OHOS_WIFIINTERFACEINFO_H - -#include - -namespace OHOS { -namespace Wifi { -typedef enum InterfaceType { IFACE_TYPE_AP, IFACE_TYPE_STA_FOR_CONNECTIVITY, IFACE_TYPE_STA_FOR_SCAN } InterfaceType; - -class WifiInterfaceInfo { -public: - WifiInterfaceInfo() - {} - ~WifiInterfaceInfo() - {} - - int id; - InterfaceType type; - std::string name; - bool isUp = false; - long featureSet = 0; -}; -} // namespace Wifi -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.cpp b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.cpp deleted file mode 100644 index de8035babc2b3264f05322c50b8dd45ded58cc05..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wifi_interface_manager.h" - -namespace OHOS { -namespace Wifi { -WifiInterfaceManager::WifiInterfaceManager() -{ - m_interfaceMap.clear(); - m_nextIndex = 0; -} - -WifiInterfaceManager::~WifiInterfaceManager() -{ - if (!m_interfaceMap.empty()) { - MAP_INT_INTERFACEINFO::iterator itor = m_interfaceMap.begin(); - while (itor != m_interfaceMap.end()) { - WifiInterfaceInfo *pInfo = itor->second; - delete pInfo; - pInfo = nullptr; - } - - m_interfaceMap.clear(); - } -} - -WifiInterfaceInfo *WifiInterfaceManager::AllocInteface(InterfaceType type) -{ - WifiInterfaceInfo *pInfo = new WifiInterfaceInfo(); - pInfo->type = type; - pInfo->id = m_nextIndex; - m_interfaceMap.insert(std::make_pair(m_nextIndex, pInfo)); - m_nextIndex++; - return pInfo; -} - -WifiInterfaceInfo *WifiInterfaceManager::GetInterface(const int &id) -{ - WifiInterfaceInfo *pInfo = nullptr; - MAP_INT_INTERFACEINFO::iterator itor = m_interfaceMap.begin(); - while (itor != m_interfaceMap.end()) { - pInfo = itor->second; - if (pInfo->id == id) { - break; - } - } - - return pInfo; -} - -WifiInterfaceInfo *WifiInterfaceManager::GetInterface(const std::string &ifaceName) -{ - WifiInterfaceInfo *pInfo = nullptr; - MAP_INT_INTERFACEINFO::iterator itor = m_interfaceMap.begin(); - while (itor != m_interfaceMap.end()) { - pInfo = itor->second; - if (pInfo->name == ifaceName) { - break; - } - } - - return pInfo; -} - -bool WifiInterfaceManager::RemoveInterface(const int &id) -{ - MAP_INT_INTERFACEINFO::iterator itor = m_interfaceMap.begin(); - while (itor != m_interfaceMap.end()) { - if (itor->second->id == id) { - WifiInterfaceInfo *pInfo = itor->second; - delete pInfo; - pInfo = nullptr; - break; - } - } - - m_interfaceMap.erase(id); - return true; -} - -bool WifiInterfaceManager::IsAnyInterfaceExist() -{ - if (m_interfaceMap.empty()) { - return false; - } - - return true; -} -} // namespace Wifi -} // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.h deleted file mode 100644 index 89ed2edd29b3348ede18c1676ecc004c3cb8b1c0..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_interface_manager.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIINTERFACEMANAGER_H -#define OHOS_WIFIINTERFACEMANAGER_H - -#include -#include -#include "wifi_interface_info.h" - -namespace OHOS { -namespace Wifi { -typedef std::map MAP_INT_INTERFACEINFO; -class WifiInterfaceManager { -public: - /** - * @Description Construct a new Wifi Interface Manager object. - * - */ - WifiInterfaceManager(); - /** - * @Description Destroy the Wifi Interface Manager object. - * - */ - ~WifiInterfaceManager(); - /** - * @Description Apply for WifiInterfaceInfo* memory based on the type value. - * - * @param type - * @return WifiInterfaceInfo* - */ - WifiInterfaceInfo *AllocInteface(InterfaceType type); - /** - * @Description Get the Interface object. - * - * @param id - * @return WifiInterfaceInfo* - */ - WifiInterfaceInfo *GetInterface(const int &id); - /** - * @Description Get the Interface object. - * - * @param ifaceName - * @return WifiInterfaceInfo* - */ - WifiInterfaceInfo *GetInterface(const std::string &ifaceName); - /** - * @Description Remove Interface by id. - * - * @param id - * @return true - * @return false - */ - bool RemoveInterface(const int &id); - /** - * @Description Check is any interface exist. - * - * @return true - * @return false - */ - bool IsAnyInterfaceExist(); - -private: - int m_nextIndex; - MAP_INT_INTERFACEINFO m_interfaceMap; -}; -} // namespace Wifi -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_scan_result.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_scan_result.h index f6e4b76b9a9b6e72f909ff88da1bfcd9cb277961..b779a61c268ce0d72cd737bdda1312180655b3c0 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_scan_result.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_scan_result.h @@ -27,7 +27,7 @@ public: std::string infoElement; int frequency; int signalLevel; - long timestamp; + int64_t timestamp; std::string capability; bool associated; }; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.cpp b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.cpp deleted file mode 100644 index 4c7cb27074ae6da6fc3d0e27fa2c8d0912aff1c1..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "wifi_vendor_interface.h" -#include "wifi_log.h" - -#undef LOG_TAG -#define LOG_TAG "OHWIFI_IDLCLIENT_WIFI_VENDOR_INTERFACE" - -namespace OHOS { -namespace Wifi { -int WifiVendorInterface::CreateStaInterface(std::string &ifaceName) -{ - mDeviceManager.CreateStaInterface(ifaceName); - if (ifaceName.empty()) { - LOGE("CreateStaInterface: failed!"); - return -1; - } - return 0; -} - -bool WifiVendorInterface::RemoveStaInterface(const std::string &ifaceName) -{ - IWifiClientIface *staIface = nullptr; - GetWifiStaIface(ifaceName, staIface); - IWifiIface *iface = (IWifiIface *)staIface; - if (iface == nullptr) { - return false; - } - return mDeviceManager.RemoveStaInterface(*iface); -} - -int WifiVendorInterface::CreateApInterface(std::string &ifaceName) -{ - mDeviceManager.CreateStaInterface(ifaceName); - if (ifaceName.empty()) { - LOGE("CreateStaInterface: failed!"); - return -1; - } - return 0; -} - -bool WifiVendorInterface::RemoveApInterface(const std::string &ifaceName) -{ - IWifiApIface *apIface = nullptr; - GetWifiApIface(ifaceName, apIface); - IWifiIface *iface = (IWifiIface *)apIface; - if (iface == nullptr) { - return false; - } - return mDeviceManager.RemoveApInterface(*iface); -} - -bool WifiVendorInterface::IsVendorHalSupported() -{ - return mDeviceManager.IsSupported(); -} - -long WifiVendorInterface::GetSupportedFeatureSet(const std::string &ifaceName) -{ - LOGD("GetSupportedFeatureSet iface %s", ifaceName.c_str()); - long featureSet = 0; - if (!mDeviceManager.IsStarted()) { - return featureSet; - } - return featureSet; -} - -void WifiVendorInterface::GetWifiStaIface(const std::string &ifaceName, IWifiClientIface *iface) -{ - std::map::iterator itor = mWifiStaIfaces.find(ifaceName); - if (itor != mWifiStaIfaces.end()) { - iface = itor->second; - } -} - -void WifiVendorInterface::GetWifiApIface(const std::string &ifaceName, IWifiApIface *iface) -{ - std::map::iterator itor = mWifiApIfaces.find(ifaceName); - if (itor != mWifiApIfaces.end()) { - iface = itor->second; - } -} -} // namespace Wifi -} // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.h b/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.h deleted file mode 100644 index 8bfa4ad889d90a8e595dc1f27c0e020e5f78d18f..0000000000000000000000000000000000000000 --- a/services/wifi_standard/wifi_framework/wifi_manage/idl_client/wifi_vendor_interface.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_WIFIVENDORINTERFACE_H -#define OHOS_WIFIVENDORINTERFACE_H - -#include -#include "wifi_device_manager.h" -#include "i_wifi_struct.h" - -namespace OHOS { -namespace Wifi { -class WifiVendorInterface { -public: - /** - * @Description Create a Sta Interface object. - * - * @param ifaceName - * @return int - 0 Success, -1 Failed. - */ - int CreateStaInterface(std::string &ifaceName); - /** - * @Description Remove Sta Interface. - * - * @param ifaceName - * @return true - * @return false - */ - bool RemoveStaInterface(const std::string &ifaceName); - /** - * @Description Create an Ap Interface object. - * - * @param ifaceName - * @return int - 0 Success, -1 Failed. - */ - int CreateApInterface(std::string &ifaceName); - /** - * @Description Remove Ap Interface. - * - * @param ifaceName - * @return true - * @return false - */ - bool RemoveApInterface(const std::string &ifaceName); - /** - * @Description Check is vendor hal supported. - * - * @return true - * @return false - */ - bool IsVendorHalSupported(); - /** - * @Description Get the Supported Feature Set object. - * - * @param ifaceName - * @return long - */ - long GetSupportedFeatureSet(const std::string &ifaceName); - -private: - void GetWifiStaIface(const std::string &ifaceName, IWifiClientIface *iface); - void GetWifiApIface(const std::string &ifaceName, IWifiApIface *iface); - -private: - WifiDeviceManager mDeviceManager; - std::map mWifiStaIfaces; - std::map mWifiApIfaces; -}; -} // namespace Wifi -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp index 467606c3f91c95d6cf230ba23f8966d557c42217..c961c9e2ffb06f7ffa9809efda5117b1ae42e6f2 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp @@ -28,17 +28,17 @@ ApIdleState::ApIdleState() : State("ApIdleState") ApIdleState::~ApIdleState() {} -void ApIdleState::Enter() +void ApIdleState::GoInState() { - LOGI("%{public}s Enter", GetName().c_str()); + LOGI("%{public}s Enter", GetStateName().c_str()); } -void ApIdleState::Exit() +void ApIdleState::GoOutState() { - LOGI("%{public}s Exit", GetName().c_str()); + LOGI("%{public}s Exit", GetStateName().c_str()); } -bool ApIdleState::ProcessMessage(InternalMessage *msg) +bool ApIdleState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { LOGE("fatal error!"); @@ -49,18 +49,18 @@ bool ApIdleState::ProcessMessage(InternalMessage *msg) switch (static_cast(msgName)) { case ApStatemachineEvent::CMD_START_HOTSPOT: { - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApStartedState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApStartedState); break; } case ApStatemachineEvent::CMD_UPDATE_HOTSPOTCONFIG_RESULT: { break; } default: - return NOT_HANDLED; + return NOT_EXECUTED; break; } - return HANDLED; + return EXECUTED; } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.h index d5f8b50f6f6610c0d53ce1a49baff51fdfd4c6c5..aab2bd1c98eb5f7fd35289e5490a93b7fb9c902e 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.h @@ -42,19 +42,19 @@ public: * @param None * @return None */ - virtual void Enter() override; + virtual void GoInState() override; /** * @Description realize pure base class method: called when exit state. * @param None * @return None */ - virtual void Exit() override; + virtual void GoOutState() override; /** * @Description realize pure base class method: process event in idle state. * @param msg - message to be processed - * @return HANDLED:Processed successfully NOT_HANDLED: Processed failed + * @return EXECUTED:Processed successfully NOT_EXECUTED: Processed failed */ - virtual bool ProcessMessage(InternalMessage *msg) override; + virtual bool ExecuteStateMsg(InternalMessage *msg) override; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.cpp index d407bd651ec2c2afdd64b7770d2149852424449b..bec5a1659d384b33fc5c0860a6715385eda496ee 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.cpp @@ -28,17 +28,17 @@ ApRootState::ApRootState() : State("ApRootState") ApRootState::~ApRootState() {} -void ApRootState::Enter() +void ApRootState::GoInState() { - LOGI("%{public}s Enter", GetName().c_str()); + LOGI("%{public}s Enter", GetStateName().c_str()); } -void ApRootState::Exit() +void ApRootState::GoOutState() { - LOGI("%{public}s Exit", GetName().c_str()); + LOGI("%{public}s Exit", GetStateName().c_str()); } -bool ApRootState::ProcessMessage(InternalMessage *msg) +bool ApRootState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { LOGE("fatal error!"); @@ -47,7 +47,7 @@ bool ApRootState::ProcessMessage(InternalMessage *msg) int msgName = msg->GetMessageName(); LOGI("msg = [%{public}dpublic}d] is not handled.", msgName); - return HANDLED; + return EXECUTED; } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.h index bde8e2f484cc358ffc7206c485543883cce0210d..f87b007cbb0d2d164de2a23c2ac7592b44de856a 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.h @@ -40,20 +40,20 @@ public: * @param None * @return None */ - virtual void Enter() override; + virtual void GoInState() override; /** * @Description realize pure base class method: called when exit root state. * @param None * @return None */ - virtual void Exit() override; + virtual void GoOutState() override; /** * @Description realize pure base class method: Messages that cannot be processed in the sub-state are recorded in the root state. * @param msg - message to be processed - * @return HANDLED:Processed successfully + * @return EXECUTED:Processed successfully */ - virtual bool ProcessMessage(InternalMessage *msg) override; + virtual bool ExecuteStateMsg(InternalMessage *msg) override; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp index 24082b5ba766e7d35b8ee5d0a5178425150283df..c579edcc05c964dde7d8eb08ce2ec12bb1dfa698 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp @@ -43,29 +43,29 @@ ApStartedState::ApStartedState() : State("ApStartedState"), hotspotConfig(Hotspo ApStartedState::~ApStartedState() {} -void ApStartedState::Enter() +void ApStartedState::GoInState() { OnApStateChange(ApState::AP_STATE_STARTING); - LOGI("%{public}s Enter", GetName().c_str()); + LOGI("%{public}s Enter", GetStateName().c_str()); StartMonitor(); if (StartAp() == false) { LOGE("enter ApstartedState is failed."); - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); return; } LOGI("StartAP is ok"); if (ApConfigUse::GetInstance().ObtainValidChannels() == false) { LOGE("ObtainValidChannels is error."); - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); return; } if (SetConfig() == false) { LOGE("wifi_settings.hotspotconfig is error."); - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); return; } @@ -74,20 +74,20 @@ void ApStartedState::Enter() } #ifndef AP_NOT_DIRECT_USE_DHCP if (StartDhcpServer() == false) { - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); return; } if (EnableInterfaceNat() == false) { - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); return; } #endif OnApStateChange(ApState::AP_STATE_STARTED); } -void ApStartedState::Exit() +void ApStartedState::GoOutState() { - LOGI("%{public}s Exit", GetName().c_str()); + LOGI("%{public}s Exit", GetStateName().c_str()); OnApStateChange(ApState::AP_STATE_CLOSING); DisableInterfaceNat(); StopDhcpServer(); @@ -121,7 +121,7 @@ void ApStartedState::Init() std::make_pair(ApStatemachineEvent::CMD_DISCONNECT_STATION, &ApStartedState::ProcessCmdDisconnectStation)); } -bool ApStartedState::ProcessMessage(InternalMessage *msg) +bool ApStartedState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { LOGE("fatal error!"); @@ -132,11 +132,11 @@ bool ApStartedState::ProcessMessage(InternalMessage *msg) auto iter = mProcessFunMap.find(static_cast(msgName)); if (iter == mProcessFunMap.end()) { - return NOT_HANDLED; + return NOT_EXECUTED; } ((*this).*(iter->second))(*msg); - return HANDLED; + return EXECUTED; } bool ApStartedState::SetConfig() @@ -234,7 +234,7 @@ bool ApStartedState::DisableInterfaceNat() const void ApStartedState::ProcessCmdFail(InternalMessage &msg) const { LOGI("State Machine message: %{public}d.", msg.GetMessageName()); - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); } void ApStartedState::ProcessCmdStationJoin(InternalMessage &msg) const @@ -285,13 +285,13 @@ void ApStartedState::ProcessCmdSetHotspotConfig(InternalMessage &msg) void ApStartedState::ProcessCmdUpdateConfigResult(InternalMessage &msg) const { - if (msg.GetArg1() == 1) { + if (msg.GetParam1() == 1) { LOGI("Hot update HotspotConfig succeeded."); if (WifiSettings::GetInstance().SetHotspotConfig(hotspotConfig)) { LOGE("set apConfig to settings failed."); } } else { - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); } } @@ -320,7 +320,7 @@ void ApStartedState::ProcessCmdDelBlockList(InternalMessage &msg) const void ApStartedState::ProcessCmdStopHotspot(InternalMessage &msg) const { LOGI("Disable hotspot: %{public}d.", msg.GetMessageName()); - ApStateMachine::GetInstance().TransitionTo(&ApStateMachine::GetInstance().mApIdleState); + ApStateMachine::GetInstance().SwitchState(&ApStateMachine::GetInstance().mApIdleState); } void ApStartedState::ProcessCmdDisconnectStation(InternalMessage &msg) const diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h index 1b5ddd702ffba371dffdfee8644fe7bedcdd09a5..ae2c46f105f3f084d430f262cf68e6c1181a422a 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h @@ -39,13 +39,13 @@ public: /** * @Description Implement pure base class methods:Called when entering the state,When receiving the start AP,Switch to the - current state by ApIdleState and call Enter to initialize + current state by ApIdleState and call GoInState to initialize hot spots(Start the wifi driver,Set hostapd to start hotspot mode,Set blocklist, etc.) * @param None * @return None */ - virtual void Enter() override; + virtual void GoInState() override; /** * @Description Implement pure base class methods:Called when exiting the state,Called when the hotspot is closed or the @@ -54,15 +54,15 @@ public: * @param None * @return None */ - virtual void Exit() override; + virtual void GoOutState() override; /** * @Description Implement pure base class methods:The CMD processed when the AP is in the running state (such as updating the blocklist to hostapd) * @param msg - processed message - * @return HANDLED:Processed successfully NOT_HANDLED: Processed failed + * @return EXECUTED:Processed successfully NOT_EXECUTED: Processed failed */ - virtual bool ProcessMessage(InternalMessage *msg) override; + virtual bool ExecuteStateMsg(InternalMessage *msg) override; private: /** diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.cpp index 7d4f429225358235216536f7a1979e33797a73ad..bea1d4e32436d4b0909efe9ee5534f3ce4c68efc 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.cpp @@ -58,17 +58,17 @@ void ApStateMachine::DeleteInstance() void ApStateMachine::Init() { LOGI("ApStateMachine::Init"); - AddState(&mApRootState, nullptr); - AddState(&mApIdleState, &mApRootState); - AddState(&mApStartedState, &mApRootState); + StatePlus(&mApRootState, nullptr); + StatePlus(&mApIdleState, &mApRootState); + StatePlus(&mApStartedState, &mApRootState); - SetInitialState(&mApIdleState); - Start(); + SetFirstState(&mApIdleState); + StartStateMachine(); } void ApStateMachine::StationJoin(StationInfo &staInfo) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_STATION_JOIN)); msg->AddStringMessageBody(staInfo.deviceName); msg->AddStringMessageBody(staInfo.bssid); @@ -78,7 +78,7 @@ void ApStateMachine::StationJoin(StationInfo &staInfo) void ApStateMachine::StationLeave(StationInfo &staInfo) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_STATION_LEAVE)); msg->AddStringMessageBody(staInfo.deviceName); msg->AddStringMessageBody(staInfo.bssid); @@ -88,7 +88,7 @@ void ApStateMachine::StationLeave(StationInfo &staInfo) void ApStateMachine::SetHotspotConfig(const HotspotConfig &cfg) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_SET_HOTSPOT_CONFIG)); msg->AddStringMessageBody(cfg.GetSsid()); msg->AddStringMessageBody(cfg.GetPreSharedKey()); @@ -101,7 +101,7 @@ void ApStateMachine::SetHotspotConfig(const HotspotConfig &cfg) void ApStateMachine::AddBlockList(const StationInfo &staInfo) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_ADD_BLOCK_LIST)); msg->AddStringMessageBody(staInfo.deviceName); msg->AddStringMessageBody(staInfo.bssid); @@ -111,7 +111,7 @@ void ApStateMachine::AddBlockList(const StationInfo &staInfo) void ApStateMachine::DelBlockList(const StationInfo &staInfo) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_DEL_BLOCK_LIST)); msg->AddStringMessageBody(staInfo.deviceName); msg->AddStringMessageBody(staInfo.bssid); @@ -121,7 +121,7 @@ void ApStateMachine::DelBlockList(const StationInfo &staInfo) void ApStateMachine::DisconnetStation(const StationInfo &staInfo) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_DISCONNECT_STATION)); msg->AddStringMessageBody(staInfo.deviceName); msg->AddStringMessageBody(staInfo.bssid); @@ -133,15 +133,5 @@ void ApStateMachine::UpdateHotspotConfigResult(const bool result) { SendMessage(static_cast(ApStatemachineEvent::CMD_UPDATE_HOTSPOTCONFIG_RESULT), result ? 1 : 0); } - -void ApStateMachine::OnQuitting() -{ - LOGI("[ApStateMachine] OnQuitting"); -} - -void ApStateMachine::OnHalting() -{ - LOGI("[ApStateMachine] OnHalting"); -} } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h index 8695f766058db27142f576e78ac5fdf112e18f86..2c4b37c97252565d2b8f64c2ea2f2635b475c88f 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h @@ -89,9 +89,6 @@ private: ApStateMachine(); virtual ~ApStateMachine(); void Init(); - virtual void OnQuitting() override; - virtual void OnHalting() override; - DISALLOW_COPY_AND_ASSIGN(ApStateMachine); private: diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_stub.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_stub.cpp index 771e3291c4c147641d03437131aae4c66e78c7ea..a46bd17817847b764a49bf34451a56872679e3ed 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_stub.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_stub.cpp @@ -136,12 +136,6 @@ void WifiDeviceStub::ReadWifiDeviceConfig(MessageParcel &data, WifiDeviceConfig config.wepTxKeyIndex = data.ReadInt32(); config.priority = data.ReadInt32(); config.hiddenSSID = data.ReadBool(); - config.isEnableWPAICertified = data.ReadBool(); - config.allowedKeyManagement = data.ReadInt32(); - config.allowedProtocols = data.ReadInt32(); - config.allowedAuthAlgorithms = data.ReadInt32(); - config.allowedPairwiseCiphers = data.ReadInt32(); - config.allowedGroupCiphers = data.ReadInt32(); config.wifiIpConfig.assignMethod = AssignIpMethod(data.ReadInt32()); ReadIpAddress(data, config.wifiIpConfig.staticIpAddress.ipAddress.address); config.wifiIpConfig.staticIpAddress.ipAddress.prefixLength = data.ReadInt32(); @@ -195,12 +189,6 @@ void WifiDeviceStub::WriteWifiDeviceConfig(MessageParcel &reply, const WifiDevic reply.WriteInt32(config.wepTxKeyIndex); reply.WriteInt32(config.priority); reply.WriteBool(config.hiddenSSID); - reply.WriteBool(config.isEnableWPAICertified); - reply.WriteInt32(config.allowedKeyManagement); - reply.WriteInt32(config.allowedProtocols); - reply.WriteInt32(config.allowedAuthAlgorithms); - reply.WriteInt32(config.allowedPairwiseCiphers); - reply.WriteInt32(config.allowedGroupCiphers); reply.WriteInt32((int)config.wifiIpConfig.assignMethod); WriteIpAddress(reply, config.wifiIpConfig.staticIpAddress.ipAddress.address); reply.WriteInt32(config.wifiIpConfig.staticIpAddress.ipAddress.prefixLength); diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp index efe3b0a7742b0b90b0a3a1883418d81e5b1d8823..d9694ba3277a180b210a5883068769784b8d6e13 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp @@ -147,7 +147,6 @@ int WifiManager::AddDeviceConfig(const WifiDeviceConfig &config, int &networkId) idlConfig.eap = config.wifiEapConfig.eap; idlConfig.identity = config.wifiEapConfig.identity; idlConfig.password = config.wifiEapConfig.password; - idlConfig.authAlgorithms = config.allowedAuthAlgorithms; idlConfig.wepKeyIdx = config.wepTxKeyIndex; for (int i = 0; i < MAX_WEPKEYS_SIZE; i++) { idlConfig.wepKeys[i] = config.wepKeys[i]; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_common.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_common.h index 992d0774de96832041fc5287b84f9ea775db43ec..33b9fa4431b86f72776388a44c385a6fa7ea0aeb 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_common.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_common.h @@ -93,7 +93,7 @@ struct StoreScanConfig { std::string ssid; /* Specifies the SSID in parameter scanning. */ std::string bssid; /* Specifies the BSSID carried in parameter scanning. */ std::vector scanFreqs; /* Only APs with specified frequencies are scanned. */ - long scanTime; /* Scan Start Time */ + int64_t scanTime; /* Scan Start Time */ bool fullScanFlag; /* Flag of scan without specifying parameters */ bool externFlag; /* Flag indicating whether the request is an external scan. */ @@ -178,7 +178,7 @@ struct InterScanResult { */ int frequency; /* Access point frequency */ int level; /* signal strength */ - long timestamp; /* Timestamp of scanning */ + int64_t timestamp; /* Timestamp of scanning */ InterScanResult() { diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp index 92bf2ac7e19e38667402aa0b18bf106b48ffb175..568541037049441aa51e4548a89aeaa28cc6b383 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp @@ -342,16 +342,16 @@ bool ScanService::SingleScan(ScanConfig &scanConfig) /* Construct a message */ InternalMessage *interMessage = - pScanStateMachine->ObtainMessage(static_cast(CMD_START_COMMON_SCAN), requestIndex); + pScanStateMachine->CreateMessage(static_cast(CMD_START_COMMON_SCAN), requestIndex); if (interMessage == nullptr) { scanConfigMap.erase(requestIndex); - LOGE("ObtainMessage failed.\n"); + LOGE("CreateMessage failed.\n"); return false; } if (!AddScanMessageBody(interMessage, interConfig)) { scanConfigMap.erase(requestIndex); - MessageManage::GetInstance().Recycle(interMessage); + MessageManage::GetInstance().ReclaimMsg(interMessage); LOGE("AddScanMessageBody failed.\n"); return false; } @@ -416,13 +416,13 @@ bool ScanService::AddScanMessageBody(InternalMessage *interMessage, const InterS interMessage->AddIntMessageBody(interConfig.hiddenNetworkSsid.size()); std::vector::const_iterator iter = interConfig.hiddenNetworkSsid.begin(); - for (; iter != interConfig.hiddenNetworkSsid.end(); iter++) { + for (; iter != interConfig.hiddenNetworkSsid.end(); ++iter) { interMessage->AddStringMessageBody(*iter); } interMessage->AddIntMessageBody(interConfig.scanFreqs.size()); std::vector::const_iterator iterFreq = interConfig.scanFreqs.begin(); - for (; iterFreq != interConfig.scanFreqs.end(); iterFreq++) { + for (; iterFreq != interConfig.scanFreqs.end(); ++iterFreq) { interMessage->AddIntMessageBody(*iterFreq); } @@ -464,7 +464,8 @@ int ScanService::StoreRequestScanConfig(const ScanConfig &scanConfig, const Inte struct timespec times = {0, 0}; clock_gettime(CLOCK_MONOTONIC, ×); - storeScanConfig.scanTime = times.tv_sec * SECOND_TO_MICRO_SECOND + times.tv_nsec / SECOND_TO_MILLI_SECOND; + storeScanConfig.scanTime = + static_cast(times.tv_sec) * SECOND_TO_MICRO_SECOND + times.tv_nsec / SECOND_TO_MILLI_SECOND; storeScanConfig.fullScanFlag = scanConfig.fullScanFlag; storeScanConfig.externFlag = scanConfig.externFlag; @@ -477,7 +478,7 @@ void ScanService::HandleCommonScanFailed(std::vector &requestIndexList) { LOGI("Enter ScanService::HandleCommonScanFailed.\n"); - for (std::vector::iterator reqIter = requestIndexList.begin(); reqIter != requestIndexList.end(); reqIter++) { + for (std::vector::iterator reqIter = requestIndexList.begin(); reqIter != requestIndexList.end(); ++reqIter) { ScanConfigMap::iterator configIter = scanConfigMap.find(*reqIter); /* No configuration found. */ if (configIter == scanConfigMap.end()) { @@ -504,7 +505,7 @@ void ScanService::HandleCommonScanResult( bool fullScanInclude = false; bool fullScanStored = false; - for (std::vector::iterator reqIter = requestIndexList.begin(); reqIter != requestIndexList.end(); reqIter++) { + for (std::vector::iterator reqIter = requestIndexList.begin(); reqIter != requestIndexList.end(); ++reqIter) { ScanConfigMap::iterator configIter = scanConfigMap.find(*reqIter); /* No configuration found. */ if (configIter == scanConfigMap.end()) { @@ -537,7 +538,7 @@ void ScanService::HandleCommonScanResult( /* Send the scanning result to the module registered for listening */ ScanResultHandlerMap::iterator handleIter = scanResultHandlerMap.begin(); - for (; handleIter != scanResultHandlerMap.end(); handleIter++) { + for (; handleIter != scanResultHandlerMap.end(); ++handleIter) { if (handleIter->second) { handleIter->second(scanResultList); } @@ -555,11 +556,11 @@ bool ScanService::StoreFullScanResult( LOGI("Enter ScanService::StoreFullScanResult.\n"); /* Filtering result */ - LOGI("scanConfig.scanTime is %ld.\n", scanConfig.scanTime); + LOGI("scanConfig.scanTime is %lld.\n", scanConfig.scanTime); LOGI("Receive %{public}d scan results.\n", (int)(scanResultList.size())); std::vector filterScanResult; std::vector::const_iterator iter = scanResultList.begin(); - for (; iter != scanResultList.end(); iter++) { + for (; iter != scanResultList.end(); ++iter) { char tmpBuf[128] = ""; EncryptLogMsg(iter->ssid.c_str(), tmpBuf, sizeof(tmpBuf)); WifiScanInfo scanInfo; @@ -589,7 +590,7 @@ bool ScanService::StoreUserScanResult( /* Filtering result */ std::vector filterScanResult; std::vector::const_iterator iter = scanResultList.begin(); - for (; iter != scanResultList.end(); iter++) { + for (; iter != scanResultList.end(); ++iter) { /* Timestamp filtering */ if ((iter->timestamp) <= scanConfig.scanTime) { continue; @@ -654,7 +655,7 @@ void ScanService::ConvertScanResults( /* Filtering result */ std::vector::const_iterator iter = scanResultList.begin(); - for (; iter != scanResultList.end(); iter++) { + for (; iter != scanResultList.end(); ++iter) { WifiScanInfo scanInfo; scanInfo.bssid = iter->bssid; scanInfo.ssid = iter->ssid; @@ -731,20 +732,20 @@ bool ScanService::PnoScan(const PnoScanConfig &pnoScanConfig, const InterScanCon LOGI("Enter ScanService::PnoScan.\n"); /* Construct a message. */ - InternalMessage *interMessage = pScanStateMachine->ObtainMessage(CMD_START_PNO_SCAN); + InternalMessage *interMessage = pScanStateMachine->CreateMessage(CMD_START_PNO_SCAN); if (interMessage == nullptr) { - LOGE("ObtainMessage failed.\n"); + LOGE("CreateMessage failed.\n"); return false; } if (!AddPnoScanMessageBody(interMessage, pnoScanConfig)) { - MessageManage::GetInstance().Recycle(interMessage); + MessageManage::GetInstance().ReclaimMsg(interMessage); LOGE("AddPnoScanMessageBody failed.\n"); return false; } if (!AddScanMessageBody(interMessage, interScanConfig)) { - MessageManage::GetInstance().Recycle(interMessage); + MessageManage::GetInstance().ReclaimMsg(interMessage); LOGE("AddScanMessageBody failed.\n"); return false; } @@ -755,7 +756,8 @@ bool ScanService::PnoScan(const PnoScanConfig &pnoScanConfig, const InterScanCon struct timespec times = {0, 0}; clock_gettime(CLOCK_MONOTONIC, ×); - pnoScanStartTime = times.tv_sec * SECOND_TO_MILLI_SECOND + times.tv_nsec / SECOND_TO_MICRO_SECOND; + pnoScanStartTime = + static_cast(times.tv_sec) * SECOND_TO_MILLI_SECOND + times.tv_nsec / SECOND_TO_MICRO_SECOND; return true; } @@ -775,19 +777,19 @@ bool ScanService::AddPnoScanMessageBody(InternalMessage *interMessage, const Pno interMessage->AddIntMessageBody(pnoScanConfig.hiddenNetworkSsid.size()); std::vector::const_iterator iter = pnoScanConfig.hiddenNetworkSsid.begin(); - for (; iter != pnoScanConfig.hiddenNetworkSsid.end(); iter++) { + for (; iter != pnoScanConfig.hiddenNetworkSsid.end(); ++iter) { interMessage->AddStringMessageBody(*iter); } interMessage->AddIntMessageBody(pnoScanConfig.savedNetworkSsid.size()); std::vector::const_iterator iter2 = pnoScanConfig.savedNetworkSsid.begin(); - for (; iter2 != pnoScanConfig.savedNetworkSsid.end(); iter2++) { + for (; iter2 != pnoScanConfig.savedNetworkSsid.end(); ++iter2) { interMessage->AddStringMessageBody(*iter2); } interMessage->AddIntMessageBody(pnoScanConfig.freqs.size()); std::vector::const_iterator iter3 = pnoScanConfig.freqs.begin(); - for (; iter3 != pnoScanConfig.freqs.end(); iter3++) { + for (; iter3 != pnoScanConfig.freqs.end(); ++iter3) { interMessage->AddIntMessageBody(*iter3); } @@ -800,7 +802,7 @@ void ScanService::HandlePnoScanResult(std::vector &scanResultLi std::vector filterScanResult; std::vector::iterator iter = scanResultList.begin(); - for (; iter != scanResultList.end(); iter++) { + for (; iter != scanResultList.end(); ++iter) { if ((iter->timestamp / SECOND_TO_MILLI_SECOND) > pnoScanStartTime) { filterScanResult.push_back(*iter); LOGI("InterScanResult.bssid is %s.\n", iter->bssid.c_str()); @@ -808,13 +810,13 @@ void ScanService::HandlePnoScanResult(std::vector &scanResultLi LOGI("InterScanResult.capabilities is %{public}s.\n", iter->capabilities.c_str()); LOGI("InterScanResult.frequency is %{public}d.\n", iter->frequency); LOGI("InterScanResult.level is %{public}d.\n", iter->level); - LOGI("InterScanResult.timestamp is %ld.\n", iter->timestamp); + LOGI("InterScanResult.timestamp is %lld.\n", iter->timestamp); } } /* Send the scanning result to the module registered for listening */ PnoScanResultHandlerMap::iterator handleIter = pnoScanResultHandlerMap.begin(); - for (; handleIter != pnoScanResultHandlerMap.end(); handleIter++) { + for (; handleIter != pnoScanResultHandlerMap.end(); ++handleIter) { if (handleIter->second) { handleIter->second(filterScanResult); } @@ -878,7 +880,7 @@ void ScanService::SystemScanProcess(bool scanAtOnce) LOGD("isScreenOn is:%{public}d", isScreenOn); if (isScreenOn) { for (auto iter = scanControlInfo.scanIntervalList.begin(); iter != scanControlInfo.scanIntervalList.end(); - iter++) { + ++iter) { if (iter->scanScene == SCAN_SCENE_ALL && iter->scanMode == ScanMode::SYSTEM_TIMER_SCAN && iter->isSingle == false) { LOGD("iter->intervalMode is:%{public}d", iter->intervalMode); @@ -922,7 +924,8 @@ void ScanService::StartSystemTimerScan(bool scanAtOnce) struct timespec times = {0, 0}; clock_gettime(CLOCK_MONOTONIC, ×); - long nowTime = times.tv_sec * SECOND_TO_MILLI_SECOND + times.tv_nsec / SECOND_TO_MICRO_SECOND; + int64_t nowTime = + static_cast(times.tv_sec) * SECOND_TO_MILLI_SECOND + times.tv_nsec / SECOND_TO_MICRO_SECOND; int sinceLastScan = 0; if (lastSystemScanTime != 0) { sinceLastScan = nowTime - lastSystemScanTime; @@ -1113,7 +1116,7 @@ bool ScanService::AllowSystemTimerScan() return false; } - for (auto iter = scanControlInfo.scanIntervalList.begin(); iter != scanControlInfo.scanIntervalList.end(); iter++) { + for (auto iter = scanControlInfo.scanIntervalList.begin(); iter != scanControlInfo.scanIntervalList.end(); ++iter) { if (iter->scanScene == SCAN_SCENE_ALL && iter->scanMode == ScanMode::SYSTEM_TIMER_SCAN && iter->isSingle == false) { if (!SystemScanByInterval(systemScanIntervalMode.expScanCount, @@ -1149,7 +1152,7 @@ bool ScanService::AllowPnoScan() return false; } - for (auto iter = scanControlInfo.scanIntervalList.begin(); iter != scanControlInfo.scanIntervalList.end(); iter++) { + for (auto iter = scanControlInfo.scanIntervalList.begin(); iter != scanControlInfo.scanIntervalList.end(); ++iter) { if (iter->scanScene == SCAN_SCENE_ALL && iter->scanMode == ScanMode::PNO_SCAN && iter->isSingle == false) { pnoScanIntervalMode.scanIntervalMode.intervalMode = iter->intervalMode; pnoScanIntervalMode.scanIntervalMode.interval = iter->interval; @@ -1254,7 +1257,7 @@ bool ScanService::IsExternScanning() { LOGI("Enter ScanService::IsExternScanning.\n"); - for (auto iter = scanConfigMap.begin(); iter != scanConfigMap.end(); iter++) { + for (auto iter = scanConfigMap.begin(); iter != scanConfigMap.end(); ++iter) { if (iter->second.externFlag) { return true; } @@ -1284,7 +1287,7 @@ void ScanService::GetAllowBandFreqsControlInfo(ScanBandType &scanBand, std::vect } auto forbidIter = scanControlInfo.scanForbidMap.find(SCAN_SCENE_ALL); if (forbidIter != scanControlInfo.scanForbidMap.end()) { - for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); iter++) { + for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); ++iter) { if (iter->scanMode == ScanMode::BAND_24GHZ_SCAN) { allow24Ghz = false; } @@ -1365,7 +1368,7 @@ void ScanService::Delete24GhzFreqs(std::vector &freqs) if (*iter < FREQS_24G_MAX_VALUE) { freqs.erase(iter); } else { - iter++; + ++iter; } } @@ -1381,7 +1384,7 @@ void ScanService::Delete5GhzFreqs(std::vector &freqs) if (*iter > FREQS_5G_MIN_VALUE) { freqs.erase(iter); } else { - iter++; + ++iter; } } @@ -1398,7 +1401,7 @@ bool ScanService::GetSavedNetworkSsidList(std::vector &savedNetwork return false; } - for (auto iter = deviceConfigs.begin(); iter != deviceConfigs.end(); iter++) { + for (auto iter = deviceConfigs.begin(); iter != deviceConfigs.end(); ++iter) { if ((iter->status == static_cast(WifiDeviceConfigStatus::ENABLED)) && (!(iter->isPasspoint)) && (!(iter->isEphemeral))) { savedNetworkSsid.push_back(iter->ssid); @@ -1418,7 +1421,7 @@ bool ScanService::GetHiddenNetworkSsidList(std::vector &hiddenNetwo return false; } - for (auto iter = deviceConfigs.begin(); iter != deviceConfigs.end(); iter++) { + for (auto iter = deviceConfigs.begin(); iter != deviceConfigs.end(); ++iter) { if (iter->hiddenSSID) { hiddenNetworkSsid.push_back(iter->ssid); } @@ -1467,7 +1470,7 @@ bool ScanService::AllowScanDuringScanning(ScanMode scanMode) auto forbidIter = scanControlInfo.scanForbidMap.find(SCAN_SCENE_SCANNING); if (forbidIter != scanControlInfo.scanForbidMap.end()) { - for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); iter++) { + for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); ++iter) { if (iter->scanMode == scanMode) { return false; } @@ -1482,7 +1485,7 @@ bool ScanService::AllowScanDuringScreenOff(ScanMode scanMode) auto forbidIter = scanControlInfo.scanForbidMap.find(SCAN_SCENE_SCREEN_OFF); if (forbidIter != scanControlInfo.scanForbidMap.end()) { - for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); iter++) { + for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); ++iter) { if (iter->scanMode == scanMode) { return false; } @@ -1499,7 +1502,7 @@ bool ScanService::AllowScanDuringStaScene(int staScene, ScanMode scanMode) auto forbidIter = scanControlInfo.scanForbidMap.find(staScene); if (forbidIter != scanControlInfo.scanForbidMap.end()) { - for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); iter++) { + for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); ++iter) { /* forbid scan mode found in scan scene */ if (iter->scanMode == scanMode) { /* Unconditional scan control for forbidCount times */ @@ -1527,10 +1530,10 @@ bool ScanService::AllowScanDuringCustomScene(ScanMode scanMode) time_t now = time(0); auto customIter = customSceneTimeMap.begin(); - for (; customIter != customSceneTimeMap.end(); customIter++) { + for (; customIter != customSceneTimeMap.end(); ++customIter) { auto forbidIter = scanControlInfo.scanForbidMap.find(customIter->first); if (forbidIter != scanControlInfo.scanForbidMap.end()) { - for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); iter++) { + for (auto iter = forbidIter->second.begin(); iter != forbidIter->second.end(); ++iter) { /* forbid scan mode found in scan scene */ if (iter->scanMode == scanMode) { /* Unconditional scan control for forbidCount times */ @@ -1559,7 +1562,7 @@ bool ScanService::AllowExternScanByIntervalMode(int appId, int scanScene, ScanMo for (auto intervalListIter = scanControlInfo.scanIntervalList.begin(); intervalListIter != scanControlInfo.scanIntervalList.end(); - intervalListIter++) { + ++intervalListIter) { LOGD("scanScene:%{public}d, scanMode:%{public}d", intervalListIter->scanScene, intervalListIter->scanMode); /* Determine whether control is required in the current scene and scan mode. */ if (intervalListIter->scanScene == scanScene && intervalListIter->scanMode == scanMode) { @@ -1584,10 +1587,10 @@ bool ScanService::AllowExternScanByCustomScene(int appId, ScanMode scanMode) LOGI("Enter ScanService::AllowExternScanByCustomScene.\n"); auto customIter = customSceneTimeMap.begin(); - for (; customIter != customSceneTimeMap.end(); customIter++) { + for (; customIter != customSceneTimeMap.end(); ++customIter) { for (auto intervalListIter = scanControlInfo.scanIntervalList.begin(); intervalListIter != scanControlInfo.scanIntervalList.end(); - intervalListIter++) { + ++intervalListIter) { /* Determine whether control is required in the current scene and scan mode. */ if (intervalListIter->scanScene == customIter->first && intervalListIter->scanMode == scanMode) { /* If a single application is distinguished */ @@ -1612,7 +1615,7 @@ bool ScanService::AllowSingleAppScanByInterval(int appId, ScanIntervalMode scanI LOGI("Enter ScanService::AllowSingleAppScan.\n"); bool appIdExisted = false; - for (auto forbidListIter = appForbidList.begin(); forbidListIter != appForbidList.end(); forbidListIter++) { + for (auto forbidListIter = appForbidList.begin(); forbidListIter != appForbidList.end(); ++forbidListIter) { if (forbidListIter->appID == appId && forbidListIter->scanIntervalMode.scanScene == scanIntervalMode.scanScene && forbidListIter->scanIntervalMode.scanMode == scanIntervalMode.scanMode) { @@ -1630,7 +1633,7 @@ bool ScanService::AllowSingleAppScanByInterval(int appId, ScanIntervalMode scanI singleAppForbid.scanIntervalMode.count = scanIntervalMode.count; appForbidList.push_back(singleAppForbid); } - for (auto iter = appForbidList.begin(); iter != appForbidList.end(); iter++) { + for (auto iter = appForbidList.begin(); iter != appForbidList.end(); ++iter) { if (iter->appID == appId && iter->scanIntervalMode.scanScene == scanIntervalMode.scanScene && iter->scanIntervalMode.scanMode == scanIntervalMode.scanMode) { if (!ExternScanByInterval(appId, *iter)) { @@ -1647,7 +1650,7 @@ bool ScanService::AllowFullAppScanByInterval(int appId, ScanIntervalMode scanInt bool fullAppExisted = false; for (auto fullAppForbidIter = fullAppForbidList.begin(); fullAppForbidIter != fullAppForbidList.end(); - fullAppForbidIter++) { + ++fullAppForbidIter) { if (fullAppForbidIter->scanIntervalMode.scanScene == scanIntervalMode.scanScene && fullAppForbidIter->scanIntervalMode.scanMode == scanIntervalMode.scanMode) { fullAppExisted = true; @@ -1662,7 +1665,7 @@ bool ScanService::AllowFullAppScanByInterval(int appId, ScanIntervalMode scanInt singleAppForbid.scanIntervalMode.count = scanIntervalMode.count; fullAppForbidList.push_back(singleAppForbid); } - for (auto iter = fullAppForbidList.begin(); iter != fullAppForbidList.end(); iter++) { + for (auto iter = fullAppForbidList.begin(); iter != fullAppForbidList.end(); ++iter) { if (iter->scanIntervalMode.scanScene == scanIntervalMode.scanScene && iter->scanIntervalMode.scanMode == scanIntervalMode.scanMode) { if (!ExternScanByInterval(appId, *iter)) { diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h index f4de049d77a4bddfab519258b8418a954b910e46..87d55cd414c6bdd049ef75237e17a58da2576993 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h @@ -184,12 +184,12 @@ private: PnoScanResultHandlerMap pnoScanResultHandlerMap; /* Map of obtaining PNO scanning results */ ScanConfigMap scanConfigMap; /* Save Scan Configuration */ int scanConfigStoreIndex; /* Index for saving the scan configuration */ - long pnoScanStartTime; /* PNO scanning start time */ + int64_t pnoScanStartTime; /* PNO scanning start time */ bool isScreenOn; /* Screen state */ int staStatus; /* STA state */ bool isPnoScanBegined; /* The PNO scanning has been started */ bool autoNetworkSelection; /* Automatic network selection */ - long lastSystemScanTime; /* Last System Scan Time */ + int64_t lastSystemScanTime; /* Last System Scan Time */ int pnoScanFailedNum; /* Number of PNO Scan Failures */ ScanControlInfo scanControlInfo; /* Scan Control Policy */ int operateAppMode; /* Operation app type */ diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp index 088020c89189572ca9efea5561336eb5269bbffc..175cc06586a914fcc46244d24172c1f6b95e5cc0 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp @@ -115,8 +115,8 @@ bool ScanStateMachine::InitScanStateMachine() }; BuildScanStateTree(); - SetInitialState(initState); - Start(); + SetFirstState(initState); + StartStateMachine(); return true; } @@ -141,9 +141,9 @@ ScanStateMachine::InitState::InitState(ScanStateMachine *paraScanStateMachine) : ScanStateMachine::InitState::~InitState() {} -void ScanStateMachine::InitState::Enter() +void ScanStateMachine::InitState::GoInState() { - LOGI("Enter ScanStateMachine::InitState::Enter.\n"); + LOGI("Enter ScanStateMachine::InitState::GoInState.\n"); pScanStateMachine->runningScans.clear(); pScanStateMachine->waitingScans.clear(); @@ -154,15 +154,15 @@ void ScanStateMachine::InitState::Enter() return; } -void ScanStateMachine::InitState::Exit() +void ScanStateMachine::InitState::GoOutState() { - LOGI("Enter ScanStateMachine::InitState::Exit.\n"); + LOGI("Enter ScanStateMachine::InitState::GoOutState.\n"); return; } -bool ScanStateMachine::InitState::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::InitState::ExecuteStateMsg(InternalMessage *msg) { - LOGI("Enter ScanStateMachine::InitState::ProcessMessage.\n"); + LOGI("Enter ScanStateMachine::InitState::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -178,7 +178,7 @@ bool ScanStateMachine::InitState::ProcessMessage(InternalMessage *msg) return true; case CMD_START_COMMON_SCAN: - pScanStateMachine->ReportCommonScanFailed(msg->GetArg1()); + pScanStateMachine->ReportCommonScanFailed(msg->GetParam1()); return true; case CMD_START_PNO_SCAN: @@ -191,12 +191,12 @@ bool ScanStateMachine::InitState::ProcessMessage(InternalMessage *msg) return true; case HARDWARE_LOAD_EVENT: - pScanStateMachine->TransitionTo(pScanStateMachine->hardwareReadyState); + pScanStateMachine->SwitchState(pScanStateMachine->hardwareReadyState); pScanStateMachine->ReportStatusChange(SCAN_STARTED_STATUS); return true; case HARDWARE_UNLOAD_EVENT: - pScanStateMachine->TransitionTo(pScanStateMachine->initState); + pScanStateMachine->SwitchState(pScanStateMachine->initState); pScanStateMachine->quitFlag = true; return true; @@ -226,21 +226,21 @@ ScanStateMachine::HardwareReady::HardwareReady(ScanStateMachine *paraScanStateMa ScanStateMachine::HardwareReady::~HardwareReady() {} -void ScanStateMachine::HardwareReady::Enter() +void ScanStateMachine::HardwareReady::GoInState() { - LOGI("Enter ScanStateMachine::HardwareReady::Enter.\n"); + LOGI("Enter ScanStateMachine::HardwareReady::GoInState.\n"); return; } -void ScanStateMachine::HardwareReady::Exit() +void ScanStateMachine::HardwareReady::GoOutState() { - LOGI("Enter ScanStateMachine::HardwareReady::Exit.\n"); + LOGI("Enter ScanStateMachine::HardwareReady::GoOutState.\n"); return; } -bool ScanStateMachine::HardwareReady::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::HardwareReady::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::HardwareReady::ProcessMessage.\n"); + LOGI("ScanStateMachine::HardwareReady::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -268,22 +268,22 @@ ScanStateMachine::CommonScan::CommonScan(ScanStateMachine *paraScanStateMachine) ScanStateMachine::CommonScan::~CommonScan() {} -void ScanStateMachine::CommonScan::Enter() +void ScanStateMachine::CommonScan::GoInState() { - LOGI("Enter ScanStateMachine::CommonScan::Enter.\n"); + LOGI("Enter ScanStateMachine::CommonScan::GoInState.\n"); return; } -void ScanStateMachine::CommonScan::Exit() +void ScanStateMachine::CommonScan::GoOutState() { - LOGI("Enter ScanStateMachine::CommonScan::Exit.\n"); + LOGI("Enter ScanStateMachine::CommonScan::GoOutState.\n"); pScanStateMachine->ReportCommonScanFailedAndClear(false); return; } -bool ScanStateMachine::CommonScan::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::CommonScan::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::CommonScan::ProcessMessage.\n"); + LOGI("ScanStateMachine::CommonScan::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -291,7 +291,7 @@ bool ScanStateMachine::CommonScan::ProcessMessage(InternalMessage *msg) switch (msg->GetMessageName()) { case CMD_STOP_COMMON_SCAN: - pScanStateMachine->RemoveCommonScanRequest(msg->GetArg1()); + pScanStateMachine->RemoveCommonScanRequest(msg->GetParam1()); return true; default: @@ -308,22 +308,22 @@ ScanStateMachine::CommonScanUnworked::CommonScanUnworked(ScanStateMachine *paraS ScanStateMachine::CommonScanUnworked::~CommonScanUnworked() {} -void ScanStateMachine::CommonScanUnworked::Enter() +void ScanStateMachine::CommonScanUnworked::GoInState() { - LOGI("Enter ScanStateMachine::CommonScanUnworked::Enter.\n"); + LOGI("Enter ScanStateMachine::CommonScanUnworked::GoInState.\n"); pScanStateMachine->StartNewCommonScan(); return; } -void ScanStateMachine::CommonScanUnworked::Exit() +void ScanStateMachine::CommonScanUnworked::GoOutState() { - LOGI("Enter ScanStateMachine::CommonScanUnworked::Exit.\n"); + LOGI("Enter ScanStateMachine::CommonScanUnworked::GoOutState.\n"); return; } -bool ScanStateMachine::CommonScanUnworked::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::CommonScanUnworked::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::CommonScanUnworked::ProcessMessage.\n"); + LOGI("ScanStateMachine::CommonScanUnworked::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -352,15 +352,15 @@ ScanStateMachine::CommonScanning::CommonScanning(ScanStateMachine *paraScanState ScanStateMachine::CommonScanning::~CommonScanning() {} -void ScanStateMachine::CommonScanning::Enter() +void ScanStateMachine::CommonScanning::GoInState() { - LOGI("Enter ScanStateMachine::CommonScanning::Enter.\n"); + LOGI("Enter ScanStateMachine::CommonScanning::GoInState.\n"); return; } -void ScanStateMachine::CommonScanning::Exit() +void ScanStateMachine::CommonScanning::GoOutState() { - LOGI("Enter ScanStateMachine::CommonScanning::Exit.\n"); + LOGI("Enter ScanStateMachine::CommonScanning::GoOutState.\n"); pScanStateMachine->ClearRunningScanSettings(); pScanStateMachine->ReportCommonScanFailedAndClear(true); pScanStateMachine->StopTimer(int(WAIT_SCAN_RESULT_TIMER)); @@ -372,9 +372,9 @@ void ScanStateMachine::CommonScanning::Exit() * @param msg - Internal message class, which is used to send messages to the state machine.[in] * @return success: true, failed: false */ -bool ScanStateMachine::CommonScanning::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::CommonScanning::ExecuteStateMsg(InternalMessage *msg) { - LOGI("Enter ScanStateMachine::CommonScanning::ProcessMessage.\n"); + LOGI("Enter ScanStateMachine::CommonScanning::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -387,19 +387,19 @@ bool ScanStateMachine::CommonScanning::ProcessMessage(InternalMessage *msg) case SCAN_RESULT_EVENT: pScanStateMachine->CommonScanResultProcess(); - pScanStateMachine->TransitionTo(pScanStateMachine->commonScanUnworkedState); + pScanStateMachine->SwitchState(pScanStateMachine->commonScanUnworkedState); return true; case SCAN_FAILED_EVENT: LOGE("scan failed."); pScanStateMachine->ReportCommonScanFailedAndClear(true); - pScanStateMachine->TransitionTo(pScanStateMachine->commonScanUnworkedState); + pScanStateMachine->SwitchState(pScanStateMachine->commonScanUnworkedState); return true; case WAIT_SCAN_RESULT_TIMER: LOGE("get scan result time out."); pScanStateMachine->ReportCommonScanFailedAndClear(true); - pScanStateMachine->TransitionTo(pScanStateMachine->commonScanUnworkedState); + pScanStateMachine->SwitchState(pScanStateMachine->commonScanUnworkedState); return true; /* @@ -408,7 +408,7 @@ bool ScanStateMachine::CommonScanning::ProcessMessage(InternalMessage *msg) */ case CMD_START_PNO_SCAN: case CMD_RESTART_PNO_SCAN: - pScanStateMachine->DeferMessage(msg); + pScanStateMachine->DelayMessage(msg); return true; default: @@ -424,22 +424,22 @@ ScanStateMachine::PnoScan::PnoScan(ScanStateMachine *paraScanStateMachine) : Sta ScanStateMachine::PnoScan::~PnoScan() {} -void ScanStateMachine::PnoScan::Enter() +void ScanStateMachine::PnoScan::GoInState() { - LOGI("Enter ScanStateMachine::PnoScan::Enter.\n"); + LOGI("Enter ScanStateMachine::PnoScan::GoInState.\n"); return; } -void ScanStateMachine::PnoScan::Exit() +void ScanStateMachine::PnoScan::GoOutState() { - LOGI("Enter ScanStateMachine::PnoScan::Exit.\n"); + LOGI("Enter ScanStateMachine::PnoScan::GoOutState.\n"); pScanStateMachine->StopPnoScanHardware(); return; } -bool ScanStateMachine::PnoScan::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::PnoScan::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::PnoScan::ProcessMessage.\n"); + LOGI("ScanStateMachine::PnoScan::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); } @@ -455,9 +455,9 @@ ScanStateMachine::PnoScanHardware::PnoScanHardware(ScanStateMachine *paraScanSta ScanStateMachine::PnoScanHardware::~PnoScanHardware() {} -void ScanStateMachine::PnoScanHardware::Enter() +void ScanStateMachine::PnoScanHardware::GoInState() { - LOGI("Enter ScanStateMachine::PnoScanHardware::Enter.\n"); + LOGI("Enter ScanStateMachine::PnoScanHardware::GoInState.\n"); if (!pScanStateMachine->StartPnoScanHardware()) { LOGE("StartPnoScanHardware failed."); return; @@ -465,15 +465,15 @@ void ScanStateMachine::PnoScanHardware::Enter() return; } -void ScanStateMachine::PnoScanHardware::Exit() +void ScanStateMachine::PnoScanHardware::GoOutState() { - LOGI("Enter ScanStateMachine::PnoScanHardware::Exit.\n"); + LOGI("Enter ScanStateMachine::PnoScanHardware::GoOutState.\n"); return; } -bool ScanStateMachine::PnoScanHardware::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::PnoScanHardware::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::PnoScanHardware::ProcessMessage.\n"); + LOGI("ScanStateMachine::PnoScanHardware::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -499,8 +499,8 @@ bool ScanStateMachine::PnoScanHardware::ProcessMessage(InternalMessage *msg) return true; case CMD_START_COMMON_SCAN: - pScanStateMachine->DeferMessage(msg); - pScanStateMachine->TransitionTo(pScanStateMachine->hardwareReadyState); + pScanStateMachine->DelayMessage(msg); + pScanStateMachine->SwitchState(pScanStateMachine->hardwareReadyState); return true; default: @@ -518,16 +518,16 @@ ScanStateMachine::CommonScanAfterPno::CommonScanAfterPno(ScanStateMachine *paraS ScanStateMachine::CommonScanAfterPno::~CommonScanAfterPno() {} -void ScanStateMachine::CommonScanAfterPno::Enter() +void ScanStateMachine::CommonScanAfterPno::GoInState() { - LOGI("Enter ScanStateMachine::CommonScanAfterPno::Enter.\n"); + LOGI("Enter ScanStateMachine::CommonScanAfterPno::GoInState.\n"); pScanStateMachine->CommonScanAfterPnoProcess(); return; } -void ScanStateMachine::CommonScanAfterPno::Exit() +void ScanStateMachine::CommonScanAfterPno::GoOutState() { - LOGI("Enter ScanStateMachine::CommonScanAfterPno::Exit.\n"); + LOGI("Enter ScanStateMachine::CommonScanAfterPno::GoOutState.\n"); if (!pScanStateMachine->remainWaitResultTimer) { pScanStateMachine->StopTimer(static_cast(WAIT_SCAN_RESULT_TIMER)); } @@ -536,9 +536,9 @@ void ScanStateMachine::CommonScanAfterPno::Exit() return; } -bool ScanStateMachine::CommonScanAfterPno::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::CommonScanAfterPno::ExecuteStateMsg(InternalMessage *msg) { - LOGI("ScanStateMachine::CommonScanAfterPno::ProcessMessage.\n"); + LOGI("ScanStateMachine::CommonScanAfterPno::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -547,12 +547,12 @@ bool ScanStateMachine::CommonScanAfterPno::ProcessMessage(InternalMessage *msg) switch (msg->GetMessageName()) { case SCAN_RESULT_EVENT: pScanStateMachine->CommonScanAfterPnoResult(); - pScanStateMachine->TransitionTo(pScanStateMachine->pnoScanHardwareState); + pScanStateMachine->SwitchState(pScanStateMachine->pnoScanHardwareState); return true; case SCAN_FAILED_EVENT: case WAIT_SCAN_RESULT_TIMER: - pScanStateMachine->TransitionTo(pScanStateMachine->pnoScanHardwareState); + pScanStateMachine->SwitchState(pScanStateMachine->pnoScanHardwareState); return true; case CMD_START_PNO_SCAN: @@ -566,8 +566,8 @@ bool ScanStateMachine::CommonScanAfterPno::ProcessMessage(InternalMessage *msg) * the status is changed */ case CMD_START_COMMON_SCAN: - pScanStateMachine->DeferMessage(msg); - pScanStateMachine->TransitionTo(pScanStateMachine->commonScanningState); + pScanStateMachine->DelayMessage(msg); + pScanStateMachine->SwitchState(pScanStateMachine->commonScanningState); pScanStateMachine->remainWaitResultTimer = true; return true; @@ -588,9 +588,9 @@ ScanStateMachine::PnoScanSoftware::PnoScanSoftware(ScanStateMachine *paraScanSta ScanStateMachine::PnoScanSoftware::~PnoScanSoftware() {} -void ScanStateMachine::PnoScanSoftware::Enter() +void ScanStateMachine::PnoScanSoftware::GoInState() { - LOGI("Enter ScanStateMachine::PnoScanSoftware::Enter.\n"); + LOGI("Enter ScanStateMachine::PnoScanSoftware::GoInState.\n"); LOGI("Start scan first!"); if (!pScanStateMachine->StartNewSoftwareScan()) { @@ -599,16 +599,16 @@ void ScanStateMachine::PnoScanSoftware::Enter() return; } -void ScanStateMachine::PnoScanSoftware::Exit() +void ScanStateMachine::PnoScanSoftware::GoOutState() { - LOGI("Enter ScanStateMachine::PnoScanSoftware::Exit.\n"); + LOGI("Enter ScanStateMachine::PnoScanSoftware::GoOutState.\n"); pScanStateMachine->StopTimer(static_cast(SOFTWARE_PNO_SCAN_TIMER)); return; } -bool ScanStateMachine::PnoScanSoftware::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::PnoScanSoftware::ExecuteStateMsg(InternalMessage *msg) { - LOGI("Enter ScanStateMachine::PnoScanSoftware::ProcessMessage.\n"); + LOGI("Enter ScanStateMachine::PnoScanSoftware::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); @@ -633,21 +633,21 @@ ScanStateMachine::PnoSwScanFree::PnoSwScanFree(ScanStateMachine *paraScanStateMa ScanStateMachine::PnoSwScanFree::~PnoSwScanFree() {} -void ScanStateMachine::PnoSwScanFree::Enter() +void ScanStateMachine::PnoSwScanFree::GoInState() { - LOGI("Enter ScanStateMachine::PnoSwScanFree::Enter.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanFree::GoInState.\n"); return; } -void ScanStateMachine::PnoSwScanFree::Exit() +void ScanStateMachine::PnoSwScanFree::GoOutState() { - LOGI("Enter ScanStateMachine::PnoSwScanFree::Exit.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanFree::GoOutState.\n"); return; } -bool ScanStateMachine::PnoSwScanFree::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::PnoSwScanFree::ExecuteStateMsg(InternalMessage *msg) { - LOGI("Enter ScanStateMachine::PnoSwScanFree::ProcessMessage.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanFree::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); @@ -663,8 +663,8 @@ bool ScanStateMachine::PnoSwScanFree::ProcessMessage(InternalMessage *msg) pScanStateMachine->PnoScanSoftwareProcess(msg); return true; case CMD_START_COMMON_SCAN: - pScanStateMachine->DeferMessage(msg); - pScanStateMachine->TransitionTo(pScanStateMachine->hardwareReadyState); + pScanStateMachine->DelayMessage(msg); + pScanStateMachine->SwitchState(pScanStateMachine->hardwareReadyState); return true; case SOFTWARE_PNO_SCAN_TIMER: LOGI("softwarePno scanscanInterval is %{public}d.\n", pScanStateMachine->runningPnoScanConfig.scanInterval); @@ -689,22 +689,22 @@ ScanStateMachine::PnoSwScanning::PnoSwScanning(ScanStateMachine *paraScanStateMa ScanStateMachine::PnoSwScanning::~PnoSwScanning() {} -void ScanStateMachine::PnoSwScanning::Enter() +void ScanStateMachine::PnoSwScanning::GoInState() { - LOGI("Enter ScanStateMachine::PnoSwScanning::Enter.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanning::GoInState.\n"); return; } -void ScanStateMachine::PnoSwScanning::Exit() +void ScanStateMachine::PnoSwScanning::GoOutState() { - LOGI("Enter ScanStateMachine::PnoSwScanning::Exit.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanning::GoOutState.\n"); pScanStateMachine->StopTimer(static_cast(WAIT_SCAN_RESULT_TIMER)); return; } -bool ScanStateMachine::PnoSwScanning::ProcessMessage(InternalMessage *msg) +bool ScanStateMachine::PnoSwScanning::ExecuteStateMsg(InternalMessage *msg) { - LOGI("Enter ScanStateMachine::PnoSwScanning::ProcessMessage.\n"); + LOGI("Enter ScanStateMachine::PnoSwScanning::ExecuteStateMsg.\n"); if (msg == nullptr) { LOGE("msg is null.\n"); return true; @@ -713,17 +713,17 @@ bool ScanStateMachine::PnoSwScanning::ProcessMessage(InternalMessage *msg) switch (msg->GetMessageName()) { case SCAN_RESULT_EVENT: pScanStateMachine->SoftwareScanResultProcess(); - pScanStateMachine->TransitionTo(pScanStateMachine->pnoSwScanFreeState); + pScanStateMachine->SwitchState(pScanStateMachine->pnoSwScanFreeState); return true; case SCAN_FAILED_EVENT: LOGE("scan failed"); - pScanStateMachine->TransitionTo(pScanStateMachine->pnoSwScanFreeState); + pScanStateMachine->SwitchState(pScanStateMachine->pnoSwScanFreeState); return true; case WAIT_SCAN_RESULT_TIMER: LOGE("get scan result timed out"); - pScanStateMachine->TransitionTo(pScanStateMachine->pnoSwScanFreeState); + pScanStateMachine->SwitchState(pScanStateMachine->pnoSwScanFreeState); return true; case CMD_START_PNO_SCAN: @@ -732,12 +732,12 @@ bool ScanStateMachine::PnoSwScanning::ProcessMessage(InternalMessage *msg) return true; case CMD_RESTART_PNO_SCAN: case CMD_START_COMMON_SCAN: - pScanStateMachine->DeferMessage(msg); + pScanStateMachine->DelayMessage(msg); return true; case SOFTWARE_PNO_SCAN_TIMER: LOGI("Scanning is in progress. Please wait for the scan result."); - pScanStateMachine->DeferMessage(msg); + pScanStateMachine->DelayMessage(msg); return true; default: @@ -775,7 +775,7 @@ bool ScanStateMachine::GetCommonScanRequestInfo( return false; } - requestIndex = interMessage->GetArg1(); + requestIndex = interMessage->GetParam1(); if (!GetCommonScanConfig(interMessage, scanConfig)) { LOGE("GetCommonScanConfig failed."); return false; @@ -838,12 +838,12 @@ void ScanStateMachine::StartNewCommonScan() bool hasFullScan = false; /* Traverse the request list and combine parameters */ std::map::iterator configIter = waitingScans.begin(); - for (; configIter != waitingScans.end(); configIter++) { + for (; configIter != waitingScans.end(); ++configIter) { runningScanSettings.scanStyle = MergeScanStyle(runningScanSettings.scanStyle, configIter->second.scanStyle); std::vector::iterator hiddenIter = configIter->second.hiddenNetworkSsid.begin(); /* Remove duplicate hidden list */ - for (; hiddenIter != configIter->second.hiddenNetworkSsid.end(); hiddenIter++) { + for (; hiddenIter != configIter->second.hiddenNetworkSsid.end(); ++hiddenIter) { if (std::find(runningScanSettings.hiddenNetworkSsid.begin(), runningScanSettings.hiddenNetworkSsid.end(), *hiddenIter) != runningScanSettings.hiddenNetworkSsid.end()) { @@ -881,7 +881,7 @@ void ScanStateMachine::StartNewCommonScan() runningScans.swap(waitingScans); waitingScans.clear(); - TransitionTo(commonScanningState); + SwitchState(commonScanningState); LOGI("StartNewCommonScan success.\n"); return; @@ -899,12 +899,12 @@ bool ScanStateMachine::StartSingleCommonScan(WifiScanParam &scanParam) { LOGI("Enter ScanStateMachine::StartSingleCommonScan.\n"); - for (auto freqIter = scanParam.scanFreqs.begin(); freqIter != scanParam.scanFreqs.end(); freqIter++) { + for (auto freqIter = scanParam.scanFreqs.begin(); freqIter != scanParam.scanFreqs.end(); ++freqIter) { LOGI("freq is %{public}d.\n", *freqIter); } for (auto hiddenIter = scanParam.hiddenNetworkSsid.begin(); hiddenIter != scanParam.hiddenNetworkSsid.end(); - hiddenIter++) { + ++hiddenIter) { LOGI("hidden ssid is %{public}s.\n", hiddenIter->c_str()); } @@ -964,7 +964,7 @@ bool ScanStateMachine::ActiveCoverNewScan(InterScanConfig &interScanConfig) } for (auto freqIter = interScanConfig.scanFreqs.begin(); freqIter != interScanConfig.scanFreqs.end(); - freqIter++) { + ++freqIter) { if (std::find(runningScanSettings.scanFreqs.begin(), runningScanSettings.scanFreqs.end(), *freqIter) == runningScanSettings.scanFreqs.end()) { return false; @@ -982,7 +982,7 @@ bool ScanStateMachine::ActiveCoverNewScan(InterScanConfig &interScanConfig) for (auto hiddenIter = interScanConfig.hiddenNetworkSsid.begin(); hiddenIter != interScanConfig.hiddenNetworkSsid.end(); - hiddenIter++) { + ++hiddenIter) { if (std::find(runningScanSettings.hiddenNetworkSsid.begin(), runningScanSettings.hiddenNetworkSsid.end(), *hiddenIter) == runningScanSettings.hiddenNetworkSsid.end()) { @@ -1020,7 +1020,7 @@ void ScanStateMachine::ConvertScanResults( LOGI("Enter ScanStateMachine::ConvertScanResults.\n"); std::vector::iterator iter = wifiScanResults.begin(); - for (; iter != wifiScanResults.end(); iter++) { + for (; iter != wifiScanResults.end(); ++iter) { InterScanResult singleResult; singleResult.bssid = iter->bssid; singleResult.ssid = iter->ssid; @@ -1035,17 +1035,6 @@ void ScanStateMachine::ConvertScanResults( return; } -void ScanStateMachine::OnQuitting() -{ - LOGI("Enter ScanStateMachine::OnQuitting.\n"); - return; -} -void ScanStateMachine::OnHalting() -{ - LOGI("ScanStateMachine::OnQuitting.\n"); - return; -} - void ScanStateMachine::ReportStatusChange(ScanStatus status) { LOGI("Enter ScanStateMachine::ReportStatusChange.\n"); @@ -1119,7 +1108,7 @@ void ScanStateMachine::ReportCommonScanFailedAndClear(bool runningFlag) void ScanStateMachine::GetRunningIndexList(std::vector &runningIndexList) { std::map::iterator iter = runningScans.begin(); - for (; iter != runningScans.end(); iter++) { + for (; iter != runningScans.end(); ++iter) { runningIndexList.push_back(iter->first); } @@ -1129,7 +1118,7 @@ void ScanStateMachine::GetRunningIndexList(std::vector &runningIndexList) void ScanStateMachine::GetWaitingIndexList(std::vector &waitingIndexList) { std::map::iterator iter = waitingScans.begin(); - for (; iter != waitingScans.end(); iter++) { + for (; iter != waitingScans.end(); ++iter) { waitingIndexList.push_back(iter->first); } @@ -1195,9 +1184,9 @@ void ScanStateMachine::PnoScanRequestProcess(InternalMessage *interMessage) } if (supportHwPnoFlag) { - TransitionTo(pnoScanHardwareState); + SwitchState(pnoScanHardwareState); } else { - TransitionTo(pnoScanSoftwareState); + SwitchState(pnoScanSoftwareState); } return; @@ -1212,9 +1201,9 @@ void ScanStateMachine::ContinuePnoScanProcess() } if (supportHwPnoFlag) { - TransitionTo(pnoScanHardwareState); + SwitchState(pnoScanHardwareState); } else { - TransitionTo(pnoScanSoftwareState); + SwitchState(pnoScanSoftwareState); } return; @@ -1405,7 +1394,7 @@ void ScanStateMachine::HwPnoScanResultProcess() } if (NeedCommonScanAfterPno(scanResults)) { - TransitionTo(commonScanAfterPnoState); + SwitchState(commonScanAfterPnoState); return; } @@ -1446,7 +1435,7 @@ void ScanStateMachine::CommonScanAfterPnoProcess() scanParam.scanFreqs.assign(runningScanConfigForPno.scanFreqs.begin(), runningScanConfigForPno.scanFreqs.end()); if (!StartSingleCommonScan(scanParam)) { LOGE("StartSingleCommonScan failed.\n"); - TransitionTo(pnoScanHardwareState); + SwitchState(pnoScanHardwareState); return; } @@ -1549,7 +1538,7 @@ bool ScanStateMachine::RepeatStartCommonScan() } runningSwPnoFlag = true; - TransitionTo(pnoSwScanningState); + SwitchState(pnoSwScanningState); return true; } @@ -1690,23 +1679,23 @@ void ScanStateMachine::BuildScanStateTree() { LOGI("Enter ScanStateMachine::BuildScanStateTree.\n"); - AddState(initState, nullptr); - AddState(hardwareReadyState, initState); - AddState(commonScanState, hardwareReadyState); - AddState(commonScanUnworkedState, commonScanState); - AddState(commonScanningState, commonScanState); - AddState(pnoScanState, hardwareReadyState); - AddState(pnoScanHardwareState, pnoScanState); - AddState(commonScanAfterPnoState, pnoScanHardwareState); - AddState(pnoScanSoftwareState, pnoScanState); - AddState(pnoSwScanFreeState, pnoScanSoftwareState); - AddState(pnoSwScanningState, pnoScanSoftwareState); + StatePlus(initState, nullptr); + StatePlus(hardwareReadyState, initState); + StatePlus(commonScanState, hardwareReadyState); + StatePlus(commonScanUnworkedState, commonScanState); + StatePlus(commonScanningState, commonScanState); + StatePlus(pnoScanState, hardwareReadyState); + StatePlus(pnoScanHardwareState, pnoScanState); + StatePlus(commonScanAfterPnoState, pnoScanHardwareState); + StatePlus(pnoScanSoftwareState, pnoScanState); + StatePlus(pnoSwScanFreeState, pnoScanSoftwareState); + StatePlus(pnoSwScanningState, pnoScanSoftwareState); } void ScanStateMachine::InitState::LoadDriver() { LOGI("Enter ScanStateMachine::LoadDriver.\n"); - pScanStateMachine->TransitionTo(pScanStateMachine->hardwareReadyState); + pScanStateMachine->SwitchState(pScanStateMachine->hardwareReadyState); pScanStateMachine->ReportStatusChange(SCAN_STARTED_STATUS); LOGI("Start Scan Service Success.\n"); } @@ -1714,7 +1703,7 @@ void ScanStateMachine::InitState::LoadDriver() void ScanStateMachine::InitState::UnLoadDriver() { LOGI("Enter ScanStateMachine::UnLoadDriver.\n"); - pScanStateMachine->TransitionTo(pScanStateMachine->initState); + pScanStateMachine->SwitchState(pScanStateMachine->initState); pScanStateMachine->quitFlag = true; LOGI("Stop Scan Service Success.\n"); } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.h index 3a159bace399a96ab11b22e5a9a69bd00d745478..0b2a97dca27e05fe6eaf028e289916ebccff9828 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.h @@ -66,9 +66,9 @@ public: */ explicit InitState(ScanStateMachine *paraScanStateMachine); ~InitState(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -92,9 +92,9 @@ public: */ explicit HardwareReady(ScanStateMachine *paraScanStateMachine); ~HardwareReady(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -108,9 +108,9 @@ public: */ explicit CommonScan(ScanStateMachine *paraScanStateMachine); ~CommonScan(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -124,9 +124,9 @@ public: */ explicit CommonScanUnworked(ScanStateMachine *paraScanStateMachine); ~CommonScanUnworked(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -140,9 +140,9 @@ public: */ explicit CommonScanning(ScanStateMachine *paraScanStateMachine); ~CommonScanning(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -156,9 +156,9 @@ public: */ explicit PnoScan(ScanStateMachine *paraScanStateMachine); ~PnoScan(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -172,9 +172,9 @@ public: */ explicit PnoScanHardware(ScanStateMachine *paraScanStateMachine); ~PnoScanHardware(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -188,9 +188,9 @@ public: */ explicit CommonScanAfterPno(ScanStateMachine *paraScanStateMachine); ~CommonScanAfterPno(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -204,9 +204,9 @@ public: */ explicit PnoScanSoftware(ScanStateMachine *paraScanStateMachine); ~PnoScanSoftware(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -220,9 +220,9 @@ public: */ explicit PnoSwScanFree(ScanStateMachine *paraScanStateMachine); ~PnoSwScanFree(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -236,9 +236,9 @@ public: */ explicit PnoSwScanning(ScanStateMachine *paraScanStateMachine); ~PnoSwScanning(); - void Enter(); - void Exit(); - bool ProcessMessage(InternalMessage *msg); + void GoInState(); + void GoOutState(); + bool ExecuteStateMsg(InternalMessage *msg); private: ScanStateMachine *pScanStateMachine; @@ -352,8 +352,6 @@ private: * @param scanResults - Scan internal scan results[out] */ void ConvertScanResults(std::vector &wifiScanResults, std::vector &scanResults); - void OnQuitting(); - void OnHalting(); /** * @Description Reporting Status to ScanService. * diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.cpp index f1903c542550ca99a5d698392db1a554e243c38c..b97256fb81e5ea119ebfe51832e812a0a216f986 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.cpp @@ -21,20 +21,20 @@ namespace OHOS { namespace Wifi { StaConnectivityHelper::StaConnectivityHelper() - : supportForFirmwareRoaming(false), maxNumBssidBlocklist(INVALID_LIST_SIZE) + : supportRoaming(false), maxBssidBlocklistSize(INVALID_LIST_SIZE) {} StaConnectivityHelper::~StaConnectivityHelper() { LOGI("Enter StaConnectivityHelper::~StaConnectivityHelper.\n"); } -bool StaConnectivityHelper::ObtainingFirmwareRoamingInfo() +bool StaConnectivityHelper::ObtainingRoamingInfo() { - LOGI("Enter StaConnectivityHelper::ObtainingFirmwareRoamingInfo.\n"); + LOGI("Enter StaConnectivityHelper::ObtainingRoamingInfo.\n"); unsigned int capabilities; if (WifiStaHalInterface::GetInstance().GetStaCapabilities(capabilities) == WIFI_IDL_OPT_OK) { - if ((capabilities & WIFI_FEATURE_CONTROL_ROAMING) == 0) { + if ((capabilities & WIFI_CONTROL_ROAMING) == 0) { LOGE("Firmware roaming is not supported.\n"); return false; } @@ -43,8 +43,8 @@ bool StaConnectivityHelper::ObtainingFirmwareRoamingInfo() WifiIdlRoamCapability capability; if (WifiStaHalInterface::GetInstance().GetRoamingCapabilities(capability) == WIFI_IDL_OPT_OK) { if (capability.maxBlocklistSize > 0) { - supportForFirmwareRoaming = true; - maxNumBssidBlocklist = capability.maxBlocklistSize; + supportRoaming = true; + maxBssidBlocklistSize = capability.maxBlocklistSize; LOGI("Get firmware roaming capabilities succeeded.\n"); return true; } @@ -55,22 +55,22 @@ bool StaConnectivityHelper::ObtainingFirmwareRoamingInfo() return false; } -bool StaConnectivityHelper::WhetherFirmwareRoamingIsSupported() const +bool StaConnectivityHelper::IsRoamingSupported() const { - LOGI("Enter StaConnectivityHelper::WhetherFirmwareRoamingIsSupported.\n"); - return supportForFirmwareRoaming; + LOGI("Enter StaConnectivityHelper::IsRoamingSupported.\n"); + return supportRoaming; } -int StaConnectivityHelper::GetMaxNumBssidBlocklist() const +int StaConnectivityHelper::GetMaxBssidBlocklistSize() const { - LOGI("Enter StaConnectivityHelper::GetmaxNumBssidBlocklist.\n"); - return (supportForFirmwareRoaming) ? maxNumBssidBlocklist : INVALID_LIST_SIZE; + LOGI("Enter StaConnectivityHelper::GetMaxBssidBlocklistSize.\n"); + return (supportRoaming) ? maxBssidBlocklistSize : INVALID_LIST_SIZE; } -bool StaConnectivityHelper::SetFirmwareRoamingConfig(const std::vector &blocklistBssids) const +bool StaConnectivityHelper::SetRoamingConfig(const std::vector &blocklistBssids) const { - LOGI("Enter StaConnectivityHelper::SetFirmwareRoamingConfig.\n"); - if (!supportForFirmwareRoaming) { + LOGI("Enter StaConnectivityHelper::SetRoamingConfig.\n"); + if (!supportRoaming) { return false; } @@ -78,7 +78,7 @@ bool StaConnectivityHelper::SetFirmwareRoamingConfig(const std::vector(blocklistBssids.size()) > maxNumBssidBlocklist) { + if (static_cast(blocklistBssids.size()) > maxBssidBlocklistSize) { return false; } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.h index 8cecb333998a92fde5dcfe73b1021906462edca2..76686bc800dbd119117ab392e7c345063b0df426 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_helper.h @@ -26,7 +26,7 @@ namespace OHOS { namespace Wifi { static const int INVALID_LIST_SIZE = -1; -static const int WIFI_FEATURE_CONTROL_ROAMING = 0x800000; +static const int WIFI_CONTROL_ROAMING = 0x800000; class StaConnectivityHelper { public: @@ -39,31 +39,31 @@ public: If firmware roaming is supported but the valid roaming capability cannot be obtained, false is returned. */ - bool ObtainingFirmwareRoamingInfo(); + bool ObtainingRoamingInfo(); /** * @Description Whether firmware roaming is supported * * @Return: bool */ - bool WhetherFirmwareRoamingIsSupported() const; + bool IsRoamingSupported() const; /** * @Description Obtains the maximum size supported by the BSSID blocklist firmware. * * @Return: If firmware roaming is not supported, INVALID_LIST_SIZE is returned. Otherwise, the maximum size supported by the BSSID blocklist firmware is returned. */ - int GetMaxNumBssidBlocklist() const; + int GetMaxBssidBlocklistSize() const; /** * @Description Write Firmware Roaming Configuration to Firmware * * @param blocklistBssids - List of BSSIDs to Be Added to the Blocklist(in) * @Return: True if successful, false otherwise */ - bool SetFirmwareRoamingConfig(const std::vector &blocklistBssids) const; + bool SetRoamingConfig(const std::vector &blocklistBssids) const; private: - bool supportForFirmwareRoaming; - int maxNumBssidBlocklist; + bool supportRoaming; + int maxBssidBlocklistSize; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.cpp index 409f1fc279671296712de8ae1c7e5607de87f8b0..dd3e36f4d09ab0a5daffda11a7dde127ac686063 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.cpp @@ -88,11 +88,11 @@ ErrCode StaConnectivityManager::InitConnectivityManager() return WIFI_OPT_FAILED; } - if (pConnectivityHelper->ObtainingFirmwareRoamingInfo()) { + if (pConnectivityHelper->ObtainingRoamingInfo()) { LOGI("Succeeded in obtaining firmware roaming information.\n"); } - UpdateFirmwareRoamingConfig(); + UpdateRoamingConfig(); pNetworkSelector = new (std::nothrow) StaNetworkSelector(); if (pNetworkSelector == nullptr) { @@ -119,17 +119,17 @@ ErrCode StaConnectivityManager::InitConnectivityManager() } int savedPriority = WifiSettings::GetInstance().GetsavedNetworkEvaluatorPriority(); - if (pNetworkSelector->RegisterNetworkEvaluator(pSavedNetworkEvaluator, savedPriority)) { + if (pNetworkSelector->RegisteringTheNetworkEvaluator(pSavedNetworkEvaluator, savedPriority)) { LOGI("RegisterSavedNetworkEvaluator succeeded.\n"); } int scoredPriority = WifiSettings::GetInstance().GetscoredNetworkEvaluatorPriority(); - if (pNetworkSelector->RegisterNetworkEvaluator(pScoredNetworkEvaluator, scoredPriority)) { + if (pNetworkSelector->RegisteringTheNetworkEvaluator(pScoredNetworkEvaluator, scoredPriority)) { LOGI("RegisterScoredNetworkEvaluator succeeded.\n"); } int passpointPriority = WifiSettings::GetInstance().GetpasspointNetworkEvaluatorPriority(); - if (pNetworkSelector->RegisterNetworkEvaluator(pPasspointNetworkEvaluator, passpointPriority)) { + if (pNetworkSelector->RegisteringTheNetworkEvaluator(pPasspointNetworkEvaluator, passpointPriority)) { LOGI("RegisterPasspointNetworkEvaluator succeeded.\n"); } return WIFI_OPT_SUCCESS; @@ -151,7 +151,7 @@ bool StaConnectivityManager::TrackBlockBssid(std::string bssid, bool enable, int /* The blocklist has been updated, so update the firmware roaming */ /* configuration */ - UpdateFirmwareRoamingConfig(); + UpdateRoamingConfig(); return true; } @@ -189,14 +189,14 @@ bool StaConnectivityManager::UpdateBssidBlocklist(std::string bssid, bool enable return false; } -void StaConnectivityManager::UpdateFirmwareRoamingConfig() +void StaConnectivityManager::UpdateRoamingConfig() { - LOGI("Enter StaConnectivityManager::UpdateFirmwareRoamingConfig.\n"); - if (!pConnectivityHelper->WhetherFirmwareRoamingIsSupported()) { + LOGI("Enter StaConnectivityManager::UpdateRoamingConfig.\n"); + if (!pConnectivityHelper->IsRoamingSupported()) { return; } - int maxBlocklistSize = pConnectivityHelper->GetMaxNumBssidBlocklist(); + int maxBlocklistSize = pConnectivityHelper->GetMaxBssidBlocklistSize(); if (maxBlocklistSize <= 0) { return; } @@ -207,7 +207,7 @@ void StaConnectivityManager::UpdateFirmwareRoamingConfig() blocklistedBssids.resize(maxBlocklistSize); } - if (pConnectivityHelper->SetFirmwareRoamingConfig(blocklistedBssids)) { + if (pConnectivityHelper->SetRoamingConfig(blocklistedBssids)) { LOGE("Set firmware roaming configuration succeeded.\n"); } else { LOGI("Set firmware roaming configuration failed.\n"); @@ -235,7 +235,7 @@ void StaConnectivityManager::RefreshBssidBlocklist() } } if (updated) { - UpdateFirmwareRoamingConfig(); + UpdateRoamingConfig(); } return; } @@ -263,7 +263,7 @@ void StaConnectivityManager::ConnectToNetwork(WifiDeviceConfig &candidate) if (currentConnectedNetwork.connState == ConnState::CONNECTED && candidate.networkId == INVALID_NETWORK_ID && currentConnectedNetwork.ssid == candidate.ssid && currentConnectedNetwork.bssid != candidate.bssid) { /* Frameworks start roaming only when firmware is not supported */ - if (!pConnectivityHelper->WhetherFirmwareRoamingIsSupported()) { + if (!pConnectivityHelper->IsRoamingSupported()) { LOGI("Roaming connectTo.\n"); pStaStateMachine->StartRoamToNetwork(candidate.bssid); LOGI("connecTo network bssid is %s", candidate.bssid.c_str()); diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.h index f87d1a79064af9b06e79fbd23436d0028eb38424..8492cccf08b84503c174e1f59119fe11b61f0f49 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_connectivity_manager.h @@ -106,7 +106,7 @@ private: update the firmware roaming config. * */ - void UpdateFirmwareRoamingConfig(); + void UpdateRoamingConfig(); /** * @Description Connect to a candidate network * diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.cpp index 33e732cc5fa38c2ec6013386e9a8e0ce805b9342..d3fae781eab48c1c2aab79a25aed378fdd70814a 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.cpp @@ -20,16 +20,16 @@ namespace OHOS { namespace Wifi { StaNetworkSelector::StaNetworkSelector() - : LastNetworkSelectionTimeStamp(0), pEvaluators {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr} + : LastSelectNetworkTimeStamp(0), pEvaluators {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr} {} StaNetworkSelector::~StaNetworkSelector() { LOGI("Enter StaNetworkSelector::~StaNetworkSelector.\n"); } -bool StaNetworkSelector::RegisterNetworkEvaluator(StaNetworkEvaluator *evaluator, int priority) +bool StaNetworkSelector::RegisteringTheNetworkEvaluator(StaNetworkEvaluator *evaluator, int priority) { - LOGI("Enter StaNetworkSelector::RegisterNetworkEvaluator.\n"); + LOGI("Enter StaNetworkSelector::RegisteringTheNetworkEvaluator.\n"); if (priority < 0 || priority >= EVALUATOR_MIN_PRIORITY) { LOGE("Out of array range.\n"); return false; @@ -66,10 +66,10 @@ ErrCode StaNetworkSelector::SelectNetwork(WifiDeviceConfig &candidate, const std } } - std::vector filteredscanResults; + std::vector chooseScanResults; /* Filter out unnecessary networks. */ - FilterscanResults(filteredscanResults, scanResults, blocklistedBssids, info); - if (filteredscanResults.empty()) { + SelectScanResults(chooseScanResults, scanResults, blocklistedBssids, info); + if (chooseScanResults.empty()) { LOGE("No scanResult available.\n"); return WIFI_OPT_FAILED; } @@ -79,17 +79,17 @@ ErrCode StaNetworkSelector::SelectNetwork(WifiDeviceConfig &candidate, const std */ for (auto registeredEvaluator : pEvaluators) { if (registeredEvaluator != nullptr) { - ErrCode code = registeredEvaluator->NetworkEvaluators(candidate, filteredscanResults, info); + ErrCode code = registeredEvaluator->NetworkEvaluators(candidate, chooseScanResults, info); if (code == WIFI_OPT_SUCCESS) { time_t now = time(NULL); - LastNetworkSelectionTimeStamp = (int)now; + LastSelectNetworkTimeStamp = (int)now; LOGI("candidate network generation.\n"); return WIFI_OPT_SUCCESS; } } } - if (RoamingSelection(candidate, filteredscanResults, info)) { + if (RoamingSelection(candidate, chooseScanResults, info)) { LOGI("Roaming network generation.\n"); return WIFI_OPT_SUCCESS; } @@ -98,9 +98,9 @@ ErrCode StaNetworkSelector::SelectNetwork(WifiDeviceConfig &candidate, const std } bool StaNetworkSelector::RoamingSelection( - WifiDeviceConfig &candidate, std::vector &filteredscanResults, WifiLinkedInfo &info) + WifiDeviceConfig &candidate, std::vector &chooseScanResults, WifiLinkedInfo &info) { - for (auto scanInfo : filteredscanResults) { + for (auto scanInfo : chooseScanResults) { if (info.connState == ConnState::CONNECTED && scanInfo.ssid == info.ssid && scanInfo.bssid != info.bssid) { LOGI("Discover roaming networks.\n"); if (RoamingEncryptionModeCheck(candidate, scanInfo, info)) { @@ -174,8 +174,8 @@ bool StaNetworkSelector::IsNetworkSelectionRequired(const std::vector &filteredscanResults, +void StaNetworkSelector::SelectScanResults(std::vector &chooseScanResults, const std::vector &scanResults, std::vector &blocklistedBssids, WifiLinkedInfo &info) { - LOGI("Enter StaNetworkSelector::FilterscanResults.\n"); + LOGI("Enter StaNetworkSelector::SelectScanResults.\n"); if (scanResults.empty()) { return; } - bool scanResultsHaveCurrentBssid = false; + bool scanResultsContainCurrentBssid = false; for (auto scanInfo : scanResults) { if (scanInfo.ssid.size() == 0) { @@ -323,7 +323,7 @@ void StaNetworkSelector::FilterscanResults(std::vector &filteredsc /* Check whether the scanning result contains the current BSSID. */ if (info.connState == ConnState::CONNECTED && scanInfo.bssid == info.bssid) { - scanResultsHaveCurrentBssid = true; + scanResultsContainCurrentBssid = true; } auto itr = find(blocklistedBssids.begin(), blocklistedBssids.end(), scanInfo.bssid); @@ -344,7 +344,7 @@ void StaNetworkSelector::FilterscanResults(std::vector &filteredsc continue; } } - filteredscanResults.push_back(scanInfo); + chooseScanResults.push_back(scanInfo); } /* * Some scan requests may not include channels for the currently connected @@ -352,9 +352,9 @@ void StaNetworkSelector::FilterscanResults(std::vector &filteredsc * results. We will not act on these scans to avoid network switching that may * trigger disconnections. */ - if (info.connState == ConnState::CONNECTED && !scanResultsHaveCurrentBssid) { + if (info.connState == ConnState::CONNECTED && !scanResultsContainCurrentBssid) { LOGI("scanResult is be cleared.\n"); - filteredscanResults.clear(); + chooseScanResults.clear(); } return; } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.h index d2b804947a1298a56719aa1d99bdf8f37161c9c9..dab07f7d3625b9266755c10fb2c2b80a87206b0e 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_selector.h @@ -73,10 +73,10 @@ public: * @param priority - Value between 0 and (SCORER_MIN_PRIORITY – 1)(in) * @Return success : true failed : false */ - bool RegisterNetworkEvaluator(StaNetworkEvaluator *evaluator, int priority); + bool RegisteringTheNetworkEvaluator(StaNetworkEvaluator *evaluator, int priority); private: - int LastNetworkSelectionTimeStamp; + int LastSelectNetworkTimeStamp; StaNetworkEvaluator *pEvaluators[MAX_MUM_EVALUATOR]; /** * @Description Filtering network @@ -84,9 +84,9 @@ private: * @param scanResults - WifiScanInfo list of all APs in the range(in) * @param blocklistedBssids - Blocklisted BSSID List(in) * @param info - Current Connected Network(in) - * @param filteredscanResults - Filtered Scan Result(out) + * @param chooseScanResults - Filtered Scan Result(out) */ - void FilterscanResults(std::vector &filteredscanResults, const std::vector &scanResults, + void SelectScanResults(std::vector &chooseScanResults, const std::vector &scanResults, std::vector &blocklistedBssids, WifiLinkedInfo &info); /** * @Description Whether the network needs to be switched. @@ -121,7 +121,7 @@ private: * @Return success : true failed : false */ bool RoamingSelection( - WifiDeviceConfig &candidate, std::vector &filteredscanResults, WifiLinkedInfo &info); + WifiDeviceConfig &candidate, std::vector &chooseScanResults, WifiLinkedInfo &info); /** * @Description Select Roaming Network. * diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_saved_network_evaluator.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_saved_network_evaluator.cpp index 2a8942fa6f20ab405012b30e58fc37ff2cece75c..2a767c8232b27e55586049fac328c81265663f08 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_saved_network_evaluator.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_saved_network_evaluator.cpp @@ -107,16 +107,9 @@ bool StaSavedNetworkEvaluator::SkipNetwork(WifiDeviceConfig &network) LOGI("Skip disable Network %s.NetworkId is %{public}d", network.ssid.c_str(), network.networkId); return false; } - /* - * Skip the network that does not support encryption. - * There are two cases where encryption is supported but encryption is not - * supported. - */ - if ((network.allowedKeyManagement & 1) == BINARY_CODE) { - return false; - } return true; } + void StaSavedNetworkEvaluator::CalculateNetworkScore( int &score, WifiScanInfo &scanInfo, WifiDeviceConfig &network, WifiLinkedInfo &info) { @@ -163,7 +156,7 @@ void StaSavedNetworkEvaluator::CalculateNetworkScore( * When firmware roaming is supported, the same BSSID is added to different * BSSIDs. */ - if (pConnectivityHelper->WhetherFirmwareRoamingIsSupported() && scanInfo.bssid != info.bssid) { + if (pConnectivityHelper->IsRoamingSupported() && scanInfo.bssid != info.bssid) { score += SameBssidScore; LOGI("roamingsupport score is %{public}d.\n", SameBssidScore); } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp index 5fd4290a937726d5c20ee3864da5a9287b88b990..476ff2377a5f628350ff298c1898ceed6ff5346f 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp @@ -156,7 +156,6 @@ ErrCode StaService::ConnectTo(const WifiDeviceConfig &config) const idlConfig.eap = config.wifiEapConfig.eap; idlConfig.identity = config.wifiEapConfig.identity; idlConfig.password = config.wifiEapConfig.password; - idlConfig.authAlgorithms = config.allowedAuthAlgorithms; idlConfig.wepKeyIdx = config.wepTxKeyIndex; for (int i = 0; i < MAX_WEPKEYS_SIZE; i++) { idlConfig.wepKeys[i] = config.wepKeys[i]; @@ -223,9 +222,9 @@ ErrCode StaService::Disconnect() const ErrCode StaService::StartWps(const WpsConfig &config) const { LOGI("Enter StaService::StartWps.\n"); - InternalMessage *msg = pStaStateMachine->ObtainMessage(); + InternalMessage *msg = pStaStateMachine->CreateMessage(); msg->SetMessageName(WIFI_SVR_CMD_STA_STARTWPS); - msg->SetArg1(static_cast(config.setup)); + msg->SetParam1(static_cast(config.setup)); msg->AddStringMessageBody(config.pin); msg->AddStringMessageBody(config.bssid); pStaStateMachine->SendMessage(msg); diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp index 3877019c704269c7c69323fc268484ff58f099b2..97d16e62b7e3bcc6380efce4920669993a8d82a8 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp @@ -103,8 +103,8 @@ ErrCode StaStateMachine::InitStaStateMachine() return WIFI_OPT_FAILED; } BuildStateTree(); - SetInitialState(pInitState); - Start(); + SetFirstState(pInitState); + StartStateMachine(); InitStaSMHandleMap(); pDhcpServer = @@ -129,31 +129,31 @@ ErrCode StaStateMachine::InitStaStates() { LOGE("Enter InitStaStates\n"); int tmpErrNumber; - pDefaultState = new DefaultState(this); + pDefaultState = new StaDefaultState(this); tmpErrNumber = JudgmentEmpty(pDefaultState); - pInitState = new InitState(this); + pInitState = new StaInitState(this); tmpErrNumber += JudgmentEmpty(pInitState); - pWpaStartingState = new WpaStartingState(this); + pWpaStartingState = new StaWpaStartingState(this); tmpErrNumber += JudgmentEmpty(pWpaStartingState); - pWpaStartedState = new WpaStartedState(this); + pWpaStartedState = new StaWpaStartedState(this); tmpErrNumber += JudgmentEmpty(pWpaStartedState); - pWpaStoppingState = new WpaStoppingState(this); + pWpaStoppingState = new StaWpaStoppingState(this); tmpErrNumber += JudgmentEmpty(pWpaStoppingState); - pConnectState = new ConnectState(this); + pConnectState = new StaConnectState(this); tmpErrNumber += JudgmentEmpty(pConnectState); - pDisconnectingState = new DisconnectingState(this); + pDisconnectingState = new StaDisconnectingState(this); tmpErrNumber += JudgmentEmpty(pDisconnectingState); - pDisconnectedState = new DisconnectedState(this); + pDisconnectedState = new StaDisconnectedState(this); tmpErrNumber += JudgmentEmpty(pDisconnectedState); - pApConnectedState = new ApConnectedState(this); + pApConnectedState = new StaConnectedApState(this); tmpErrNumber += JudgmentEmpty(pApConnectedState); - pWpsState = new WpsState(this); + pWpsState = new StaWpsState(this); tmpErrNumber += JudgmentEmpty(pWpsState); - pObtainingIpState = new ObtainingIpState(this); + pObtainingIpState = new StaObtainingIpState(this); tmpErrNumber += JudgmentEmpty(pObtainingIpState); - pConnectedState = new ConnectedState(this); + pConnectedState = new StaConnectedState(this); tmpErrNumber += JudgmentEmpty(pConnectedState); - pRoamingState = new RoamingState(this); + pRoamingState = new StaRoamingState(this); tmpErrNumber += JudgmentEmpty(pRoamingState); pNetSpeed = new StaNetWorkSpeed(); tmpErrNumber += JudgmentEmpty(pNetSpeed); @@ -208,43 +208,43 @@ void StaStateMachine::SetResponseQueue(WifiMessageQueue *pM void StaStateMachine::BuildStateTree() { - AddState(pDefaultState, nullptr); - AddState(pInitState, pDefaultState); - AddState(pWpaStartingState, pDefaultState); - AddState(pWpaStartedState, pDefaultState); - AddState(pConnectState, pWpaStartedState); - AddState(pDisconnectingState, pConnectState); - AddState(pDisconnectedState, pConnectState); - AddState(pApConnectedState, pConnectState); - AddState(pObtainingIpState, pApConnectedState); - AddState(pConnectedState, pApConnectedState); - AddState(pRoamingState, pApConnectedState); - AddState(pWpsState, pConnectState); - AddState(pWpaStoppingState, pDefaultState); + StatePlus(pDefaultState, nullptr); + StatePlus(pInitState, pDefaultState); + StatePlus(pWpaStartingState, pDefaultState); + StatePlus(pWpaStartedState, pDefaultState); + StatePlus(pConnectState, pWpaStartedState); + StatePlus(pDisconnectingState, pConnectState); + StatePlus(pDisconnectedState, pConnectState); + StatePlus(pApConnectedState, pConnectState); + StatePlus(pObtainingIpState, pApConnectedState); + StatePlus(pConnectedState, pApConnectedState); + StatePlus(pRoamingState, pApConnectedState); + StatePlus(pWpsState, pConnectState); + StatePlus(pWpaStoppingState, pDefaultState); } /* --------------------------- state machine default state ------------------------------ */ -StaStateMachine::DefaultState::DefaultState(StaStateMachine *staStateMachine) : State("DefaultState") +StaStateMachine::StaDefaultState::StaDefaultState(StaStateMachine *staStateMachine) : State("StaDefaultState") { pStaStateMachine = staStateMachine; } -StaStateMachine::DefaultState::~DefaultState() +StaStateMachine::StaDefaultState::~StaDefaultState() {} -void StaStateMachine::DefaultState::Enter() +void StaStateMachine::StaDefaultState::GoInState() { - LOGI("DefaultState Enter function."); + LOGI("DefaultState GoInState function."); return; } -void StaStateMachine::DefaultState::Exit() +void StaStateMachine::StaDefaultState::GoOutState() { - LOGI("DefaultState Exit function."); + LOGI("DefaultState GoOutState function."); return; } -bool StaStateMachine::DefaultState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaDefaultState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; @@ -255,41 +255,41 @@ bool StaStateMachine::DefaultState::ProcessMessage(InternalMessage *msg) } /* --------------------------- state machine Init State ------------------------------ */ -StaStateMachine::InitState::InitState(StaStateMachine *staStateMachine) : State("InitState") +StaStateMachine::StaInitState::StaInitState(StaStateMachine *staStateMachine) : State("StaInitState") { pStaStateMachine = staStateMachine; } -StaStateMachine::InitState::~InitState() +StaStateMachine::StaInitState::~StaInitState() {} -void StaStateMachine::InitState::Enter() +void StaStateMachine::StaInitState::GoInState() { - LOGI("InitState Enter function."); + LOGI("InitState GoInState function."); CleanUp(); return; } -void StaStateMachine::InitState::Exit() +void StaStateMachine::StaInitState::GoOutState() {} -bool StaStateMachine::InitState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaInitState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_CMD_STA_START_SUPPLICANT: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->StartWifiProcess(); break; } case WIFI_SVR_CMD_STA_ENABLE_WIFI: { - ret = HANDLED; - pStaStateMachine->operationalMode = msg->GetArg1(); + ret = EXECUTED; + pStaStateMachine->operationalMode = msg->GetParam1(); pStaStateMachine->SendMessage(WIFI_SVR_CMD_STA_START_SUPPLICANT); break; } @@ -298,7 +298,7 @@ bool StaStateMachine::InitState::ProcessMessage(InternalMessage *msg) break; case WIFI_SVR_CMD_STA_REMOVE_DEVICE_CONFIG: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->RemoveDeviceConfigProcess(msg); break; } @@ -308,7 +308,7 @@ bool StaStateMachine::InitState::ProcessMessage(InternalMessage *msg) return ret; } -void StaStateMachine::InitState::CleanUp() +void StaStateMachine::StaInitState::CleanUp() {} void StaStateMachine::StartWifiProcess() @@ -342,7 +342,7 @@ void StaStateMachine::StartWifiProcess() /* The current state of StaStateMachine transfers to DisconnectedState after * enable supplicant. */ - TransitionTo(pDisconnectedState); + SwitchState(pDisconnectedState); /* Set country code */ SetCountryCode(); } else { @@ -354,41 +354,42 @@ void StaStateMachine::StartWifiProcess() } /* --------------------------- state machine WpaStarting State ------------------------------ */ -StaStateMachine::WpaStartingState::WpaStartingState(StaStateMachine *staStateMachine) : State("WpaStartingState") +StaStateMachine::StaWpaStartingState::StaWpaStartingState(StaStateMachine *staStateMachine) + : State("StaWpaStartingState") { pStaStateMachine = staStateMachine; } -StaStateMachine::WpaStartingState::~WpaStartingState() +StaStateMachine::StaWpaStartingState::~StaWpaStartingState() {} -void StaStateMachine::WpaStartingState::InitWpsSettings() +void StaStateMachine::StaWpaStartingState::InitWpsSettings() { LOGI("WpaStartingState InitWpsSettings function."); return; } -void StaStateMachine::WpaStartingState::Enter() +void StaStateMachine::StaWpaStartingState::GoInState() { - LOGI("WpaStartingState Enter function."); + LOGI("WpaStartingState GoInState function."); return; } -void StaStateMachine::WpaStartingState::Exit() +void StaStateMachine::StaWpaStartingState::GoOutState() { return; } -bool StaStateMachine::WpaStartingState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaWpaStartingState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_CMD_STA_SUP_CONNECTION_EVENT: { - ret = HANDLED; - pStaStateMachine->TransitionTo(pStaStateMachine->pWpaStartedState); + ret = EXECUTED; + pStaStateMachine->SwitchState(pStaStateMachine->pWpaStartedState); break; } default: @@ -398,53 +399,53 @@ bool StaStateMachine::WpaStartingState::ProcessMessage(InternalMessage *msg) } /* --------------------------- state machine WpaStarted State ------------------------------ */ -StaStateMachine::WpaStartedState::WpaStartedState(StaStateMachine *staStateMachine) : State("WpaStartedState") +StaStateMachine::StaWpaStartedState::StaWpaStartedState(StaStateMachine *staStateMachine) : State("StaWpaStartedState") { pStaStateMachine = staStateMachine; } -StaStateMachine::WpaStartedState::~WpaStartedState() +StaStateMachine::StaWpaStartedState::~StaWpaStartedState() {} -void StaStateMachine::WpaStartedState::Enter() +void StaStateMachine::StaWpaStartedState::GoInState() { - LOGD("WpaStartedState Enter function."); + LOGD("WpaStartedState GoInState function."); if (pStaStateMachine->operationalMode == STA_CONNECT_MODE) { /* Update the wifi status. */ WifiSettings::GetInstance().SetWifiState(static_cast(WifiState::ENABLING)); - pStaStateMachine->TransitionTo(pStaStateMachine->pDisconnectedState); + pStaStateMachine->SwitchState(pStaStateMachine->pDisconnectedState); } else if (pStaStateMachine->operationalMode == STA_DISABLED_MODE) { - pStaStateMachine->TransitionTo(pStaStateMachine->pWpaStoppingState); + pStaStateMachine->SwitchState(pStaStateMachine->pWpaStoppingState); } return; } -void StaStateMachine::WpaStartedState::Exit() +void StaStateMachine::StaWpaStartedState::GoOutState() { return; } -bool StaStateMachine::WpaStartedState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaWpaStartedState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_CMD_STA_STOP_SUPPLICANT: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->StopWifiProcess(); break; } case WIFI_SVR_CMD_STA_DISABLE_WIFI: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->SendMessage(WIFI_SVR_CMD_STA_STOP_SUPPLICANT); break; } case WIFI_SVR_CMD_STA_REMOVE_DEVICE_CONFIG: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->RemoveDeviceConfigProcess(msg); break; } @@ -483,7 +484,7 @@ void StaStateMachine::StopWifiProcess() LOGD("Stop WifiProcess successfully!"); /* The current state of StaStateMachine transfers to InitState. */ - TransitionTo(pInitState); + SwitchState(pInitState); } else { LOGE("StopWifiProcess failed,and errcode is %{public}d", errorNo); NotifyResult(WifiInternalMsgCode::STA_OPEN_RES, static_cast(OperateResState::CLOSE_WIFI_FAILED)); @@ -498,7 +499,7 @@ void StaStateMachine::RemoveDeviceConfigProcess(const InternalMessage *msg) LOGD("Enter StaStateMachine::RemoveDeviceConfigProcess.\n"); /* Remove network configuration. */ - if (WifiStaHalInterface::GetInstance().RemoveDeviceConfig(msg->GetArg1()) == WIFI_IDL_OPT_OK) { + if (WifiStaHalInterface::GetInstance().RemoveDeviceConfig(msg->GetParam1()) == WIFI_IDL_OPT_OK) { LOGD("Remove device config successfully!"); if (WifiStaHalInterface::GetInstance().SaveDeviceConfig() != WIFI_IDL_OPT_OK) { @@ -510,62 +511,63 @@ void StaStateMachine::RemoveDeviceConfigProcess(const InternalMessage *msg) } /* Remove network configuration directly without notification to InterfaceService. */ - WifiSettings::GetInstance().RemoveDeviceConfig(msg->GetArg1()); + WifiSettings::GetInstance().RemoveDeviceConfig(msg->GetParam1()); if (WifiSettings::GetInstance().SyncDeviceConfig() != 0) { LOGE("RemoveDeviceConfigProcess-SyncDeviceConfig() failed!"); } } /* --------------------------- state machine WpaStopping State ------------------------------ */ -StaStateMachine::WpaStoppingState::WpaStoppingState(StaStateMachine *staStateMachine) : State("WpaStoppingState") +StaStateMachine::StaWpaStoppingState::StaWpaStoppingState(StaStateMachine *staStateMachine) + : State("StaWpaStoppingState") { pStaStateMachine = staStateMachine; } -StaStateMachine::WpaStoppingState::~WpaStoppingState() +StaStateMachine::StaWpaStoppingState::~StaWpaStoppingState() {} -void StaStateMachine::WpaStoppingState::Enter() +void StaStateMachine::StaWpaStoppingState::GoInState() { - LOGE("WpaStoppingState Enter function."); - pStaStateMachine->TransitionTo(pStaStateMachine->pInitState); + LOGE("WpaStoppingState GoInState function."); + pStaStateMachine->SwitchState(pStaStateMachine->pInitState); return; } -void StaStateMachine::WpaStoppingState::Exit() +void StaStateMachine::StaWpaStoppingState::GoOutState() {} -bool StaStateMachine::WpaStoppingState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaWpaStoppingState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; LOGI("DefaultState-msgCode=%{public}d not handled.\n", msg->GetMessageName()); return ret; } /* --------------------------- state machine Connect State ------------------------------ */ -StaStateMachine::ConnectState::ConnectState(StaStateMachine *staStateMachine) : State("ConnectState") +StaStateMachine::StaConnectState::StaConnectState(StaStateMachine *staStateMachine) : State("StaConnectState") { pStaStateMachine = staStateMachine; } -StaStateMachine::ConnectState::~ConnectState() +StaStateMachine::StaConnectState::~StaConnectState() {} -void StaStateMachine::ConnectState::Enter() +void StaStateMachine::StaConnectState::GoInState() { - LOGI("ConnectState Enter function."); + LOGI("ConnectState GoInState function."); return; } -void StaStateMachine::ConnectState::Exit() +void StaStateMachine::StaConnectState::GoOutState() {} -bool StaStateMachine::ConnectState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaConnectState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; @@ -574,9 +576,9 @@ bool StaStateMachine::ConnectState::ProcessMessage(InternalMessage *msg) auto iter = pStaStateMachine->staSmHandleFuncMap.find(msg->GetMessageName()); if (iter != pStaStateMachine->staSmHandleFuncMap.end()) { (pStaStateMachine->*(iter->second))(msg); - return HANDLED; + return EXECUTED; } - return NOT_HANDLED; + return NOT_EXECUTED; } /* -- state machine Connect State Message processing function -- */ @@ -605,8 +607,8 @@ void StaStateMachine::DealConnectToUserSelectedNetwork(InternalMessage *msg) } LOGI("enter ConnectToUserSelectedNetwork\n"); - int networkId = msg->GetArg1(); - bool forceReconnect = msg->GetArg2(); + int networkId = msg->GetParam1(); + bool forceReconnect = msg->GetParam2(); /* Sets network status. */ WifiSettings::GetInstance().EnableNetwork(networkId, forceReconnect); @@ -621,10 +623,9 @@ void StaStateMachine::DealConnectToSelectedNetCmd(InternalMessage *msg) LOGD("Enter StaStateMachine::DealConnectToSelectedNetCmd.\n"); WifiDeviceConfig config; - targetNetworkId = msg->GetArg1(); + targetNetworkId = msg->GetParam1(); SetRandomMac(targetNetworkId); - SetTargetBssid(config, config.bssid); /* Sets linkedinfo */ linkedInfo.networkId = targetNetworkId; @@ -701,7 +702,7 @@ void StaStateMachine::DealConnectionEvent(InternalMessage *msg) NotifyResult(WifiInternalMsgCode::STA_CONNECT_RES, static_cast(OperateResState::CONNECT_AP_CONNECTED)); /* The current state of StaStateMachine transfers to ObtainingIpState. */ - TransitionTo(pObtainingIpState); + SwitchState(pObtainingIpState); } void StaStateMachine::DealDisconnectEvent(InternalMessage *msg) @@ -737,7 +738,7 @@ void StaStateMachine::DealDisconnectEvent(InternalMessage *msg) } /* Notify result to InterfaceService. */ NotifyResult(WifiInternalMsgCode::STA_DISCONNECT_RES, static_cast(OperateResState::DISCONNECT_DISCONNECTED)); - TransitionTo(pDisconnectedState); + SwitchState(pDisconnectedState); } void StaStateMachine::DealWpaWrongPskEvent(InternalMessage *msg) @@ -766,7 +767,7 @@ void StaStateMachine::DealReassociateCmd(InternalMessage *msg) if (WifiStaHalInterface::GetInstance().Reassociate() == WIFI_IDL_OPT_OK) { /* Notify result to InterfaceService */ NotifyResult(WifiInternalMsgCode::STA_REASSOCIATE_RES, static_cast(OperateResState::CONNECT_AP_CONNECTED)); - LOGD("StaStateMachine::ConnectState::ProcessMessage ReAssociate successfully!"); + LOGD("StaStateMachine::ConnectState::ExecuteStateMsg ReAssociate successfully!"); } else { LOGE("ReAssociate failed!"); } @@ -797,7 +798,7 @@ void StaStateMachine::StartWpsMode(InternalMessage *msg) constexpr int multiAp = 0; WifiIdlWpsConfig wpsParam; WpsConfig wpsConfig; - wpsConfig.setup = static_cast(msg->GetArg1()); + wpsConfig.setup = static_cast(msg->GetParam1()); wpsConfig.pin = msg->GetStringFromMessage(); wpsConfig.bssid = msg->GetStringFromMessage(); if (wpsConfig.bssid.length() == 0 || wpsConfig.bssid == PBC_ANY_BSSID) { @@ -820,7 +821,7 @@ void StaStateMachine::StartWpsMode(InternalMessage *msg) LOGD("StartWpsPbcMode() succeed!"); /* Notify result to InterfaceService. */ NotifyResult(WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::START_PBC_SUCCEED)); - TransitionTo(pWpsState); + SwitchState(pWpsState); } else { LOGE("StartWpsPbcMode() failed!"); NotifyResult(WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::START_PBC_FAILED)); @@ -831,7 +832,7 @@ void StaStateMachine::StartWpsMode(InternalMessage *msg) /* Notify result to InterfaceService. */ NotifyResult(WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::START_PIN_SUCCEED)); LOGD("StartWpsPinMode() succeed! pincode: %d", pinCode); - TransitionTo(pWpsState); + SwitchState(pWpsState); } else { LOGE("StartWpsPinMode() failed!"); NotifyResult(WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::START_PIN_FAILED)); @@ -846,8 +847,9 @@ void StaStateMachine::RemoveAllDeviceConfigs() { std::vector wpaNetworkList; WifiStaHalInterface::GetInstance().GetNetworkList(wpaNetworkList); - for (std::vector::iterator it = wpaNetworkList.begin(); it != wpaNetworkList.end(); it++) { - WifiStaHalInterface::GetInstance().RemoveDeviceConfig(it->id); + for (std::vector::iterator iter = wpaNetworkList.begin(); iter != wpaNetworkList.end(); + ++iter) { + WifiStaHalInterface::GetInstance().RemoveDeviceConfig(iter->id); } WifiStaHalInterface::GetInstance().SaveDeviceConfig(); LOGD("Remove all device configurations completed!"); @@ -878,7 +880,7 @@ void StaStateMachine::DealWpsConnectTimeOutEvent(InternalMessage *msg) /* Notify InterfaceService that WPS time out. */ NotifyResult(WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::WPS_TIME_OUT)); - TransitionTo(pDisconnectedState); + SwitchState(pDisconnectedState); } void StaStateMachine::DealCancelWpsCmd(InternalMessage *msg) @@ -919,7 +921,7 @@ void StaStateMachine::DealCancelWpsCmd(InternalMessage *msg) NotifyResult(WifiInternalMsgCode::STA_CANCEL_WPS_RES, static_cast(WpsStartState::STOP_PIN_FAILED)); } } - TransitionTo(pDisconnectedState); + SwitchState(pDisconnectedState); } void StaStateMachine::DealStartRoamCmd(InternalMessage *msg) @@ -963,7 +965,7 @@ void StaStateMachine::DealStartRoamCmd(InternalMessage *msg) WifiSettings::GetInstance().SaveLinkedInfo(linkedInfo); /* Start roaming */ - TransitionTo(pRoamingState); + SwitchState(pRoamingState); if (WifiStaHalInterface::GetInstance().Reassociate() != WIFI_IDL_OPT_OK) { LOGE("START_ROAM-ReAssociate() failed!"); } @@ -972,19 +974,19 @@ void StaStateMachine::DealStartRoamCmd(InternalMessage *msg) void StaStateMachine::StartConnectToNetwork(int networkId) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); if (msg == nullptr) { return; } msg->SetMessageName(CMD_START_CONNECT_SELECTED_NETWORK); - msg->SetArg1(networkId); + msg->SetParam1(networkId); SendMessage(msg); } void StaStateMachine::StartRoamToNetwork(std::string bssid) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); if (msg == nullptr) { return; } @@ -996,13 +998,13 @@ void StaStateMachine::StartRoamToNetwork(std::string bssid) void StaStateMachine::OnNetworkConnectionEvent(int networkId, std::string bssid) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); if (msg == nullptr) { return; } msg->SetMessageName(WIFI_SVR_CMD_STA_NETWORK_CONNECTION_EVENT); - msg->SetArg1(networkId); + msg->SetParam1(networkId); msg->AddStringMessageBody(bssid); SendMessage(msg); } @@ -1015,13 +1017,13 @@ void StaStateMachine::SyncLinkInfo(const std::vector &scanResults) } for (auto scanInfo : scanResults) { if ((scanInfo.ssid == linkedInfo.ssid) && (scanInfo.bssid == linkedInfo.bssid)) { - InternalMessage *msg = ObtainMessage(); + InternalMessage *msg = CreateMessage(); if (msg == nullptr) { break; } msg->SetMessageName(CMD_SYNC_LINKINFO); - msg->SetArg1(scanInfo.level); - msg->SetArg2(scanInfo.frequency); + msg->SetParam1(scanInfo.level); + msg->SetParam2(scanInfo.frequency); msg->AddStringMessageBody(scanInfo.capabilities); LOGI("scanInfo.level == [%{public}d]\n", scanInfo.level); LOGI("scanInfo.frequency == [%{public}d]\n", scanInfo.frequency); @@ -1033,64 +1035,66 @@ void StaStateMachine::SyncLinkInfo(const std::vector &scanResults) } /* --------------------------- state machine Disconnecting State ------------------------------ */ -StaStateMachine::DisconnectingState::DisconnectingState(StaStateMachine *staStateMachine) : State("DisconnectingState") +StaStateMachine::StaDisconnectingState::StaDisconnectingState(StaStateMachine *staStateMachine) + : State("StaDisconnectingState") { pStaStateMachine = staStateMachine; } -StaStateMachine::DisconnectingState::~DisconnectingState() +StaStateMachine::StaDisconnectingState::~StaDisconnectingState() {} -void StaStateMachine::DisconnectingState::Enter() +void StaStateMachine::StaDisconnectingState::GoInState() { - LOGI("DisconnectingState Enter function."); + LOGI("DisconnectingState GoInState function."); return; } -void StaStateMachine::DisconnectingState::Exit() +void StaStateMachine::StaDisconnectingState::GoOutState() {} -bool StaStateMachine::DisconnectingState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaDisconnectingState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; LOGI("DefaultState-msgCode=%{public}d not handled.\n", msg->GetMessageName()); return ret; } /* --------------------------- state machine Disconnected State ------------------------------ */ -StaStateMachine::DisconnectedState::DisconnectedState(StaStateMachine *staStateMachine) : State("DisconnectedState") +StaStateMachine::StaDisconnectedState::StaDisconnectedState(StaStateMachine *staStateMachine) + : State("StaDisconnectedState") { pStaStateMachine = staStateMachine; } -StaStateMachine::DisconnectedState::~DisconnectedState() +StaStateMachine::StaDisconnectedState::~StaDisconnectedState() {} -void StaStateMachine::DisconnectedState::Enter() +void StaStateMachine::StaDisconnectedState::GoInState() { - LOGI("DisconnectedState Enter function."); + LOGI("DisconnectedState GoInState function."); return; } -void StaStateMachine::DisconnectedState::Exit() +void StaStateMachine::StaDisconnectedState::GoOutState() {} -bool StaStateMachine::DisconnectedState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaDisconnectedState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_COM_STA_SET_COUNTRY_CODE: { - ret = HANDLED; + ret = EXECUTED; /* Get code from config center. */ std::string countryCode; WifiSettings::GetInstance().GetCountryCode(countryCode); @@ -1107,7 +1111,7 @@ bool StaStateMachine::DisconnectedState::ProcessMessage(InternalMessage *msg) break; case WIFI_SVR_CMD_STA_ENABLE_WIFI: { - ret = HANDLED; + ret = EXECUTED; LOGE("Wifi has already started! start Wifi failed!"); /* Notify result to InterfaceService. */ pStaStateMachine->NotifyResult( @@ -1128,43 +1132,44 @@ void StaStateMachine::SetCountryCode() } /* --------------------------- state machine ApConnected State ------------------------------ */ -StaStateMachine::ApConnectedState::ApConnectedState(StaStateMachine *staStateMachine) : State("ApConnectedState") +StaStateMachine::StaConnectedApState::StaConnectedApState(StaStateMachine *staStateMachine) + : State("StaConnectedApState") { pStaStateMachine = staStateMachine; } -StaStateMachine::ApConnectedState::~ApConnectedState() +StaStateMachine::StaConnectedApState::~StaConnectedApState() {} -void StaStateMachine::ApConnectedState::Enter() +void StaStateMachine::StaConnectedApState::GoInState() { - LOGI("ApConnectedState Enter function."); + LOGI("ApConnectedState GoInState function."); return; } -void StaStateMachine::ApConnectedState::Exit() +void StaStateMachine::StaConnectedApState::GoOutState() {} -bool StaStateMachine::ApConnectedState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaConnectedApState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { /* The current state of StaStateMachine transfers to DisConnectingState when * receive the disconnecting message. */ case WIFI_SVR_CMD_STA_DISCONNECT: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->DisConnectProcess(); break; } case CMD_SYNC_LINKINFO: { - ret = HANDLED; - pStaStateMachine->linkedInfo.rssi = msg->GetArg1(); - pStaStateMachine->linkedInfo.frequency = msg->GetArg2(); + ret = EXECUTED; + pStaStateMachine->linkedInfo.rssi = msg->GetParam1(); + pStaStateMachine->linkedInfo.frequency = msg->GetParam2(); pStaStateMachine->GetBandFromFreQuencies(pStaStateMachine->linkedInfo.frequency); WifiSettings::GetInstance().SaveLinkedInfo(pStaStateMachine->linkedInfo); std::string mgmt = msg->GetStringFromMessage(); @@ -1172,18 +1177,18 @@ bool StaStateMachine::ApConnectedState::ProcessMessage(InternalMessage *msg) break; } case WIFI_SVR_CMD_STA_NETWORK_CONNECTION_EVENT: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->StopTimer(static_cast(WPA_BLOCK_LIST_CLEAR_EVENT)); LOGI("Stop clearing wpa block list"); /* Save linkedinfo */ - pStaStateMachine->linkedInfo.networkId = msg->GetArg1(); + pStaStateMachine->linkedInfo.networkId = msg->GetParam1(); pStaStateMachine->linkedInfo.bssid = msg->GetStringFromMessage(); WifiSettings::GetInstance().SaveLinkedInfo(pStaStateMachine->linkedInfo); break; } case CMD_GET_NETWORK_SPEED: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->pNetSpeed->GetNetSpeed( pStaStateMachine->linkedInfo.rxLinkSpeed, pStaStateMachine->linkedInfo.txLinkSpeed); /* Obtains rate */ WifiSettings::GetInstance().SaveLinkedInfo(pStaStateMachine->linkedInfo); @@ -1243,7 +1248,7 @@ void StaStateMachine::DisConnectProcess() WifiInternalMsgCode::STA_DISCONNECT_RES, static_cast(OperateResState::DISCONNECT_DISCONNECTING)); /* The current state of StaStateMachine transfers to DisconnectedState. */ - TransitionTo(pDisconnectedState); + SwitchState(pDisconnectedState); } else { NotifyResult( WifiInternalMsgCode::STA_DISCONNECT_RES, static_cast(OperateResState::DISCONNECT_DISCONNECT_FAILED)); @@ -1278,37 +1283,37 @@ void StaStateMachine::GetBandFromFreQuencies(const int &freQuency) } /* --------------------------- state machine Wps State ------------------------------ */ -StaStateMachine::WpsState::WpsState(StaStateMachine *staStateMachine) : State("WpsState") +StaStateMachine::StaWpsState::StaWpsState(StaStateMachine *staStateMachine) : State("StaWpsState") { pStaStateMachine = staStateMachine; } -StaStateMachine::WpsState::~WpsState() +StaStateMachine::StaWpsState::~StaWpsState() {} -void StaStateMachine::WpsState::Enter() +void StaStateMachine::StaWpsState::GoInState() { - LOGI("WpsState Enter function."); + LOGI("WpsState GoInState function."); return; } -void StaStateMachine::WpsState::Exit() +void StaStateMachine::StaWpsState::GoOutState() {} -bool StaStateMachine::WpsState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaWpsState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_CMD_STA_WPS_START_EVENT: { /* Wps starts successfully and Wait until the connection is complete. */ break; } case WIFI_SVR_CMD_STA_NETWORK_CONNECTION_EVENT: { - ret = HANDLED; + ret = EXECUTED; /* Stop clearing the Wpa_blocklist. */ pStaStateMachine->StopTimer(static_cast(WPA_BLOCK_LIST_CLEAR_EVENT)); @@ -1318,12 +1323,12 @@ bool StaStateMachine::WpsState::ProcessMessage(InternalMessage *msg) /* Notify result to InterfaceService. */ pStaStateMachine->NotifyResult( WifiInternalMsgCode::STA_CONNECT_RES, static_cast(OperateResState::CONNECT_AP_CONNECTED)); - pStaStateMachine->TransitionTo(pStaStateMachine->pObtainingIpState); + pStaStateMachine->SwitchState(pStaStateMachine->pObtainingIpState); break; } case WIFI_SVR_CMD_STA_STARTWPS: { - ret = HANDLED; - auto setup = static_cast(msg->GetArg1()); + ret = EXECUTED; + auto setup = static_cast(msg->GetParam1()); /* Notify InterfaceService that wps has started successfully. */ LOGE("WPS has already started, start wps failed!"); if (setup == SetupMethod::PBC) { @@ -1336,16 +1341,16 @@ bool StaStateMachine::WpsState::ProcessMessage(InternalMessage *msg) break; } case WIFI_SVR_CMD_STA_WPS_OVERLAP_EVENT: { - ret = HANDLED; + ret = EXECUTED; LOGI("Wps PBC Overlap!"); /* Notify InterfaceService that PBC is conflicting. */ pStaStateMachine->NotifyResult( WifiInternalMsgCode::STA_START_WPS_RES, static_cast(WpsStartState::START_PBC_FAILED_OVERLAP)); - pStaStateMachine->TransitionTo(pStaStateMachine->pDisconnectedState); + pStaStateMachine->SwitchState(pStaStateMachine->pDisconnectedState); break; } case WIFI_SVR_CMD_STA_CANCELWPS: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->SyncAllDeviceConfigs(); pStaStateMachine->DealCancelWpsCmd(msg); break; @@ -1361,7 +1366,7 @@ void StaStateMachine::SyncAllDeviceConfigs() std::vector result; WifiIdlDeviceConfig idlConfig; if (WifiSettings::GetInstance().GetDeviceConfig(result) != -1) { - for (std::vector::iterator it = result.begin(); it != result.end(); it++) { + for (std::vector::iterator it = result.begin(); it != result.end(); ++it) { if (isWpsConnect == IsWpsConnected::WPS_CONNECTED && it->networkId == 0) { continue; } @@ -1393,17 +1398,18 @@ void StaStateMachine::SyncAllDeviceConfigs() } /* --------------------------- state machine ObtainingIp State ------------------------------ */ -StaStateMachine::ObtainingIpState::ObtainingIpState(StaStateMachine *staStateMachine) : State("ObtainingIpState") +StaStateMachine::StaObtainingIpState::StaObtainingIpState(StaStateMachine *staStateMachine) + : State("StaObtainingIpState") { pStaStateMachine = staStateMachine; } -StaStateMachine::ObtainingIpState::~ObtainingIpState() +StaStateMachine::StaObtainingIpState::~StaObtainingIpState() {} -void StaStateMachine::ObtainingIpState::Enter() +void StaStateMachine::StaObtainingIpState::GoInState() { - LOGI("ObtainingIpState Enter function."); + LOGI("ObtainingIpState GoInState function."); WifiDeviceConfig config; AssignIpMethod assignMethod = AssignIpMethod::DHCP; @@ -1434,16 +1440,16 @@ void StaStateMachine::ObtainingIpState::Enter() return; } -void StaStateMachine::ObtainingIpState::Exit() +void StaStateMachine::StaObtainingIpState::GoOutState() {} -bool StaStateMachine::ObtainingIpState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaObtainingIpState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; LOGI("DefaultState-msgCode=%{public}d not handled.\n", msg->GetMessageName()); return ret; } @@ -1581,7 +1587,7 @@ void StaStateMachine::HandleNetCheckResult(StaNetState netState) statusId = static_cast(WifiDeviceConfigStatus::ENABLED); NotifyResult(WifiInternalMsgCode::STA_CONNECT_RES, static_cast(OperateResState::CONNECT_NETWORK_ENABLED)); /* The current state of StaStateMachine transfers to ConnectedState. */ - TransitionTo(pConnectedState); + SwitchState(pConnectedState); } else { LOGI("HandleNetCheckResult network state is notworking\n"); SaveLinkstate(ConnState::CONNECTED, DetailedState::NOTWORKING); @@ -1615,78 +1621,78 @@ int StaStateMachine::PortalHttpDetection() } /* --------------------------- state machine Connected State ------------------------------ */ -StaStateMachine::ConnectedState::ConnectedState(StaStateMachine *staStateMachine) : State("ConnectedState") +StaStateMachine::StaConnectedState::StaConnectedState(StaStateMachine *staStateMachine) : State("StaConnectedState") { pStaStateMachine = staStateMachine; } -StaStateMachine::ConnectedState::~ConnectedState() +StaStateMachine::StaConnectedState::~StaConnectedState() {} -void StaStateMachine::ConnectedState::Enter() +void StaStateMachine::StaConnectedState::GoInState() { - LOGI("ConnectedState Enter function."); + LOGI("ConnectedState GoInState function."); return; } -void StaStateMachine::ConnectedState::Exit() +void StaStateMachine::StaConnectedState::GoOutState() { - LOGI("ConnectedState Exit function."); + LOGI("ConnectedState GoOutState function."); } -bool StaStateMachine::ConnectedState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaConnectedState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = HANDLED; + bool ret = EXECUTED; LOGI("DefaultState-msgCode=%{public}d not handled.\n", msg->GetMessageName()); return ret; } /* --------------------------- state machine Roaming State ------------------------------ */ -StaStateMachine::RoamingState::RoamingState(StaStateMachine *staStateMachine) : State("RoamingState") +StaStateMachine::StaRoamingState::StaRoamingState(StaStateMachine *staStateMachine) : State("StaRoamingState") { pStaStateMachine = staStateMachine; } -StaStateMachine::RoamingState::~RoamingState() +StaStateMachine::StaRoamingState::~StaRoamingState() {} -void StaStateMachine::RoamingState::Enter() +void StaStateMachine::StaRoamingState::GoInState() { - LOGI("RoamingState Enter function."); + LOGI("RoamingState GoInState function."); } -void StaStateMachine::RoamingState::Exit() +void StaStateMachine::StaRoamingState::GoOutState() {} -bool StaStateMachine::RoamingState::ProcessMessage(InternalMessage *msg) +bool StaStateMachine::StaRoamingState::ExecuteStateMsg(InternalMessage *msg) { if (msg == nullptr) { return false; } - bool ret = NOT_HANDLED; + bool ret = NOT_EXECUTED; switch (msg->GetMessageName()) { case WIFI_SVR_CMD_STA_NETWORK_CONNECTION_EVENT: { - ret = HANDLED; + ret = EXECUTED; pStaStateMachine->ConnectToNetworkProcess(msg); /* Notify result to InterfaceService. */ pStaStateMachine->NotifyResult( WifiInternalMsgCode::STA_CONNECT_RES, static_cast(OperateResState::CONNECT_AP_CONNECTED)); /* The current state of StaStateMachine transfers to ObtainingIpState. */ - pStaStateMachine->TransitionTo(pStaStateMachine->pObtainingIpState); + pStaStateMachine->SwitchState(pStaStateMachine->pObtainingIpState); break; } default: break; } - return HANDLED; + return EXECUTED; } void StaStateMachine::ConnectToNetworkProcess(InternalMessage *msg) @@ -1695,7 +1701,7 @@ void StaStateMachine::ConnectToNetworkProcess(InternalMessage *msg) return; } - lastNetworkId = msg->GetArg1(); + lastNetworkId = msg->GetParam1(); std::string bssid = msg->GetStringFromMessage(); WifiDeviceConfig deviceConfig; @@ -1838,12 +1844,6 @@ void StaStateMachine::SetOperationalMode(int mode) SendMessage(WIFI_SVR_CMD_STA_OPERATIONAL_MODE, mode, 0); } -bool StaStateMachine::SetTargetBssid(const WifiDeviceConfig &config, std::string &bssid) -{ - LOGI("enter SetTargetBssid![%s]\n", bssid.c_str()); - return true; -} - void StaStateMachine::MacAddressGenerate(std::string &strMac) { char szMacStr[] = "0123456789abcdef"; diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h index 7addc05c3d1e20c505b9128c5faba502aec27fe0..a16fa5d857000565dfcb51d375a76ed0d3a0ad73 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h @@ -69,13 +69,13 @@ public: * @Description Definition of member function of State base class in StaStateMachine. * */ - class DefaultState : public State { + class StaDefaultState : public State { public: - explicit DefaultState(StaStateMachine *pStaStateMachine); - ~DefaultState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaDefaultState(StaStateMachine *pStaStateMachine); + ~StaDefaultState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -84,13 +84,13 @@ public: * @Description : Definition of member function of InitState class in StaStateMachine. * */ - class InitState : public State { + class StaInitState : public State { public: - explicit InitState(StaStateMachine *pStaStateMachine); - ~InitState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaInitState(StaStateMachine *pStaStateMachine); + ~StaInitState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; void CleanUp(); private: @@ -100,14 +100,14 @@ public: * @Description : Definition of member function of WpaStartingState class in StaStateMachine. * */ - class WpaStartingState : public State { + class StaWpaStartingState : public State { public: - explicit WpaStartingState(StaStateMachine *pStaStateMachine); - ~WpaStartingState() override; + explicit StaWpaStartingState(StaStateMachine *pStaStateMachine); + ~StaWpaStartingState() override; void InitWpsSettings(); - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -116,13 +116,13 @@ public: * @Description Definition of member function of WpaStartedState class in StaStateMachine. * */ - class WpaStartedState : public State { + class StaWpaStartedState : public State { public: - explicit WpaStartedState(StaStateMachine *pStaStateMachine); - ~WpaStartedState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaWpaStartedState(StaStateMachine *pStaStateMachine); + ~StaWpaStartedState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -131,13 +131,13 @@ public: * @Description Definition of member function of WpaStoppingState class in StaStateMachine. * */ - class WpaStoppingState : public State { + class StaWpaStoppingState : public State { public: - explicit WpaStoppingState(StaStateMachine *pStaStateMachine); - ~WpaStoppingState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaWpaStoppingState(StaStateMachine *pStaStateMachine); + ~StaWpaStoppingState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -146,13 +146,13 @@ public: * @Description Definition of member function of ConnectState class in StaStateMachine. * */ - class ConnectState : public State { + class StaConnectState : public State { public: - explicit ConnectState(StaStateMachine *pStaStateMachine); - ~ConnectState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaConnectState(StaStateMachine *pStaStateMachine); + ~StaConnectState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -161,13 +161,13 @@ public: * @Description Definition of member function of DisconnectingState class in StaStateMachine. * */ - class DisconnectingState : public State { + class StaDisconnectingState : public State { public: - explicit DisconnectingState(StaStateMachine *pStaStateMachine); - ~DisconnectingState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaDisconnectingState(StaStateMachine *pStaStateMachine); + ~StaDisconnectingState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -176,13 +176,13 @@ public: * @Description Definition of member function of DisconnectedState class in StaStateMachine. * */ - class DisconnectedState : public State { + class StaDisconnectedState : public State { public: - explicit DisconnectedState(StaStateMachine *pStaStateMachine); - ~DisconnectedState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaDisconnectedState(StaStateMachine *pStaStateMachine); + ~StaDisconnectedState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -191,13 +191,13 @@ public: * @Description Definition of member function of ApConnectedState class in StaStateMachine. * */ - class ApConnectedState : public State { + class StaConnectedApState : public State { public: - explicit ApConnectedState(StaStateMachine *pStaStateMachine); - ~ApConnectedState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaConnectedApState(StaStateMachine *pStaStateMachine); + ~StaConnectedApState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -206,13 +206,13 @@ public: * @Description Definition of member function of WpsState class in StaStateMachine. * */ - class WpsState : public State { + class StaWpsState : public State { public: - explicit WpsState(StaStateMachine *pStaStateMachine); - ~WpsState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaWpsState(StaStateMachine *pStaStateMachine); + ~StaWpsState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -221,13 +221,13 @@ public: * @Description Definition of member function of ObtainingIpState class in StaStateMachine. * */ - class ObtainingIpState : public State { + class StaObtainingIpState : public State { public: - explicit ObtainingIpState(StaStateMachine *pStaStateMachine); - ~ObtainingIpState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaObtainingIpState(StaStateMachine *pStaStateMachine); + ~StaObtainingIpState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -236,13 +236,13 @@ public: * @Description Definition of member function of ConnectedState class in StaStateMachine. * */ - class ConnectedState : public State { + class StaConnectedState : public State { public: - explicit ConnectedState(StaStateMachine *pStaStateMachine); - ~ConnectedState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaConnectedState(StaStateMachine *pStaStateMachine); + ~StaConnectedState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -251,13 +251,13 @@ public: * @Description Definition of member function of RoamingState class in StaStateMachine. * */ - class RoamingState : public State { + class StaRoamingState : public State { public: - explicit RoamingState(StaStateMachine *pStaStateMachine); - ~RoamingState() override; - void Enter() override; - void Exit() override; - bool ProcessMessage(InternalMessage *msg) override; + explicit StaRoamingState(StaStateMachine *pStaStateMachine); + ~StaRoamingState() override; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(InternalMessage *msg) override; private: StaStateMachine *pStaStateMachine; @@ -282,10 +282,6 @@ public: * @param msgCode - operating results code.(in) */ void NotifyResult(int msgCode, int stateCode = 0); - void OnQuitting() - {} - void OnHalting() - {} /** * @Description Start roaming connection. * @@ -428,14 +424,6 @@ private: void SetOperationalMode(int mode); void SetSuspendMode(bool enabled); void SetPowerSave(bool enabled); - /** - * @Description Setting target Bssid - * - * @param config - Wifi device config(in) - * @param bssid - the mac address of wifi(in) - * @return success: true failed: false - */ - bool SetTargetBssid(const WifiDeviceConfig &config, std::string &bssid); /** * @Description Configure static ipaddress. * @@ -593,19 +581,19 @@ private: StaNetworkCheck *pNetcheck; WifiMessageQueue *msgQueueUp; /* Uplink message queue. */ - DefaultState *pDefaultState; - InitState *pInitState; - WpaStartingState *pWpaStartingState; /* Starting wpa_supplicant state. */ - WpaStartedState *pWpaStartedState; /* Started wpa_supplicant state. */ - WpaStoppingState *pWpaStoppingState; /* Stopping wpa_supplicant state. */ - ConnectState *pConnectState; - DisconnectingState *pDisconnectingState; - DisconnectedState *pDisconnectedState; - ApConnectedState *pApConnectedState; - WpsState *pWpsState; - ObtainingIpState *pObtainingIpState; - ConnectedState *pConnectedState; - RoamingState *pRoamingState; + StaDefaultState *pDefaultState; + StaInitState *pInitState; + StaWpaStartingState *pWpaStartingState; /* Starting wpa_supplicant state. */ + StaWpaStartedState *pWpaStartedState; /* Started wpa_supplicant state. */ + StaWpaStoppingState *pWpaStoppingState; /* Stopping wpa_supplicant state. */ + StaConnectState *pConnectState; + StaDisconnectingState *pDisconnectingState; + StaDisconnectedState *pDisconnectedState; + StaConnectedApState *pApConnectedState; + StaWpsState *pWpsState; + StaObtainingIpState *pObtainingIpState; + StaConnectedState *pConnectedState; + StaRoamingState *pRoamingState; }; } // namespace Wifi } // namespace OHOS diff --git a/services/wifi_standard/wifi_hal/wifi_hal_crpc_server.c b/services/wifi_standard/wifi_hal/wifi_hal_crpc_server.c index b2974e795088d1b952c1546e85c2ea6602cfb4c1..5fb58ccc675c9820f977aa8032c591aa1b60fa72 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_crpc_server.c +++ b/services/wifi_standard/wifi_hal/wifi_hal_crpc_server.c @@ -134,13 +134,6 @@ static int InitRpcFuncMapSta(void) ret += PushRpcFunc("Reconnect", RpcReconnect); ret += PushRpcFunc("Reassociate", RpcReassociate); ret += PushRpcFunc("Disconnect", RpcDisconnect); - ret += PushRpcFunc("SetExternalSim", RpcSetExternalSim); - ret += PushRpcFunc("SetBluetoothCoexistenceScanMode", RpcSetBluetoothCoexistenceScanMode); - ret += PushRpcFunc("StopFilteringMulticastV4Packets", RpcStopFilteringMulticastV4Packets); - ret += PushRpcFunc("StopFilteringMulticastV6Packets", RpcStopFilteringMulticastV6Packets); - ret += PushRpcFunc("EnableStaAutoReconnect", RpcEnableStaAutoReconnect); - ret += PushRpcFunc("SetConcurrencyPriority", RpcSetConcurrencyPriority); - ret += PushRpcFunc("SetSuspendModeEnabled", RpcSetSuspendModeEnabled); ret += PushRpcFunc("GetStaCapabilities", RpcGetStaCapabilities); ret += PushRpcFunc("GetDeviceMacAddress", RpcGetDeviceMacAddress); ret += PushRpcFunc("GetFrequencies", RpcGetFrequencies); diff --git a/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.c b/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.c index 92088c2d6a17aad461579d42195cadcc42bfcc95..9cac99b759afedb5c6e4f46358cf1369c6f48d15 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.c +++ b/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.c @@ -122,8 +122,8 @@ int RpcGetScanResults(RpcServer *server, Context *context) WriteInt(context, results[i].siglv); WriteStr(context, results[i].flags); WriteStr(context, results[i].ssid); - long currTime = clockTime.tv_sec * secComplex * secComplex + clockTime.tv_nsec / secComplex; - WriteLong(context, currTime); + int64_t currTime = (int64_t)clockTime.tv_sec * secComplex * secComplex + clockTime.tv_nsec / secComplex; + WriteInt64(context, currTime); } } WriteEnd(context); @@ -268,110 +268,6 @@ int RpcDisconnect(RpcServer *server, Context *context) return 0; } -int RpcSetExternalSim(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - int useExternalSim = 0; - if (ReadInt(context, &useExternalSim) < 0) { - return -1; - } - WifiErrorNo err = SetExternalSim(useExternalSim); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcSetBluetoothCoexistenceScanMode(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - int mode = 0; - if (ReadInt(context, &mode) < 0) { - return -1; - } - WifiErrorNo err = SetBluetoothCoexistenceScanMode(mode); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcStopFilteringMulticastV4Packets(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - WifiErrorNo err = StopFilteringMulticastV4Packets(); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcStopFilteringMulticastV6Packets(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - WifiErrorNo err = StopFilteringMulticastV6Packets(); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcEnableStaAutoReconnect(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - int enable = 0; - if (ReadInt(context, &enable) < 0) { - return -1; - } - WifiErrorNo err = EnableStaAutoReconnect(enable); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcSetConcurrencyPriority(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - int isStaHigherPriority = 0; - if (ReadInt(context, &isStaHigherPriority) < 0) { - return -1; - } - WifiErrorNo err = SetConcurrencyPriority(isStaHigherPriority); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - -int RpcSetSuspendModeEnabled(RpcServer *server, Context *context) -{ - if (server == NULL || context == NULL) { - return -1; - } - int enable = 0; - if (ReadInt(context, &enable) < 0) { - return -1; - } - WifiErrorNo err = SetSuspendModeEnabled(enable); - WriteBegin(context, 0); - WriteInt(context, err); - WriteEnd(context); - return 0; -} - int RpcGetStaCapabilities(RpcServer *server, Context *context) { if (server == NULL || context == NULL) { diff --git a/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.h b/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.h index f667506890c8d9be7b8f476b4a4019ce7feeb9f4..9b6d47e1744fe92d76dd418dc07c72e57bfc5580 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.h +++ b/services/wifi_standard/wifi_hal/wifi_hal_crpc_sta.h @@ -118,76 +118,6 @@ int RpcReassociate(RpcServer *server, Context *context); */ int RpcDisconnect(RpcServer *server, Context *context); -/** - * @Description Parse the context to obtain data. Call the corresponding function - * SetExternalSim and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcSetExternalSim(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * SetBluetoothCoexistenceScanMode and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcSetBluetoothCoexistenceScanMode(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * StopFilteringMulticastV4Packets and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcStopFilteringMulticastV4Packets(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * StopFilteringMulticastV6Packets and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcStopFilteringMulticastV6Packets(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * EnableStaAutoReconnect and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcEnableStaAutoReconnect(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * SetConcurrencyPriority and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcSetConcurrencyPriority(RpcServer *server, Context *context); - -/** - * @Description Parse the context to obtain data. Call the corresponding function - * SetSuspendModeEnabled and assemble the function to obtain data. - * - * @param server - Pointer to the global structure of the communication server. - * @param context - Pointer to the global communication context structure of the server. - * @return int - 0 Success, -1 Failed. - */ -int RpcSetSuspendModeEnabled(RpcServer *server, Context *context); - /** * @Description Parse the context to obtain data. Call the corresponding function * GetStaCapabilities and assemble the function to obtain data. diff --git a/services/wifi_standard/wifi_hal/wifi_hal_define.h b/services/wifi_standard/wifi_hal/wifi_hal_define.h index e208c0c44f663f47081878b70d8e9aba9850356f..cc65c994b7d661a4bdc713036732b8da9d04ea4f 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_define.h +++ b/services/wifi_standard/wifi_hal/wifi_hal_define.h @@ -82,7 +82,7 @@ typedef enum WifiHalEvent { } WifiHalEvent; #define WIFI_BSSID_LENGTH 128 -#define WIFI_SSID_LENGTH 128 +#define WIFI_SSID_LENGTH 132 #define WIFI_SCAN_RESULT_CAPABILITY_LENGTH 256 #define WIFI_NETWORK_CONFIG_VALUE_LENGTH 128 #define WIFI_MAC_LENGTH 17 diff --git a/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.c b/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.c index ee0d7ae58c1f84edf6040352aa041419a233f087..6a13f1b911666b3d668534a5f160948c9dfd45f2 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.c +++ b/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.c @@ -349,48 +349,6 @@ WifiErrorNo SetPowerSave(BOOL enable) return WIFI_HAL_SUCCESS; } -WifiErrorNo SetExternalSim(int useExternalSim) -{ - LOGD("SetExternalSim() %{public}d", useExternalSim); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo SetBluetoothCoexistenceScanMode(int mode) -{ - LOGD("SetBluetoothCoexistenceScanMode() %{public}d", mode); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo StopFilteringMulticastV4Packets(void) -{ - LOGD("StopFilteringMulticastV4Packets()"); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo StopFilteringMulticastV6Packets(void) -{ - LOGD("StopFilteringMulticastV6Packets()"); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo EnableStaAutoReconnect(int enable) -{ - LOGD("EnableStaAutoReconnect() %{public}d", enable); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo SetConcurrencyPriority(int isStaHigherPriority) -{ - LOGD("SetConcurrencyPriority() %{public}d", isStaHigherPriority); - return WIFI_HAL_SUCCESS; -} - -WifiErrorNo SetSuspendModeEnabled(int enable) -{ - LOGD("SetSuspendModeEnabled() %{public}d", enable); - return WIFI_HAL_SUCCESS; -} - WifiErrorNo GetStaCapabilities(int32_t *capabilities) { LOGD("GetStaCapabilities: This function is not supported currently."); diff --git a/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.h b/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.h index d7777370193c2a04b6c62464f064d7bd57da061c..6beaa93db71505d09b9f49a2d5647dd8b2c3ef3c 100644 --- a/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.h +++ b/services/wifi_standard/wifi_hal/wifi_hal_sta_interface.h @@ -157,62 +157,6 @@ WifiErrorNo Disconnect(void); */ WifiErrorNo SetPowerSave(BOOL enable); -/** - * @Description Use DFS (Whether to use an external SIM card to process SIM/USIM cards). - * - * @param useExternalSim - Bool value, whether to use. - * @return WifiErrorNo - */ -WifiErrorNo SetExternalSim(int useExternalSim); - -/** - * @Description Enable Bluetooth coexistence scanning mode. - * - * @param mode - Mode ID. - * @return WifiErrorNo - */ -WifiErrorNo SetBluetoothCoexistenceScanMode(int mode); - -/** - * @Description Filtering IPv4 Multicast Packets. - * - * @return WifiErrorNo - */ -WifiErrorNo StopFilteringMulticastV4Packets(void); - -/** - * @Description Filtering IPv6 Multicast Packets. - * - * @return WifiErrorNo - */ -WifiErrorNo StopFilteringMulticastV6Packets(void); - -/** - * @Description Set whether to enable automatic reconnection. - * - * @param enable - Bool value. - * @return WifiErrorNo - */ -WifiErrorNo EnableStaAutoReconnect(int enable); - -/** - * @Description Setting the Priority When STAs and P2P Services Coexist. - * - * @param isStaHigherPriority - Bool value Indicates whether the STA - * is preferentially selected. - * @return WifiErrorNo - */ -WifiErrorNo SetConcurrencyPriority(int isStaHigherPriority); - -/** - * @Description High-performance lock, which corresponds to disabling the - * suspend mode of wpa-supplicant. - * - * @param enable - Bool value. - * @return WifiErrorNo - */ -WifiErrorNo SetSuspendModeEnabled(int enable); - /** * @Description Obtaining the STA Support Capability. *