mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 08:49:59 +00:00
commit
b22a55e22e
@ -35,6 +35,7 @@
|
||||
static const int32_t DELAY_LEN = 1000;
|
||||
static const int32_t RETRY_MAX = 20;
|
||||
static const std::string COMMON_EVENT_WIFI_SEMI_STATE = "usual.event.wifi.SEMI_STATE";
|
||||
static const int32_t WIFI_UID = 1010;
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
@ -193,6 +194,7 @@ int32_t SubscribeEvent::SubscribeWifiSemiStateEvent()
|
||||
MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(COMMON_EVENT_WIFI_SEMI_STATE);
|
||||
CommonEventSubscribeInfo subscriberInfo(matchingSkills);
|
||||
subscriberInfo.SetPublisherUid(WIFI_UID);
|
||||
std::shared_ptr<WifiServiceMonitor> subscriberPtr = std::make_shared<WifiServiceMonitor>(subscriberInfo);
|
||||
if (!CommonEventManager::SubscribeCommonEvent(subscriberPtr)) {
|
||||
return SOFTBUS_ERR;
|
||||
|
@ -186,12 +186,18 @@ int32_t LnnGetSettingDeviceName(char *deviceName, uint32_t len)
|
||||
return ret;
|
||||
}
|
||||
if (ret == SOFTBUS_OK) {
|
||||
LNN_LOGI(LNN_STATE, "get user defined deviceName success");
|
||||
char *anonyDeviceName = NULL;
|
||||
Anonymize(deviceName, &anonyDeviceName);
|
||||
LNN_LOGI(LNN_STATE, "get user defined deviceName=%{public}s", AnonymizeWrapper(anonyDeviceName));
|
||||
AnonymizeFree(anonyDeviceName);
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ret = OHOS::BusCenter::GetDefaultDeviceName(dataShareHelper, deviceName, len);
|
||||
LNN_LOGI(LNN_STATE, "get default deviceName, ret=%{public}d", ret);
|
||||
char *anonyDeviceName = NULL;
|
||||
Anonymize(deviceName, &anonyDeviceName);
|
||||
LNN_LOGI(LNN_STATE, "get default deviceName=%{public}s, ret=%{public}d", AnonymizeWrapper(anonyDeviceName), ret);
|
||||
AnonymizeFree(anonyDeviceName);
|
||||
dataShareHelper->Release();
|
||||
return ret;
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ static void HbUserSwitchedHandler(const LnnEventBasicInfo *info)
|
||||
SoftBusUserSwitchState userSwitchState = (SoftBusUserSwitchState)event->status;
|
||||
switch (userSwitchState) {
|
||||
case SOFTBUS_USER_SWITCHED:
|
||||
LNN_LOGI(LNN_HEART_BEAT, "HB SOFTBUS_USER_SWITCHED");
|
||||
LNN_LOGI(LNN_HEART_BEAT, "HB handle SOFTBUS_USER_SWITCHED");
|
||||
LnnUpdateOhosAccount(true);
|
||||
HbConditionChanged(false);
|
||||
if (IsHeartbeatEnable()) {
|
||||
|
@ -295,27 +295,23 @@ static void LnnSetP2pNetCapability(uint32_t *capability)
|
||||
}
|
||||
}
|
||||
|
||||
static void GetApCapability(SoftBusWifiState wifiState, uint32_t *capability, bool *needSync)
|
||||
static void ProcessApEnabled(uint32_t *capability, bool *needSync)
|
||||
{
|
||||
switch (wifiState) {
|
||||
case SOFTBUS_AP_ENABLED:
|
||||
g_isApEnable = true;
|
||||
LnnSetNetworkCapability(capability);
|
||||
if (IsP2pAvailable(true)) {
|
||||
(void)LnnSetNetCapability(capability, BIT_WIFI_P2P);
|
||||
}
|
||||
*needSync = true;
|
||||
break;
|
||||
case SOFTBUS_AP_DISABLED:
|
||||
g_isApEnable = false;
|
||||
if (IsP2pAvailable(false)) {
|
||||
(void)LnnSetNetCapability(capability, BIT_WIFI_P2P);
|
||||
}
|
||||
*needSync = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
g_isApEnable = true;
|
||||
LnnSetNetworkCapability(capability);
|
||||
if (IsP2pAvailable(true)) {
|
||||
(void)LnnSetNetCapability(capability, BIT_WIFI_P2P);
|
||||
}
|
||||
*needSync = true;
|
||||
}
|
||||
|
||||
static void ProcessApDisabled(uint32_t *capability, bool *needSync)
|
||||
{
|
||||
g_isApEnable = false;
|
||||
if (IsP2pAvailable(false)) {
|
||||
(void)LnnSetNetCapability(capability, BIT_WIFI_P2P);
|
||||
}
|
||||
*needSync = true;
|
||||
}
|
||||
|
||||
static void GetNetworkCapability(SoftBusWifiState wifiState, uint32_t *capability, bool *needSync)
|
||||
@ -350,8 +346,10 @@ static void GetNetworkCapability(SoftBusWifiState wifiState, uint32_t *capabilit
|
||||
*needSync = true;
|
||||
break;
|
||||
case SOFTBUS_AP_ENABLED:
|
||||
ProcessApEnabled(capability, needSync);
|
||||
break;
|
||||
case SOFTBUS_AP_DISABLED:
|
||||
GetApCapability(wifiState, capability, needSync);
|
||||
ProcessApDisabled(capability, needSync);
|
||||
break;
|
||||
case SOFTBUS_WIFI_SEMI_ACTIVE:
|
||||
g_isWifiEnable = true;
|
||||
|
@ -141,6 +141,7 @@ static void ProcessLocalDeviceInfo(void)
|
||||
info.stateVersion++;
|
||||
LnnSaveLocalDeviceInfo(&info);
|
||||
}
|
||||
LNN_LOGI(LNN_LEDGER, "load local deviceInfo stateVersion=%{public}d", info.stateVersion);
|
||||
if (LnnSetLocalNumInfo(NUM_KEY_STATE_VERSION, info.stateVersion) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "set state version fail");
|
||||
}
|
||||
@ -151,6 +152,7 @@ static void ProcessLocalDeviceInfo(void)
|
||||
LnnNotifyLocalNetworkIdChanged();
|
||||
if (info.networkIdTimestamp != 0) {
|
||||
LnnUpdateLocalNetworkIdTime(info.networkIdTimestamp);
|
||||
LNN_LOGD(LNN_LEDGER, "update networkIdTimestamp=%" PRId64, info.networkIdTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user