From 068b5e60cec209a33f6d550630ca52b6ec90f995 Mon Sep 17 00:00:00 2001 From: cheng_guohong Date: Tue, 15 Jun 2021 14:42:48 +0800 Subject: [PATCH] add the wifi event Signed-off-by: cheng_guohong --- .../wifi_standard/interfaces/wifi_msg.h | 2 +- .../common/utils/wifi_common_event_helper.cpp | 127 +++++++++++++++ .../common/utils/wifi_common_event_helper.h | 64 ++++++++ .../wifi_framework/wifi_manage/BUILD.gn | 19 ++- .../wifi_device_death_recipient.cpp | 4 +- .../wifi_manage/wifi_device_service_impl.cpp | 9 +- .../wifi_manage/wifi_device_stub.cpp | 4 +- .../wifi_hotspot_death_recipient.cpp | 4 +- .../wifi_manage/wifi_hotspot_service_impl.cpp | 4 +- .../wifi_manage/wifi_hotspot_stub.cpp | 4 +- ...cpp => wifi_internal_event_dispatcher.cpp} | 147 +++++++++++++----- ...ast.h => wifi_internal_event_dispatcher.h} | 22 +-- .../wifi_manage/wifi_manager.cpp | 28 ++-- .../wifi_manage/wifi_scan_callback_proxy.cpp | 6 +- .../wifi_manage/wifi_scan_death_recipient.cpp | 4 +- .../wifi_manage/wifi_scan_service_impl.cpp | 4 +- .../wifi_manage/wifi_scan_stub.cpp | 4 +- 17 files changed, 361 insertions(+), 95 deletions(-) create mode 100644 services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.cpp create mode 100644 services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.h rename services/wifi_standard/wifi_framework/wifi_manage/{wifi_event_broadcast.cpp => wifi_internal_event_dispatcher.cpp} (62%) rename services/wifi_standard/wifi_framework/wifi_manage/{wifi_event_broadcast.h => wifi_internal_event_dispatcher.h} (85%) 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 01689d95e..9ab1d70b6 100644 --- a/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h +++ b/interfaces/innerkits/native_cpp/wifi_standard/interfaces/wifi_msg.h @@ -468,4 +468,4 @@ struct WifiEvent { }; } // namespace Wifi } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.cpp b/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.cpp new file mode 100644 index 000000000..025013b99 --- /dev/null +++ b/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.cpp @@ -0,0 +1,127 @@ +/* + * 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_common_event_helper.h" +#include "common_event_manager.h" +#include "common_event.h" +#include "common_event_data.h" + +using namespace OHOS::EventFwk; +namespace OHOS { +namespace Wifi { +bool WifiCommonEventHelper::PublishEvent(const std::string &eventAction, const int &code, const std::string &data, + const std::vector &permissions) +{ + Want want; + want.SetAction(eventAction); + CommonEventData commonData; + commonData.SetWant(want); + commonData.SetCode(code); + commonData.SetData(data); + if (permissions.size() > 0) { + CommonEventPublishInfo publishInfo; + publishInfo.SetSubscriberPermissions(permissions); + return CommonEventManager::PublishCommonEvent(commonData, publishInfo); + } + return CommonEventManager::PublishCommonEvent(commonData); +} + +bool WifiCommonEventHelper::PublishEvent(const std::string &eventAction, const int &code, const std::string &data) +{ + Want want; + want.SetAction(eventAction); + CommonEventData commonData; + commonData.SetWant(want); + commonData.SetCode(code); + commonData.SetData(data); + return CommonEventManager::PublishCommonEvent(commonData); +} + +bool WifiCommonEventHelper::PublishPowerStateChangeEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_POWER_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishScanFinishedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_SCAN_FINISHED, code, data); +} + +bool WifiCommonEventHelper::PublishScanStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_SCAN_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishRssiValueChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_RSSI_VALUE, code, data); +} + +bool WifiCommonEventHelper::PublishConnectionStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_CONN_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishHotspotStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_HOTSPOT_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishApStaJoinEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_AP_STA_JOIN, code, data); +} + +bool WifiCommonEventHelper::PublishApStaLeaveEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_AP_STA_LEAVE, code, data); +} + +bool WifiCommonEventHelper::PublishMPlinkEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_MPLINK_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishP2pStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_STATE_CHANGED, code, data); +} + +bool WifiCommonEventHelper::PublishP2pConnStateEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_CONN_STATE, code, data); +} + +bool WifiCommonEventHelper::PublishP2pPeersStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED, code, data); +} + +bool WifiCommonEventHelper::PublishP2pDicoveryStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED, code, data); +} + +bool WifiCommonEventHelper::PublishP2pCurrentDeviceStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED, code, data); +} + +bool WifiCommonEventHelper::PublishP2pGroupStateChangedEvent(const int &code, const std::string &data) +{ + return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED, code, data); +} +} // namespace Wifi +} // namespace OHOS diff --git a/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.h b/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.h new file mode 100644 index 000000000..028f25d1c --- /dev/null +++ b/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.h @@ -0,0 +1,64 @@ +/* + * 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_WIFI_COMMON_EVENT_HELPER_H +#define OHOS_WIFI_COMMON_EVENT_HELPER_H + +#include +#include "common_event_subscriber.h" + +namespace OHOS { +namespace Wifi { +const std::string COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE"; +const std::string COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED"; +const std::string COMMON_EVENT_WIFI_SCAN_STATE = "usual.event.wifi.SCAN_STATE"; +const std::string COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE"; +const std::string COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE"; +const std::string COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE"; +const std::string COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN"; +const std::string COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE"; +const std::string COMMON_EVENT_WIFI_MPLINK_STATE = "usual.event.wifi.mplink.STATE_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = + "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE"; +const std::string COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED"; +class WifiCommonEventHelper { +public: + static bool PublishEvent(const std::string &eventAction, const int &code, const std::string &data, + const std::vector &permissions); + + static bool PublishEvent(const std::string &eventAction, const int &code, const std::string &data); + static bool PublishPowerStateChangeEvent(const int &code, const std::string &data); + static bool PublishScanFinishedEvent(const int &code, const std::string &data); + static bool PublishScanStateChangedEvent(const int &code, const std::string &data); + static bool PublishRssiValueChangedEvent(const int &code, const std::string &data); + static bool PublishConnectionStateChangedEvent(const int &code, const std::string &data); + static bool PublishHotspotStateChangedEvent(const int &code, const std::string &data); + static bool PublishApStaJoinEvent(const int &code, const std::string &data); + static bool PublishApStaLeaveEvent(const int &code, const std::string &data); + static bool PublishMPlinkEvent(const int &code, const std::string &data); + static bool PublishP2pStateChangedEvent(const int &code, const std::string &data); + static bool PublishP2pConnStateEvent(const int &code, const std::string &data); + static bool PublishP2pPeersStateChangedEvent(const int &code, const std::string &data); + static bool PublishP2pDicoveryStateChangedEvent(const int &code, const std::string &data); + static bool PublishP2pCurrentDeviceStateChangedEvent(const int &code, const std::string &data); + static bool PublishP2pGroupStateChangedEvent(const int &code, const std::string &data); +}; +} // namespace Wifi +} // namespace OHOS +#endif diff --git a/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn b/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn index 2a28068d3..37af145d4 100755 --- a/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn +++ b/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/ohos/sa_profile/sa_profile.gni") import("//build/ohos_var.gni") - +import("//foundation/appexecfwk/standard/appexecfwk.gni") ################################################################################ config("wifi_manager_service_header") { @@ -35,6 +35,16 @@ config("wifi_manager_service_header") { "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/common", "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/idl_client", "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/idl_client/idl_interface", + "${even_path}/cesfwk/kits/native/include", + "${even_path}/cesfwk/innerkits/include", + "${aafwk_path}/interfaces/innerkits/want/include", + "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "//foundation/aafwk/intent/interfaces/innerkits/base/include", + "//foundation/appexecfwk/adapter/interfaces/innerkits/appexecfwk_base/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/aafwk/standard/interfaces/innerkits/base/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include" ] } @@ -108,9 +118,10 @@ ohos_shared_library("wifi_manager_service") { "//foundation/communication/wifi/services/wifi_standard/wifi_framework/common/utils/wifi_global_func.cpp", "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/common/wifi_permission_helper.cpp", "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/common/wifi_permission_utils.cpp", + "//foundation/communication/wifi/services/wifi_standard/wifi_framework/common/utils/wifi_common_event_helper.cpp", "wifi_auth_center.cpp", "wifi_config_center.cpp", - "wifi_event_broadcast.cpp", + "wifi_internal_event_dispatcher.cpp", "wifi_manager.cpp", "wifi_service_manager.cpp", ] @@ -121,6 +132,10 @@ ohos_shared_library("wifi_manager_service") { "//foundation/communication/wifi/services/wifi_standard/wifi_framework/wifi_manage/idl_client:wifi_idl_client", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", "//utils/native/base:utils", + "${even_path}/common:libevent_common", + "${aafwk_path}/interfaces/innerkits/base:base", + "${aafwk_path}/interfaces/innerkits/want:want", + "//base/notification/ces_standard/cesfwk/kits/native:cesfwk_kits", ] defines = [ diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_death_recipient.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_death_recipient.cpp index 4650ff9d1..15400dcb1 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_death_recipient.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_death_recipient.cpp @@ -15,14 +15,14 @@ #include "wifi_device_death_recipient.h" #include "wifi_logger.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" DEFINE_WIFILOG_LABEL("WifiDeviceDeathRecipient"); namespace OHOS { namespace Wifi { void WifiDeviceDeathRecipient::OnRemoteDied(const wptr& remoteObject) { WIFI_LOGD("WifiDeviceDeathRecipient::OnRemoteDied!"); - WifiEventBroadcast::GetInstance().RemoveStaCallback(remoteObject.promote()); + WifiInternalEventDispatcher::GetInstance().RemoveStaCallback(remoteObject.promote()); } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_service_impl.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_service_impl.cpp index f6c43f138..640437753 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_service_impl.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_device_service_impl.cpp @@ -19,7 +19,7 @@ #include "wifi_internal_msg.h" #include "wifi_auth_center.h" #include "wifi_config_center.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_manager.h" #include "wifi_service_manager.h" #include "wifi_logger.h" @@ -490,12 +490,7 @@ ErrCode WifiDeviceServiceImpl::RegisterCallBackClient( return WIFI_OPT_PERMISSION_DENIED; } - if (WifiPermissionUtils::VerifyWifiConnectionPermission() == PERMISSION_DENIED) { - WIFI_LOGE("RegisterCallBackClient:VerifyWifiConnectionPermission() PERMISSION_DENIED!"); - return WIFI_OPT_PERMISSION_DENIED; - } - - WifiEventBroadcast::GetInstance().SetSingleStaCallback(callback); + WifiInternalEventDispatcher::GetInstance().SetSingleStaCallback(callback); return WIFI_OPT_SUCCESS; } 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 a46bd1781..9fff104b3 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 @@ -18,7 +18,7 @@ #include "wifi_logger.h" #include "wifi_msg.h" #include "wifi_device_callback_proxy.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_device_death_recipient.h" DEFINE_WIFILOG_LABEL("WifiDeviceStub"); @@ -484,7 +484,7 @@ void WifiDeviceStub::OnRegisterCallBackClient(uint32_t code, MessageParcel &data WIFI_LOGD("AddDeathRecipient!"); } if (callback_ != nullptr) { - WifiEventBroadcast::GetInstance().AddStaCallback(remote, callback_); + WifiInternalEventDispatcher::GetInstance().AddStaCallback(remote, callback_); } ret = WIFI_OPT_SUCCESS; } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_death_recipient.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_death_recipient.cpp index e7bfd498f..79bb4a3bd 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_death_recipient.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_death_recipient.cpp @@ -15,14 +15,14 @@ #include "wifi_hotspot_death_recipient.h" #include "wifi_logger.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" DEFINE_WIFILOG_HOTSPOT_LABEL("WifiScanDeathRecipient"); namespace OHOS { namespace Wifi { void WifiHotspotDeathRecipient::OnRemoteDied(const wptr& remoteObject) { WIFI_LOGD("WifiHotspotDeathRecipient::OnRemoteDied!"); - WifiEventBroadcast::GetInstance().RemoveHotspotCallback(remoteObject.promote()); + WifiInternalEventDispatcher::GetInstance().RemoveHotspotCallback(remoteObject.promote()); } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_service_impl.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_service_impl.cpp index 35399badb..315c32a19 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_service_impl.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_hotspot_service_impl.cpp @@ -20,7 +20,7 @@ #include "wifi_config_center.h" #include "wifi_manager.h" #include "wifi_service_manager.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_logger.h" #include "define.h" #include "wifi_logger.h" @@ -483,7 +483,7 @@ ErrCode WifiHotspotServiceImpl::RegisterCallBack(const sptr &remote, const sptr &callback) +int WifiInternalEventDispatcher::AddStaCallback(const sptr &remote, const sptr &callback) { - WIFI_LOGD("WifiEventBroadcast::AddStaCallback!"); + WIFI_LOGD("WifiInternalEventDispatcher::AddStaCallback!"); if (remote == nullptr || callback == nullptr) { WIFI_LOGE("remote object is null!"); return 1; @@ -65,31 +66,31 @@ int WifiEventBroadcast::AddStaCallback(const sptr &remote, const return 0; } -int WifiEventBroadcast::RemoveStaCallback(const sptr &remote) +int WifiInternalEventDispatcher::RemoveStaCallback(const sptr &remote) { if (remote != nullptr) { std::unique_lock lock(mStaCallbackMutex); auto iter = mStaCallbacks.find(remote); if (iter != mStaCallbacks.end()) { mStaCallbacks.erase(iter); - WIFI_LOGD("WifiEventBroadcast::RemoveStaCallback!"); + WIFI_LOGD("WifiInternalEventDispatcher::RemoveStaCallback!"); } } return 0; } -int WifiEventBroadcast::SetSingleStaCallback(const sptr &callback) +int WifiInternalEventDispatcher::SetSingleStaCallback(const sptr &callback) { mStaSingleCallback = callback; return 0; } -sptr WifiEventBroadcast::GetSingleStaCallback() const +sptr WifiInternalEventDispatcher::GetSingleStaCallback() const { return mStaSingleCallback; } -bool WifiEventBroadcast::HasStaRemote(const sptr &remote) +bool WifiInternalEventDispatcher::HasStaRemote(const sptr &remote) { std::unique_lock lock(mStaCallbackMutex); if (remote != nullptr) { @@ -100,9 +101,9 @@ bool WifiEventBroadcast::HasStaRemote(const sptr &remote) return false; } -int WifiEventBroadcast::AddScanCallback(const sptr &remote, const sptr &callback) +int WifiInternalEventDispatcher::AddScanCallback(const sptr &remote, const sptr &callback) { - WIFI_LOGD("WifiEventBroadcast::AddCallbackClient!"); + WIFI_LOGD("WifiInternalEventDispatcher::AddCallbackClient!"); if (remote == nullptr || callback == nullptr) { WIFI_LOGE("remote object is null!"); return 1; @@ -111,31 +112,31 @@ int WifiEventBroadcast::AddScanCallback(const sptr &remote, const mScanCallbacks[remote] = callback; return 0; } -int WifiEventBroadcast::RemoveScanCallback(const sptr &remote) +int WifiInternalEventDispatcher::RemoveScanCallback(const sptr &remote) { if (remote != nullptr) { std::unique_lock lock(mScanCallbackMutex); auto iter = mScanCallbacks.find(remote); if (iter != mScanCallbacks.end()) { mScanCallbacks.erase(iter); - WIFI_LOGD("WifiEventBroadcast::RemoveScanCallback!"); + WIFI_LOGD("WifiInternalEventDispatcher::RemoveScanCallback!"); } } return 0; } -int WifiEventBroadcast::SetSingleScanCallback(const sptr &callback) +int WifiInternalEventDispatcher::SetSingleScanCallback(const sptr &callback) { mScanSingleCallback = callback; return 0; } -sptr WifiEventBroadcast::GetSingleScanCallback() const +sptr WifiInternalEventDispatcher::GetSingleScanCallback() const { return mScanSingleCallback; } -bool WifiEventBroadcast::HasScanRemote(const sptr &remote) +bool WifiInternalEventDispatcher::HasScanRemote(const sptr &remote) { std::unique_lock lock(mScanCallbackMutex); if (remote != nullptr) { @@ -146,10 +147,10 @@ bool WifiEventBroadcast::HasScanRemote(const sptr &remote) return false; } -int WifiEventBroadcast::AddHotspotCallback( +int WifiInternalEventDispatcher::AddHotspotCallback( const sptr &remote, const sptr &callback) { - WIFI_LOGD("WifiEventBroadcast::AddHotspotCallback!"); + WIFI_LOGD("WifiInternalEventDispatcher::AddHotspotCallback!"); if (remote == nullptr || callback == nullptr) { WIFI_LOGE("remote object is null!"); return 1; @@ -158,31 +159,31 @@ int WifiEventBroadcast::AddHotspotCallback( mHotspotCallbacks[remote] = callback; return 0; } -int WifiEventBroadcast::RemoveHotspotCallback(const sptr &remote) +int WifiInternalEventDispatcher::RemoveHotspotCallback(const sptr &remote) { if (remote != nullptr) { std::unique_lock lock(mHotspotCallbackMutex); auto iter = mHotspotCallbacks.find(remote); if (iter != mHotspotCallbacks.end()) { mHotspotCallbacks.erase(iter); - WIFI_LOGD("WifiEventBroadcast::RemoveHotspotCallback!"); + WIFI_LOGD("WifiInternalEventDispatcher::RemoveHotspotCallback!"); } } return 0; } -int WifiEventBroadcast::SetSingleHotspotCallback(const sptr &callback) +int WifiInternalEventDispatcher::SetSingleHotspotCallback(const sptr &callback) { mHotspotSingleCallback = callback; return 0; } -sptr WifiEventBroadcast::GetSingleHotspotCallback() const +sptr WifiInternalEventDispatcher::GetSingleHotspotCallback() const { return mHotspotSingleCallback; } -bool WifiEventBroadcast::HasHotspotRemote(const sptr &remote) +bool WifiInternalEventDispatcher::HasHotspotRemote(const sptr &remote) { std::unique_lock lock(mHotspotCallbackMutex); if (remote != nullptr) { @@ -193,9 +194,9 @@ bool WifiEventBroadcast::HasHotspotRemote(const sptr &remote) return false; } -int WifiEventBroadcast::AddBroadCastMsg(const WifiEventCallbackMsg &msg) +int WifiInternalEventDispatcher::AddBroadCastMsg(const WifiEventCallbackMsg &msg) { - WIFI_LOGD("WifiEventBroadcast::AddBroadCastMsg, msgcode %{public}d", msg.msgCode); + WIFI_LOGD("WifiInternalEventDispatcher::AddBroadCastMsg, msgcode %{public}d", msg.msgCode); { std::unique_lock lock(mMutex); mEventQue.push_back(msg); @@ -204,15 +205,32 @@ int WifiEventBroadcast::AddBroadCastMsg(const WifiEventCallbackMsg &msg) return 0; } -void WifiEventBroadcast::Exit() +void WifiInternalEventDispatcher::Exit() { mRunFlag = false; mCondition.notify_one(); pthread_join(mTid, nullptr); } -void WifiEventBroadcast::DealStaCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::DealStaCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg) { + switch (msg.msgCode) { + case WIFI_CBK_MSG_STATE_CHANGE: + WifiInternalEventDispatcher::PublishWifiStateChangedEvent(msg.msgData); + break; + case WIFI_CBK_MSG_CONNECTION_CHANGE: + WifiInternalEventDispatcher::PublishConnectionStateChangedEvent(msg.msgData, msg.linkInfo); + break; + case WIFI_CBK_MSG_RSSI_CHANGE: + break; + case WIFI_CBK_MSG_STREAM_DIRECTION: + break; + case WIFI_CBK_MSG_WPS_STATE_CHANGE: + break; + default: + break; + } + auto callback = pInstance->GetSingleStaCallback(); if (callback != nullptr) { switch (msg.msgCode) { @@ -240,7 +258,50 @@ void WifiEventBroadcast::DealStaCallbackMsg(WifiEventBroadcast *pInstance, const return; } -void WifiEventBroadcast::DealScanCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::PublishConnectionStateChangedEvent(int state, const WifiLinkedInfo &info) +{ + std::string eventData = "Idle"; + switch (info.connState) { + case ConnState::CONNECTING: + eventData = "Connecting"; + break; + case ConnState::AUTHENTICATING: + eventData = "Authenticating"; + break; + case ConnState::OBTAINING_IPADDR: + eventData = "ObtainingIpaddress"; + break; + case ConnState::CONNECTED: + eventData = "Connected"; + break; + case ConnState::SUSPENDED: + eventData = "Suspended"; + break; + case ConnState::DISCONNECTING: + eventData = "Disconnecting"; + break; + case ConnState::DISCONNECTED: + eventData = "Disconnected"; + break; + default: + break; + } + if (!WifiCommonEventHelper::PublishConnectionStateChangedEvent(state, eventData)) { + WIFI_LOGE("failed to publish connection state changed event!"); + return; + } + WIFI_LOGD("publish connection state changed event."); +} + +void WifiInternalEventDispatcher::PublishWifiStateChangedEvent(int state) +{ + if (!WifiCommonEventHelper::PublishPowerStateChangeEvent(state, "OnWifiPowerStateChanged")) { + WIFI_LOGE("failed to publish wifi state changed event!"); + return; + } + WIFI_LOGD("publish wifi state changed event."); +} +void WifiInternalEventDispatcher::DealScanCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg) { auto callback = pInstance->GetSingleScanCallback(); if (callback != nullptr) { @@ -257,7 +318,7 @@ void WifiEventBroadcast::DealScanCallbackMsg(WifiEventBroadcast *pInstance, cons return; } -void WifiEventBroadcast::InvokeScanCallbacks(const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::InvokeScanCallbacks(const WifiEventCallbackMsg &msg) { ScanCallbackMapType callbacks = mScanCallbacks; ScanCallbackMapType::iterator itr; @@ -276,7 +337,7 @@ void WifiEventBroadcast::InvokeScanCallbacks(const WifiEventCallbackMsg &msg) } } -void WifiEventBroadcast::InvokeDeviceCallbacks(const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::InvokeDeviceCallbacks(const WifiEventCallbackMsg &msg) { StaCallbackMapType callbacks = mStaCallbacks; StaCallbackMapType::iterator itr; @@ -306,7 +367,7 @@ void WifiEventBroadcast::InvokeDeviceCallbacks(const WifiEventCallbackMsg &msg) } } } -void WifiEventBroadcast::InvokeHotspotCallbacks(const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::InvokeHotspotCallbacks(const WifiEventCallbackMsg &msg) { HotspotCallbackMapType callbacks = mHotspotCallbacks; HotspotCallbackMapType::iterator itr; @@ -330,7 +391,7 @@ void WifiEventBroadcast::InvokeHotspotCallbacks(const WifiEventCallbackMsg &msg) } } } -void WifiEventBroadcast::DealHotspotCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg) +void WifiInternalEventDispatcher::DealHotspotCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg) { auto callback = pInstance->GetSingleHotspotCallback(); if (callback != nullptr) { @@ -353,9 +414,9 @@ void WifiEventBroadcast::DealHotspotCallbackMsg(WifiEventBroadcast *pInstance, c return; } -void *WifiEventBroadcast::Run(void *p) +void *WifiInternalEventDispatcher::Run(void *p) { - WifiEventBroadcast *pInstance = (WifiEventBroadcast *)p; + WifiInternalEventDispatcher *pInstance = (WifiInternalEventDispatcher *)p; while (pInstance->mRunFlag) { std::unique_lock lock(pInstance->mMutex); while (pInstance->mEventQue.empty() && pInstance->mRunFlag) { @@ -367,7 +428,7 @@ void *WifiEventBroadcast::Run(void *p) WifiEventCallbackMsg msg = pInstance->mEventQue.front(); pInstance->mEventQue.pop_front(); lock.unlock(); - WIFI_LOGD("WifiEventBroadcast::Run broad cast a msg %{public}d", msg.msgCode); + WIFI_LOGD("WifiInternalEventDispatcher::Run broad cast a msg %{public}d", msg.msgCode); if (msg.msgCode >= WIFI_CBK_MSG_STATE_CHANGE && msg.msgCode <= WIFI_CBK_MSG_WPS_STATE_CHANGE) { DealStaCallbackMsg(pInstance, msg); } else if (msg.msgCode == WIFI_CBK_MSG_SCAN_STATE_CHANGE) { diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_event_broadcast.h b/services/wifi_standard/wifi_framework/wifi_manage/wifi_internal_event_dispatcher.h similarity index 85% rename from services/wifi_standard/wifi_framework/wifi_manage/wifi_event_broadcast.h rename to services/wifi_standard/wifi_framework/wifi_manage/wifi_internal_event_dispatcher.h index 1a02d8496..0e51afc86 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_event_broadcast.h +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_internal_event_dispatcher.h @@ -39,13 +39,13 @@ namespace Wifi { using StaCallbackMapType = std::map, sptr>; using ScanCallbackMapType = std::map, sptr>; using HotspotCallbackMapType = std::map, sptr>; -class WifiEventBroadcast { +class WifiInternalEventDispatcher { public: - WifiEventBroadcast(); - ~WifiEventBroadcast(); + WifiInternalEventDispatcher(); + ~WifiInternalEventDispatcher(); /** - * @Description Init WifiEventBroadcast object + * @Description Init WifiInternalEventDispatcher object * * @return int - init result, when 0 means success, other means some fails happened */ @@ -80,12 +80,12 @@ public: * registration list one by one. The BpWifiCallbackService * method will eventually be called * - * @param p WifiEventBroadcast this Object + * @param p WifiInternalEventDispatcher this Object * @return void* - nullptr, not care this now */ static void *Run(void *p); - static WifiEventBroadcast &GetInstance(); + static WifiInternalEventDispatcher &GetInstance(); int AddStaCallback(const sptr &remote, const sptr &callback); int SetSingleStaCallback(const sptr &callback); sptr GetSingleStaCallback() const; @@ -106,9 +106,13 @@ public: void InvokeDeviceCallbacks(const WifiEventCallbackMsg &msg); void InvokeHotspotCallbacks(const WifiEventCallbackMsg &msg); private: - static void DealStaCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg); - static void DealScanCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg); - static void DealHotspotCallbackMsg(WifiEventBroadcast *pInstance, const WifiEventCallbackMsg &msg); + static void DealStaCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg); + static void DealScanCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg); + static void DealHotspotCallbackMsg(WifiInternalEventDispatcher *pInstance, const WifiEventCallbackMsg &msg); + + static void PublishConnectionStateChangedEvent(int state, const WifiLinkedInfo &info); + + static void PublishWifiStateChangedEvent(int state); private: bool mSystemNotifyInit; 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 032c359ea..923ef0517 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp @@ -19,7 +19,7 @@ #include "wifi_sta_hal_interface.h" #include "wifi_auth_center.h" #include "wifi_config_center.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_service_manager.h" #include "wifi_settings.h" @@ -66,8 +66,8 @@ int WifiManager::Init() mInitStatus_ = SERVICE_MANAGER_INIT_FAILED; return -1; } - if (WifiEventBroadcast::GetInstance().Init() < 0) { - WIFI_LOGE("WifiEventBroadcast Init failed!"); + if (WifiInternalEventDispatcher::GetInstance().Init() < 0) { + WIFI_LOGE("WifiInternalEventDispatcher Init failed!"); mInitStatus_ = EVENT_BROADCAST_INIT_FAILED; return -1; } @@ -88,7 +88,7 @@ void WifiManager::Exit() { WifiServiceManager::GetInstance().UninstallAllService(); WifiStaHalInterface::GetInstance().ExitAllIdlClient(); - WifiEventBroadcast::GetInstance().Exit(); + WifiInternalEventDispatcher::GetInstance().Exit(); if (mTid != 0) { mRunFlag = false; WifiResponseMsgInfo msg; @@ -262,7 +262,7 @@ void WifiManager::DealScanUpMsg(const WifiResponseMsgInfo &msg) WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_SCAN_STATE_CHANGE; cbMsg.msgData = msg.params.result; - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); break; } case WifiInternalMsgCode::SCAN_RESULT_RES: { @@ -286,7 +286,7 @@ void WifiManager::UploadOpenWifiFailedEvent() WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE; cbMsg.msgData = static_cast(WifiState::UNKNOWN); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } @@ -300,7 +300,7 @@ void WifiManager::UploadOpenWifiSuccessfulEvent() WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE; cbMsg.msgData = static_cast(WifiState::ENABLED); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } @@ -358,7 +358,7 @@ void WifiManager::DealStaCloseRes(const WifiResponseMsgInfo &msg) WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE; cbMsg.msgData = static_cast(WifiState::UNKNOWN); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); } WifiServiceManager::GetInstance().UnloadService(WIFI_SERVICE_STA); /* uninstalling sta service */ @@ -369,7 +369,7 @@ void WifiManager::DealStaCloseRes(const WifiResponseMsgInfo &msg) WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE; cbMsg.msgData = static_cast(WifiState::DISABLED); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); /** * Check unload SCAN service @@ -408,7 +408,7 @@ void WifiManager::DealStaConnChanged(const WifiResponseMsgInfo &msg) cbMsg.msgCode = WIFI_CBK_MSG_CONNECTION_CHANGE; cbMsg.msgData = static_cast(ConvertConnStateInternal(OperateResState(msg.params.result))); cbMsg.linkInfo = msg.params.linkedInfo; - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); /* Pushing the connection status to the scanning service */ if (msg.params.result == static_cast(OperateResState::CONNECT_CONNECTING) || @@ -429,7 +429,7 @@ void WifiManager::DealApOpenRes() WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_HOTSPOT_STATE_CHANGE; cbMsg.msgData = static_cast(ApState::AP_STATE_STARTED); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } @@ -440,7 +440,7 @@ void WifiManager::DealApCloseRes() WifiEventCallbackMsg cbMsg; cbMsg.msgCode = WIFI_CBK_MSG_HOTSPOT_STATE_CHANGE; cbMsg.msgData = static_cast(ApState::AP_STATE_CLOSED); - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } @@ -452,7 +452,7 @@ void WifiManager::DealApConnChanged(const WifiResponseMsgInfo &msg) cbMsg.msgCode = WIFI_CBK_MSG_HOTSPOT_STATE_LEAVE; } cbMsg.staInfo = msg.params.staInfo; - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } @@ -468,7 +468,7 @@ void WifiManager::DealWpsChanged(const WifiResponseMsgInfo &msg) cbMsg.pinCode = std::string(8 - len, '0') + cbMsg.pinCode; } } - WifiEventBroadcast::GetInstance().AddBroadCastMsg(cbMsg); + WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg); return; } } // namespace Wifi diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_callback_proxy.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_callback_proxy.cpp index 0b97d8c60..970380a28 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_callback_proxy.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_callback_proxy.cpp @@ -16,7 +16,7 @@ #include "wifi_scan_callback_proxy.h" #include "wifi_logger.h" #include "define.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" DEFINE_WIFILOG_SCAN_LABEL("WifiScanCallbackProxy"); @@ -44,8 +44,8 @@ void WifiScanCallbackProxy::OnWifiScanStateChanged(int state) break; case DEAD_OBJECT: { WIFI_LOGE("Failed to SendRequest, remote object has dead!"); - if (WifiEventBroadcast::GetInstance().HasScanRemote(Remote())) { - WifiEventBroadcast::GetInstance().RemoveScanCallback(Remote()); + if (WifiInternalEventDispatcher::GetInstance().HasScanRemote(Remote())) { + WifiInternalEventDispatcher::GetInstance().RemoveScanCallback(Remote()); } break; } diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_death_recipient.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_death_recipient.cpp index 00705da26..c9c22bd06 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_death_recipient.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_death_recipient.cpp @@ -15,14 +15,14 @@ #include "wifi_scan_death_recipient.h" #include "wifi_logger.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" DEFINE_WIFILOG_SCAN_LABEL("WifiScanDeathRecipient"); namespace OHOS { namespace Wifi { void WifiScanDeathRecipient::OnRemoteDied(const wptr& remoteObject) { WIFI_LOGD("WifiScanDeathRecipient::OnRemoteDied!"); - WifiEventBroadcast::GetInstance().RemoveScanCallback(remoteObject.promote()); + WifiInternalEventDispatcher::GetInstance().RemoveScanCallback(remoteObject.promote()); } } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_service_impl.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_service_impl.cpp index 850aa9b38..cb98cca87 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_service_impl.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_service_impl.cpp @@ -21,7 +21,7 @@ #include "wifi_config_center.h" #include "wifi_manager.h" #include "wifi_service_manager.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_internal_msg.h" #include "wifi_logger.h" #include "define.h" @@ -183,7 +183,7 @@ ErrCode WifiScanServiceImpl::GetScanInfoList(std::vector &result) ErrCode WifiScanServiceImpl::RegisterCallBack(const sptr &callback) { WIFI_LOGI("WifiScanServiceImpl::RegisterCallBack!"); - WifiEventBroadcast::GetInstance().SetSingleScanCallback(callback); + WifiInternalEventDispatcher::GetInstance().SetSingleScanCallback(callback); return WIFI_OPT_SUCCESS; } } // namespace Wifi diff --git a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_stub.cpp b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_stub.cpp index dc9a71aa2..cb73d474c 100644 --- a/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_stub.cpp +++ b/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_stub.cpp @@ -18,7 +18,7 @@ #include "wifi_msg.h" #include "define.h" #include "wifi_scan_callback_proxy.h" -#include "wifi_event_broadcast.h" +#include "wifi_internal_event_dispatcher.h" #include "wifi_scan_death_recipient.h" namespace OHOS { @@ -223,7 +223,7 @@ int WifiScanStub::OnRegisterCallBack(uint32_t code, MessageParcel &data, Message WIFI_LOGD("AddDeathRecipient!"); } if (callback_ != nullptr) { - WifiEventBroadcast::GetInstance().AddScanCallback(remote, callback_); + WifiInternalEventDispatcher::GetInstance().AddScanCallback(remote, callback_); } ret = WIFI_OPT_SUCCESS; } -- Gitee