!3295 modify broadcast permission control

Merge pull request !3295 from yinyongbin/master
This commit is contained in:
openharmony_ci 2024-11-09 03:40:22 +00:00 committed by Gitee
commit 2d1777617c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 21 additions and 20 deletions

View File

@ -30,6 +30,7 @@ inline const std::u16string ABILITY_MGR_DESCRIPTOR = u"ohos.aafwk.AbilityManager
inline const std::string WIFI_EVENT_TAP_NOTIFICATION = "ohos.event.notification.wifi.TAP_NOTIFICATION";
inline const std::string WIFI_EVENT_DIALOG_ACCEPT = "ohos.event.wifi.DIALOG_ACCEPT";
inline const std::string WIFI_EVENT_DIALOG_REJECT = "ohos.event.wifi.DIALOG_REJECT";
inline const std::string EVENT_SETTINGS_WLAN_KEEP_CONNECTED = "event.settings.wlan.keep_connected";
enum WifiNotificationId {
WIFI_PORTAL_NOTIFICATION_ID = 101000
};

View File

@ -56,7 +56,6 @@ const std::string SUPPORT_COEXCHIP = "";
const std::string COEX_IFACENAME = "wlan1";
const std::string WIFI_STANDBY_NAP = "napped";
const std::string WIFI_STANDBY_SLEEPING = "sleeping";
const std::string EVENT_SETTINGS_WLAN_KEEP_CONNECTED = "event.settings.wlan.keep_connected";
bool WifiEventSubscriberManager::mIsMdmForbidden = false;
static sptr<WifiLocationModeObserver> locationModeObserver_ = nullptr;
@ -82,8 +81,7 @@ const std::map<std::string, CesFuncType> CES_REQUEST_MAP = {
{OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED, &
CesEventSubscriber::OnReceiveStandbyEvent},
{OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_UNLOCKED, &
CesEventSubscriber::OnReceiveUserUnlockedEvent},
{EVENT_SETTINGS_WLAN_KEEP_CONNECTED, &CesEventSubscriber::OnReceiveWlanKeepConnected}
CesEventSubscriber::OnReceiveUserUnlockedEvent}
};
WifiEventSubscriberManager::WifiEventSubscriberManager()
@ -816,22 +814,6 @@ void CesEventSubscriber::OnReceiveStandbyEvent(const OHOS::EventFwk::CommonEvent
}
}
void CesEventSubscriber::OnReceiveWlanKeepConnected(const OHOS::EventFwk::CommonEventData &eventData)
{
const auto &action = eventData.GetWant().GetAction();
const int code = eventData.GetCode();
WifiLinkedInfo linkedInfo;
WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo);
int networkId = linkedInfo.networkId;
WIFI_LOGI("received the WlanKeepConnected, action ==%{public}s, code == %{public}d", action.c_str(), code);
if (code == 1) { // The user clicks the use button.
WifiNetAgent::GetInstance().RestoreWifiConnection();
WIFI_LOGI("change the value of AcceptUnvalidated to true");
WifiSettings::GetInstance().SetAcceptUnvalidated(networkId);
WifiSettings::GetInstance().SyncDeviceConfig();
}
}
void WifiEventSubscriberManager::RegisterNotificationEvent()
{
std::unique_lock<std::mutex> lock(notificationEventMutex);
@ -845,6 +827,7 @@ void WifiEventSubscriberManager::RegisterNotificationEvent()
matchingSkills.AddEvent(WIFI_EVENT_TAP_NOTIFICATION);
matchingSkills.AddEvent(WIFI_EVENT_DIALOG_ACCEPT);
matchingSkills.AddEvent(WIFI_EVENT_DIALOG_REJECT);
matchingSkills.AddEvent(EVENT_SETTINGS_WLAN_KEEP_CONNECTED);
WIFI_LOGI("RegisterNotificationEvent start");
EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
subscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
@ -888,6 +871,21 @@ NotificationEventSubscriber::~NotificationEventSubscriber()
WIFI_LOGI("~NotificationEventSubscriber enter");
}
void NotificationEventSubscriber::OnReceiveWlanKeepConnected(const OHOS::EventFwk::CommonEventData &eventData)
{
const int code = eventData.GetCode();
WifiLinkedInfo linkedInfo;
WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo);
int networkId = linkedInfo.networkId;
WIFI_LOGI("received the WlanKeepConnected, code == %{public}d", code);
if (code == 1) { // The user clicks the use button.
WifiNetAgent::GetInstance().RestoreWifiConnection();
WIFI_LOGI("change the value of AcceptUnvalidated to true");
WifiSettings::GetInstance().SetAcceptUnvalidated(networkId);
WifiSettings::GetInstance().SyncDeviceConfig();
}
}
void NotificationEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &eventData)
{
std::string action = eventData.GetWant().GetAction();
@ -913,6 +911,8 @@ void NotificationEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEve
pService->ConnectToNetwork(candidateNetworkId);
}
}
} else if (action == EVENT_SETTINGS_WLAN_KEEP_CONNECTED) {
OnReceiveWlanKeepConnected(eventData);
} else {
int dialogType = eventData.GetWant().GetIntParam("dialogType", 0);
WIFI_LOGI("dialogType[%{public}d]", dialogType);

View File

@ -50,7 +50,6 @@ public:
void OnReceiveThermalEvent(const OHOS::EventFwk::CommonEventData &eventData);
void OnReceiveNotificationEvent(const OHOS::EventFwk::CommonEventData &eventData);
void OnReceiveUserUnlockedEvent(const OHOS::EventFwk::CommonEventData &eventData);
void OnReceiveWlanKeepConnected(const OHOS::EventFwk::CommonEventData &eventData);
private:
bool lastSleepState = false;
};
@ -60,6 +59,7 @@ public:
explicit NotificationEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo);
virtual ~NotificationEventSubscriber();
void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &eventData) override;
void OnReceiveWlanKeepConnected(const OHOS::EventFwk::CommonEventData &eventData);
};
#ifdef HAS_POWERMGR_PART