diff --git a/adapter/common/bus_center/common_event/lnn_common_event_monitor.cpp b/adapter/common/bus_center/common_event/lnn_common_event_monitor.cpp index d15492217704dca9a2f6ee9d57b2712ba0dce48f..87cd8b18450f1930bca2ec9212308dd56f1dc2ca 100644 --- a/adapter/common/bus_center/common_event/lnn_common_event_monitor.cpp +++ b/adapter/common/bus_center/common_event/lnn_common_event_monitor.cpp @@ -50,7 +50,7 @@ void CommonEventMonitor::OnReceiveEvent(const CommonEventData &data) LnnNotifySysTimeChangeEvent(); } if (action == CommonEventSupport::COMMON_EVENT_BOOT_COMPLETED) { - LnnNotifyDeviceRootStateChangeEvent(); + LnnNotifyDeviceRiskStateChangeEvent(); } SoftBusScreenState screenState = SOFTBUS_SCREEN_UNKNOWN; diff --git a/core/authentication/src/auth_device.c b/core/authentication/src/auth_device.c index dc3f3b6d9bd20317a084b95a533ae8fb0e38ac86..8678df211ca93a4d6c0897edac4e2b3c01db472e 100644 --- a/core/authentication/src/auth_device.c +++ b/core/authentication/src/auth_device.c @@ -346,7 +346,7 @@ void AuthDeviceNotTrust(const char *peerUdid) LnnDeleteSpecificTrustedDevInfo(peerUdid, GetActiveOsAccountIds()); LnnHbOnTrustedRelationReduced(); AuthRemoveDeviceKeyByUdidPacked(peerUdid); - if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { AUTH_LOGE(AUTH_HICHAIN, "request leave specific fail"); } else { AUTH_LOGI(AUTH_HICHAIN, "request leave specific successful"); diff --git a/core/bus_center/lnn/lane_hub/heartbeat/include/lnn_heartbeat_ctrl.h b/core/bus_center/lnn/lane_hub/heartbeat/include/lnn_heartbeat_ctrl.h index 20c41b439cd8ba8931823ac36c3aa98538852176..b2fa0018022de1bf2d770c729dc0abcae12dafaf 100644 --- a/core/bus_center/lnn/lane_hub/heartbeat/include/lnn_heartbeat_ctrl.h +++ b/core/bus_center/lnn/lane_hub/heartbeat/include/lnn_heartbeat_ctrl.h @@ -61,6 +61,7 @@ bool LnnIsNeedInterceptBroadcast(bool disableGlass); void LnnRegBleRangeCb(const IBleRangeInnerCallback *callback); void LnnUnregBleRangeCb(void); +int32_t RiskDeviceLeaveLnn(void); #ifdef __cplusplus } diff --git a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_ctrl.c b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_ctrl.c index b6d913a42f983b00213d8723630902b12ad03332..8b8e847485edf6155742950600ee8c991ad71f37 100644 --- a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_ctrl.c +++ b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_ctrl.c @@ -70,7 +70,7 @@ typedef struct { SoftBusUserState backgroundState; SoftBusNightModeState nightModeState; SoftBusOOBEState OOBEState; - SoftBusDeviceRootState deviceRootState; + SoftBusDeviceRiskState deviceRiskState; bool hasTrustedRelation; bool heartbeatEnable; bool isRequestDisable; @@ -102,7 +102,7 @@ static void InitHbConditionState(void) g_hbConditionState.isRequestDisable = false; g_hbConditionState.heartbeatEnable = false; g_hbConditionState.OOBEState = SOFTBUS_OOBE_UNKNOWN; - g_hbConditionState.deviceRootState = SOFTBUS_DEVICE_ROOT_UNKNOWN; + g_hbConditionState.deviceRiskState = SOFTBUS_DEVICE_RISK_UNKNOWN; LNN_LOGI(LNN_INIT, "condition state:heartbeat=%{public}d", g_hbConditionState.heartbeatEnable); } @@ -132,17 +132,17 @@ bool IsHeartbeatEnable(void) bool isOOBEEnd = g_hbConditionState.OOBEState == SOFTBUS_OOBE_END || g_hbConditionState.OOBEState == SOFTBUS_FACK_OOBE_END; bool isInitCheckSuc = IsLnnInitCheckSucceed(MONITOR_BLE_NET); - bool isDeviceRoot = g_hbConditionState.deviceRootState == SOFTBUS_DEVICE_IS_ROOT; + bool isDeviceRisk = g_hbConditionState.deviceRiskState == SOFTBUS_DEVICE_IS_RISK; LNN_LOGI(LNN_HEART_BEAT, "HB condition state: bt=%{public}d, screenUnlock=%{public}d, account=%{public}d, trustedRelation=%{public}d, " "background=%{public}d, nightMode=%{public}d, OOBEEnd=%{public}d, heartbeatEnable=%{public}d, " - "request=%{public}d, init check=%{public}d, deviceRoot=%{public}d", + "request=%{public}d, init check=%{public}d, deviceRisk=%{public}d", isBtOn, isScreenUnlock, isLogIn, g_hbConditionState.hasTrustedRelation, isBackground, isNightMode, isOOBEEnd, - g_hbConditionState.heartbeatEnable, g_hbConditionState.isRequestDisable, isInitCheckSuc, isDeviceRoot); + g_hbConditionState.heartbeatEnable, g_hbConditionState.isRequestDisable, isInitCheckSuc, isDeviceRisk); return g_hbConditionState.heartbeatEnable && isBtOn && isScreenUnlock && !g_hbConditionState.isRequestDisable && (isLogIn || g_hbConditionState.hasTrustedRelation) && !isBackground && !isNightMode && isOOBEEnd && - isInitCheckSuc && !isDeviceRoot; + isInitCheckSuc && !isDeviceRisk; } SoftBusScreenState GetScreenState(void) @@ -387,9 +387,9 @@ void LnnRequestBleDiscoveryProcess(int32_t strategy, int64_t timeout) } } -static int32_t HbRootDeviceLeaveLnn(void) +int32_t RiskDeviceLeaveLnn(void) { - LNN_LOGI(LNN_HEART_BEAT, "enter HbRootDeviceLeaveLnn"); + LNN_LOGI(LNN_HEART_BEAT, "enter RiskDeviceLeaveLnn"); int32_t i = 0; int32_t infoNum = 0; NodeBasicInfo *info = NULL; @@ -409,8 +409,8 @@ static int32_t HbRootDeviceLeaveLnn(void) if (ret != SOFTBUS_OK) { continue; } - LNN_LOGI(LNN_HEART_BEAT, "device is root, need to offline"); - LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_MAX); + LNN_LOGI(LNN_HEART_BEAT, "device is risk, need to offline"); + LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_NOT_TRUST); AuthRemoveDeviceKeyByUdidPacked(nodeInfo.deviceInfo.deviceUdid); } SoftBusFree(info); @@ -440,7 +440,7 @@ static int32_t HbHandleLeaveLnn(void) } if ((nodeInfo.feature & (1 << BIT_SUPPORT_THREE_STATE)) == 0 && SoftBusGetBrState() == BR_DISABLE) { LNN_LOGI(LNN_HEART_BEAT, "peer don't support three state and local br off"); - LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_BLE); + LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_BLE, DEVICE_LEAVE_REASON_DEFAULT); } } SoftBusFree(info); @@ -698,30 +698,35 @@ static void DfxRecordScreenChangeTimestamp(LnnTriggerReason reason) DfxRecordTriggerTime(reason, EVENT_STAGE_LNN_SCREEN_STATE_CHANGED); } -static void HbDeviceRootStateEventHandler(const LnnEventBasicInfo *info) +static void HbDeviceRiskStateEventHandler(const LnnEventBasicInfo *info) { - if (info == NULL || info->event != LNN_EVENT_DEVICE_ROOT_STATE_CHANGED) { - LNN_LOGE(LNN_HEART_BEAT, "device root state change evt handler get invalid param"); + if (info == NULL || info->event != LNN_EVENT_DEVICE_RISK_STATE_CHANGED) { + LNN_LOGE(LNN_HEART_BEAT, "device risk state change evt handler get invalid param"); return; } - const LnnDeviceRootStateChangeEvent *event = (const LnnDeviceRootStateChangeEvent *)info; - SoftBusDeviceRootState deviceRootState = (SoftBusDeviceRootState)event->status; - LNN_LOGI(LNN_HEART_BEAT, "HB handle deviceRootState=%{public}d", deviceRootState); - switch (deviceRootState) { - case SOFTBUS_DEVICE_IS_ROOT: - if (g_hbConditionState.deviceRootState != SOFTBUS_DEVICE_IS_ROOT) { - g_hbConditionState.deviceRootState = deviceRootState; + const LnnDeviceRiskStateChangeEvent *event = (const LnnDeviceRiskStateChangeEvent *)info; + SoftBusDeviceRiskState deviceRiskState = (SoftBusDeviceRiskState)event->status; + LNN_LOGI(LNN_HEART_BEAT, "HB handle deviceRiskState=%{public}d", deviceRiskState); + switch (deviceRiskState) { + case SOFTBUS_DEVICE_IS_RISK: + if (g_hbConditionState.deviceRiskState != SOFTBUS_DEVICE_IS_RISK) { + g_hbConditionState.deviceRiskState = deviceRiskState; + HbConditionChanged(false); + RiskDeviceLeaveLnn(); + } else { + LNN_LOGI(LNN_HEART_BEAT, "deviceRiskState is risk"); } - HbConditionChanged(false); - HbRootDeviceLeaveLnn(); break; - case SOFTBUS_DEVICE_NOT_ROOT: - if (g_hbConditionState.deviceRootState != SOFTBUS_DEVICE_NOT_ROOT) { - g_hbConditionState.deviceRootState = deviceRootState; + case SOFTBUS_DEVICE_NOT_RISK: + if (g_hbConditionState.deviceRiskState == SOFTBUS_DEVICE_IS_RISK) { + HbConditionChanged(false); + } + if (g_hbConditionState.deviceRiskState != SOFTBUS_DEVICE_NOT_RISK) { + g_hbConditionState.deviceRiskState = deviceRiskState; } break; default: - LNN_LOGE(LNN_HEART_BEAT, "error deviceRootState"); + LNN_LOGE(LNN_HEART_BEAT, "error deviceRiskState"); break; } } @@ -1231,7 +1236,7 @@ int32_t LnnShiftLNNGear(const char *pkgName, const char *callerId, const char *t int32_t ret = AuthFlushDevice(uuid); if (ret != SOFTBUS_OK && ret != SOFTBUS_INVALID_PARAM) { LNN_LOGI(LNN_HEART_BEAT, "tcp flush failed, wifi will offline"); - return LnnRequestLeaveSpecific(targetNetworkId, CONNECTION_ADDR_WLAN); + return LnnRequestLeaveSpecific(targetNetworkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); } return SOFTBUS_OK; } @@ -1281,7 +1286,7 @@ int32_t LnnShiftLNNGearWithoutPkgName(const char *callerId, const GearMode *mode LNN_LOGE(LNN_HEART_BEAT, "tcp flush failed, wifi will offline, uuid=%{public}s", AnonymizeWrapper(anonyUuid)); AnonymizeFree(anonyUuid); - LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_WLAN); + LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); } } SoftBusFree(info); @@ -1402,8 +1407,8 @@ static int32_t LnnRegisterCommonEvent(void) LNN_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, LNN_INIT, "regist user switch evt handler fail"); ret = LnnRegisterEventHandler(LNN_EVENT_SLE_STATE_CHANGED, HbSleStateEventHandler); LNN_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, LNN_INIT, "regist sle state change evt handler fail"); - ret = LnnRegisterEventHandler(LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, HbDeviceRootStateEventHandler); - LNN_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, LNN_INIT, "regist sle state change evt handler fail"); + ret = LnnRegisterEventHandler(LNN_EVENT_DEVICE_RISK_STATE_CHANGED, HbDeviceRiskStateEventHandler); + LNN_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, LNN_INIT, "regist device risk state evt handler fail"); return SOFTBUS_OK; } @@ -1528,7 +1533,7 @@ void LnnDeinitHeartbeat(void) LnnUnregisterEventHandler(LNN_EVENT_LP_EVENT_REPORT, HbLpEventHandler); LnnUnregisterEventHandler(LNN_EVENT_USER_SWITCHED, HbUserSwitchedHandler); LnnUnregisterEventHandler(LNN_EVENT_SLE_STATE_CHANGED, HbSleStateEventHandler); - LnnUnregisterEventHandler(LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, HbDeviceRootStateEventHandler); + LnnUnregisterEventHandler(LNN_EVENT_DEVICE_RISK_STATE_CHANGED, HbDeviceRiskStateEventHandler); } int32_t LnnTriggerDataLevelHeartbeat(void) diff --git a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_fsm.c b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_fsm.c index 2bf617a67563e79e43cebbf618e062609626b4d7..0be02e598f7e299d9eeaab4b8e200850696494be 100644 --- a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_fsm.c +++ b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_fsm.c @@ -866,7 +866,7 @@ static int32_t ProcessLostHeartbeat(const char *networkId, LnnHeartbeatType type AnonymizeWrapper(anonyUdidHash), AnonymizeWrapper(anonyNetworkId)); AnonymizeFree(anonyNetworkId); AnonymizeFree(anonyUdidHash); - if (LnnRequestLeaveSpecific(networkId, addrType) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, addrType, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_HEART_BEAT, "process dev lost send request to NetBuilder fail"); return SOFTBUS_NETWORK_REQ_LEAVE_LNN_FAIL; } @@ -996,7 +996,8 @@ static void CheckDevStatusForScreenOff(LnnHeartbeatFsm *hbFsm, const char *netwo LNN_LOGI(LNN_HEART_BEAT, "local device support lp, no need offline"); return; } - if (LnnRequestLeaveSpecific(networkId, LnnConvertHbTypeToConnAddrType(hbType)) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, LnnConvertHbTypeToConnAddrType(hbType), + DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_HEART_BEAT, "process dev lost send request to NetBuilder fail"); return; } @@ -1141,7 +1142,7 @@ static void CheckSleDevStatus(LnnHeartbeatFsm *hbFsm, const char *networkId, LNN_LOGI(LNN_HEART_BEAT, "notify node lost sle heartbeat, networkId=%{public}s," "timestamp=%{public}" PRIu64 "->%{public}" PRIu64 "", AnonymizeWrapper(anonyNetworkId), oldTimeStamp, nowTime); - if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_HEART_BEAT, "process dev lost sle hb, send request to NetBuilder fail, networkId=%{public}s", AnonymizeWrapper(anonyNetworkId)); } diff --git a/core/bus_center/lnn/net_builder/include/lnn_net_builder.h b/core/bus_center/lnn/net_builder/include/lnn_net_builder.h index afe2a98dce26d5fd6885df01d2458853c0b8af87..33db67720b897d7b1cbfad2b562b78be7ba02e3d 100644 --- a/core/bus_center/lnn/net_builder/include/lnn_net_builder.h +++ b/core/bus_center/lnn/net_builder/include/lnn_net_builder.h @@ -39,7 +39,7 @@ int32_t LnnNotifyDiscoveryDevice( const ConnectionAddr *addr, const LnnDfxDeviceInfoReport *infoReport, bool isNeedConnect); void LnnSyncOfflineComplete(LnnSyncInfoType type, const char *networkId, const uint8_t *msg, uint32_t len); int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen); -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType); +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason); void LnnRequestLeaveAllOnlineNodes(void); int32_t LnnRequestLeaveInvalidConn(const char *oldNetworkId, ConnectionAddrType addrType, const char *newNetworkId); int32_t LnnRequestCleanConnFsm(uint16_t connFsmId); diff --git a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c index 909425b6f040f313ddebae62a309dda09b5bf729..accea8d9793fa518e01a650e857799f8f3d38086 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c +++ b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c @@ -1818,7 +1818,7 @@ static void LeaveSameIpOnlineDevice(LnnConntionInfo *connInfo) LNN_LOGI( LNN_BUILDER, "need old same ip device offline, networkId=%{public}s", AnonymizeWrapper(anonyNetworkId)); AnonymizeFree(anonyNetworkId); - LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_WLAN); + LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); SoftBusFree(info); return; } diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c index 26e919362adf3880e4e31d348152575eee30d755..1332d4212908ee328c9a2313d941710c92a481f1 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c @@ -565,7 +565,8 @@ void OnLnnProcessNotTrustedMsgDelay(void *para) LNN_LOGI(LNN_BUILDER, "networkId=%{public}s, LnnRequestLeaveSpecificType=%{public}d", AnonymizeWrapper(anonyNetworkId), type); AnonymizeFree(anonyNetworkId); - LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType((DiscoveryType)type)); + LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType((DiscoveryType)type), + DEVICE_LEAVE_REASON_DEFAULT); continue; } } @@ -614,7 +615,8 @@ void LnnProcessCompleteNotTrustedMsg(LnnSyncInfoType syncType, const char *netwo LNN_LOGI(LNN_BUILDER, "networkId=%{public}s, LnnRequestLeaveSpecificType=%{public}d", AnonymizeWrapper(anonyNetworkId), type); AnonymizeFree(anonyNetworkId); - LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType((DiscoveryType)type)); + LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType((DiscoveryType)type), + DEVICE_LEAVE_REASON_DEFAULT); continue; } } @@ -1388,7 +1390,7 @@ int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) return SOFTBUS_OK; } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { SpecificLeaveMsgPara *para = NULL; @@ -1410,6 +1412,7 @@ int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrTy return SOFTBUS_STRCPY_ERR; } para->addrType = addrType; + para->leaveReason = leaveReason; if (PostBuildMessageToHandler(MSG_TYPE_LEAVE_SPECIFIC, para) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "post leave specific msg failed"); SoftBusFree(para); diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder_init.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder_init.c index 2f20abfe4744b33c7c76125cfd2bc761690a4ff4..b1775f650cf78e72c2654ee3446eefc3b8405be0 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder_init.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder_init.c @@ -742,7 +742,7 @@ static bool IsNeedNotifyOfflineByAdv(const char *udid) LNN_LOGE(LNN_BUILDER, "ble capa disable, local=%{public}u, remote=%{public}u", local, info.netCapacity); return false; } - LnnRequestLeaveSpecific(info.networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(info.networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); return true; } diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder_process.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder_process.c index e386bc560ca06f5b9efdebc3b9ef75305c03d9cf..04a55a97366e08ddee6a8423fcf120ed4241cf45 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder_process.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder_process.c @@ -518,7 +518,7 @@ static int32_t ProcessDeviceNotTrusted(const void *para) do { char networkId[NETWORK_ID_BUF_LEN] = { 0 }; if (LnnGetNetworkIdByUdid(peerUdid, networkId, sizeof(networkId)) == SOFTBUS_OK) { - LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); break; } LIST_FOR_EACH_ENTRY(item, &LnnGetNetBuilder()->fsmList, LnnConnectionFsm, node) { @@ -757,51 +757,46 @@ static int32_t ProcessLeaveSpecific(const void *para) { const SpecificLeaveMsgPara *msgPara = (const SpecificLeaveMsgPara *)para; LnnConnectionFsm *item = NULL; - if (msgPara == NULL) { LNN_LOGW(LNN_BUILDER, "leave specific msg is null"); return SOFTBUS_INVALID_PARAM; } - int32_t rc; bool deviceLeave = false; LIST_FOR_EACH_ENTRY(item, &LnnGetNetBuilder()->fsmList, LnnConnectionFsm, node) { if (strcmp(item->connInfo.peerNetworkId, msgPara->networkId) != 0 || - (item->connInfo.addr.type != msgPara->addrType && - msgPara->addrType != CONNECTION_ADDR_MAX)) { + (item->connInfo.addr.type != msgPara->addrType && msgPara->addrType != CONNECTION_ADDR_MAX)) { continue; } deviceLeave = true; + if (msgPara->leaveReason == DEVICE_LEAVE_REASON_NOT_TRUST) { + item->connInfo.flag |= LNN_CONN_INFO_FLAG_LEAVE_PASSIVE; + } rc = LnnSendLeaveRequestToConnFsm(item); if (rc == SOFTBUS_OK) { item->connInfo.flag |= LNN_CONN_INFO_FLAG_LEAVE_AUTO; } LNN_LOGI(LNN_BUILDER, "send leave LNN msg to connection. fsmId=%{public}u, result=%{public}d", item->id, rc); } - if (deviceLeave) { SoftBusFree((void *)msgPara); return SOFTBUS_OK; } - do { NodeInfo nodeInfo; (void)memset_s(&nodeInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo)); if (LnnGetRemoteNodeInfoById(msgPara->networkId, CATEGORY_NETWORK_ID, &nodeInfo)) { break; } - if (nodeInfo.deviceInfo.deviceTypeId != TYPE_PC_ID || strcmp(nodeInfo.networkId, nodeInfo.deviceInfo.deviceUdid) != 0) { break; } - (void)LnnClearDiscoveryType(&nodeInfo, LnnConvAddrTypeToDiscType(msgPara->addrType)); if (nodeInfo.discoveryType != 0) { LNN_LOGI(LNN_BUILDER, "pc without softbus has another discovery type"); break; } - LNN_LOGI(LNN_BUILDER, "pc without softbus offline"); DeleteFromProfile(nodeInfo.deviceInfo.deviceUdid); LnnRemoveNode(nodeInfo.deviceInfo.deviceUdid); diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder_virtual.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder_virtual.c index 5c58864e821b57d90985054cd303c844e48f6733..500db67d731f8ccaa2f416313bbd0d58dbca0878 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder_virtual.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder_virtual.c @@ -81,7 +81,7 @@ void ClearPcRestrictMap(void) return; } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { (void)networkId; (void)addrType; diff --git a/core/bus_center/lnn/net_builder/src/lnn_network_info.c b/core/bus_center/lnn/net_builder/src/lnn_network_info.c index 3a5f463614257cc621a8192f8a71d8869d057d17..4d3c7329d2e3ce4594d49327b5f161dc93b60819 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_network_info.c +++ b/core/bus_center/lnn/net_builder/src/lnn_network_info.c @@ -65,7 +65,7 @@ static uint32_t ConvertMsgToCapability(uint32_t *capability, const uint8_t *msg, static void PostNetchangedInfo(const char *networkId, ConnectionAddrType type) { LNN_LOGI(LNN_BUILDER, "start post offline, conntype=%{public}d", type); - if (LnnRequestLeaveSpecific(networkId, type) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, type, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "send request to NetBuilder fail"); } } @@ -188,7 +188,7 @@ static void OnReceiveUserIdSyncInfoMsg(LnnSyncInfoType type, const char *network LNN_LOGE(LNN_BUILDER, "update conn userId fail."); return; } - LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); } static uint8_t *ConvertCapabilityToMsg(uint32_t localCapability) @@ -790,7 +790,7 @@ void LnnDeinitNetworkInfo(void) static void LnnProcessUserChangeMsg(LnnSyncInfoType syncType, const char *networkId, const uint8_t *msg, uint32_t len) { - LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); } void OnLnnProcessUserChangeMsgDelay(void *para) @@ -800,7 +800,7 @@ void OnLnnProcessUserChangeMsgDelay(void *para) return; } - LnnRequestLeaveSpecific((char *)para, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific((char *)para, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); SoftBusFree(para); } @@ -819,7 +819,7 @@ static void LnnAsyncSendUserId(void *param) int32_t ret = LnnSendSyncInfoMsg(data->type, data->networkId, data->msg, data->len, data->complete); if (ret != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "send info msg type=%{public}d fail, ret:%{public}d", data->type, ret); - LnnRequestLeaveSpecific(data->networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(data->networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); } SoftBusFree(data->msg); SoftBusFree(data); @@ -837,7 +837,7 @@ static void DoSendUserId(const char *udid, uint8_t *msg) } if (LnnHasDiscoveryType(&nodeInfo, DISCOVERY_TYPE_BLE)) { LNN_LOGI(LNN_BUILDER, "ble online, no need notify offline by adv"); - LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); return; } @@ -845,7 +845,7 @@ static void DoSendUserId(const char *udid, uint8_t *msg) CreateSyncInfoParam(LNN_INFO_TYPE_USERID, nodeInfo.networkId, msg, MSG_LEN, LnnProcessUserChangeMsg); if (data == NULL) { LNN_LOGE(LNN_BUILDER, "create async info fail"); - LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); return; } ret = LnnAsyncCallbackHelper(GetLooper(LOOP_TYPE_DEFAULT), LnnAsyncSendUserId, (void *)data); @@ -853,7 +853,7 @@ static void DoSendUserId(const char *udid, uint8_t *msg) SoftBusFree(data->msg); SoftBusFree(data); LNN_LOGE(LNN_BUILDER, "async userid to peer fail"); - LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX); + LnnRequestLeaveSpecific(nodeInfo.networkId, CONNECTION_ADDR_MAX, DEVICE_LEAVE_REASON_DEFAULT); return; } diff --git a/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager.c b/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager.c index 5684c2669b825c512b02c4bb9a3f43a11a81c7bf..cfa454cb6c4226fa2912fbab4b16237f3f10a0db 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager.c +++ b/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager.c @@ -649,7 +649,7 @@ static void BleOffLineProcess(const AuthTransData *data, AuthHandle authHandle) char *anonyNetworkId = NULL; Anonymize(networkId, &anonyNetworkId); (void)LnnConvertDlId(uuid, CATEGORY_UUID, CATEGORY_NETWORK_ID, networkId, NETWORK_ID_BUF_LEN); - if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "request leave specific fail, networkId:%{public}s", AnonymizeWrapper(anonyNetworkId)); } else { @@ -726,7 +726,7 @@ static void WlanOffLineProcess(const AuthTransData *data, AuthHandle authHandle) } if (CheckWifiOfflineMsgResult(networkId, authPort, convertOfflineCode)) { Anonymize(networkId, &anonyNetworkId); - if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "wifi fast offline failed, networkId:%{public}s", AnonymizeWrapper(anonyNetworkId)); } else { LNN_LOGI(LNN_BUILDER, "wifi fast offline success networkId:%{public}s", AnonymizeWrapper(anonyNetworkId)); diff --git a/core/bus_center/lnn/net_builder/src/lnn_sync_item_info.c b/core/bus_center/lnn/net_builder/src/lnn_sync_item_info.c index f6ac8266b8e2d85c63c4e4f1844fa5e81d72bd8c..70f647747c3d2c005b3750fed3a5cd3c8d09bf6d 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_sync_item_info.c +++ b/core/bus_center/lnn/net_builder/src/lnn_sync_item_info.c @@ -187,7 +187,8 @@ static void OnReceiveBrOffline(LnnSyncInfoType type, const char *networkId, cons discType, code, peerCode); return; } - if (LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType(discType)) != SOFTBUS_OK) { + if (LnnRequestLeaveSpecific(networkId, LnnDiscTypeToConnAddrType(discType), + DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "request leave specific fail"); } } diff --git a/core/bus_center/lnn/net_buscenter/src/lnn_bt_network_impl.c b/core/bus_center/lnn/net_buscenter/src/lnn_bt_network_impl.c index 441efd2c5e3f37ff3b6b75649acd78d9b9143323..3b13166830014d688e5a5707485ea129a3a336ea 100644 --- a/core/bus_center/lnn/net_buscenter/src/lnn_bt_network_impl.c +++ b/core/bus_center/lnn/net_buscenter/src/lnn_bt_network_impl.c @@ -294,7 +294,7 @@ static void LeaveSpecificBrNetwork(const char *btMac) Anonymize(networkId, &anonyNetworkId); LNN_LOGI(LNN_BUILDER, "start leave specific br networkId=%{public}s", AnonymizeWrapper(anonyNetworkId)); AnonymizeFree(anonyNetworkId); - int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BR); + int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BR, DEVICE_LEAVE_REASON_DEFAULT); if (ret != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "leave br network fail=%{public}d", ret); } diff --git a/core/bus_center/lnn/net_buscenter/src/lnn_network_manager.c b/core/bus_center/lnn/net_buscenter/src/lnn_network_manager.c index e08dea7287ef21988d7024204aae70f18efe2658..90a3144d95c3d8f8a8398aaa9640a9e63ec57bcf 100644 --- a/core/bus_center/lnn/net_buscenter/src/lnn_network_manager.c +++ b/core/bus_center/lnn/net_buscenter/src/lnn_network_manager.c @@ -19,6 +19,7 @@ #include #include +#include "anonymizer.h" #include "auth_interface.h" #include "bus_center_event.h" #include "bus_center_manager.h" @@ -85,7 +86,7 @@ typedef struct { static bool g_isNightMode = false; static bool g_isOOBEEnd = false; static bool g_isUnLock = false; -static bool g_isDeviceRoot = false; +static bool g_isDeviceRisk = false; static SoftBusUserState g_backgroundState = SOFTBUS_USER_FOREGROUND; int32_t RegistIPProtocolManager(void); @@ -300,54 +301,61 @@ static void NetUserStateEventHandler(const LnnEventBasicInfo *info) } } -static int32_t NetRootDeviceLeaveLnn(void) +int32_t NetRiskDeviceOpenAuthPort(void) { - LNN_LOGI(LNN_BUILDER, "enter NetRootDeviceLeaveLnn"); - int32_t i = 0; - int32_t infoNum = 0; - NodeBasicInfo *info = NULL; - if (LnnGetAllOnlineNodeInfo(&info, &infoNum) != SOFTBUS_OK) { - LNN_LOGE(LNN_BUILDER, "get online node info failed"); - return SOFTBUS_NETWORK_GET_ALL_NODE_INFO_ERR; + char localIp[MAX_ADDR_LEN] = {0}; + + int32_t authPort; + if (LnnGetLocalNumInfoByIfnameIdx(NUM_KEY_AUTH_PORT, &authPort, WLAN_IF) != SOFTBUS_OK) { + LNN_LOGE(LNN_BUILDER, "get port failed"); + authPort = 0; } - if (info == NULL || infoNum == 0) { - LNN_LOGE(LNN_BUILDER, "get online node is 0"); - return SOFTBUS_NO_ONLINE_DEVICE; + + if (LnnGetLocalStrInfoByIfnameIdx(STRING_KEY_IP, localIp, MAX_ADDR_LEN, WLAN_IF) != SOFTBUS_OK) { + LNN_LOGE(LNN_BUILDER, "get local ip failed"); + return SOFTBUS_NETWORK_GET_NODE_INFO_ERR; } - int32_t ret; - NodeInfo nodeInfo; - (void)memset_s(&nodeInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo)); - for (i = 0; i < infoNum; ++i) { - ret = LnnGetRemoteNodeInfoById(info[i].networkId, CATEGORY_NETWORK_ID, &nodeInfo); - if (ret != SOFTBUS_OK) { - continue; - } - LNN_LOGI(LNN_BUILDER, "device is root, need to offline"); - LnnRequestLeaveSpecific(info[i].networkId, CONNECTION_ADDR_MAX); - AuthRemoveDeviceKeyByUdidPacked(nodeInfo.deviceInfo.deviceUdid); + int32_t port = AuthStartListening(AUTH_LINK_TYPE_WIFI, localIp, authPort); + if (port < 0) { + LNN_LOGE(LNN_BUILDER, "AuthStartListening failed"); + return SOFTBUS_INVALID_PORT; + } + char *anonyIp = NULL; + Anonymize(localIp, &anonyIp); + LNN_LOGI(LNN_BUILDER, "open auth port listening on ip=%{public}s", AnonymizeWrapper(anonyIp)); + AnonymizeFree(anonyIp); + if (authPort == 0) { + return LnnSetLocalNumInfoByIfnameIdx(NUM_KEY_AUTH_PORT, port, WLAN_IF); } - SoftBusFree(info); return SOFTBUS_OK; } -static void NetDeviceRootStateEventHandler(const LnnEventBasicInfo *info) +static void NetDeviceRiskStateEventHandler(const LnnEventBasicInfo *info) { - if (info == NULL || info->event != LNN_EVENT_DEVICE_ROOT_STATE_CHANGED) { - LNN_LOGE(LNN_BUILDER, "device root state change evt handler get invalid param"); + if (info == NULL || info->event != LNN_EVENT_DEVICE_RISK_STATE_CHANGED) { + LNN_LOGE(LNN_BUILDER, "device risk state change evt handler get invalid param"); return; } - const LnnDeviceRootStateChangeEvent *event = (const LnnDeviceRootStateChangeEvent *)info; - SoftBusDeviceRootState deviceRootState = (SoftBusDeviceRootState)event->status; - LNN_LOGI(LNN_BUILDER, "device root state=%{public}d", deviceRootState); - switch (deviceRootState) { - case SOFTBUS_DEVICE_IS_ROOT: - g_isDeviceRoot = true; + const LnnDeviceRiskStateChangeEvent *event = (const LnnDeviceRiskStateChangeEvent *)info; + SoftBusDeviceRiskState deviceRiskState = (SoftBusDeviceRiskState)event->status; + LNN_LOGI(LNN_BUILDER, "device risk state=%{public}d", deviceRiskState); + switch (deviceRiskState) { + case SOFTBUS_DEVICE_IS_RISK: + if (g_isDeviceRisk) { + LNN_LOGI(LNN_BUILDER, "device is risk"); + } + g_isDeviceRisk = true; AuthStopListening(AUTH_LINK_TYPE_WIFI); LnnStopPublish(); LnnStopDiscovery(); - NetRootDeviceLeaveLnn(); + RiskDeviceLeaveLnn(); break; - case SOFTBUS_DEVICE_NOT_ROOT: + case SOFTBUS_DEVICE_NOT_RISK: + if (g_isDeviceRisk == true) { + NetRiskDeviceOpenAuthPort(); + RestartCoapDiscovery(); + } + g_isDeviceRisk = false; break; default: break; @@ -416,6 +424,7 @@ static void RetryCheckOOBEState(void *para) if (!IsOOBEState()) { LNN_LOGI(LNN_BUILDER, "wifi handle SOFTBUS_OOBE_END"); LnnNotifyOOBEStateChangeEvent(SOFTBUS_OOBE_END); + LnnNotifyDeviceRiskStateChangeEvent(); } else { LNN_LOGD(LNN_BUILDER, "check OOBE again after a delay. delay=%{public}" PRIu64 "ms", (uint64_t)LNN_CHECK_OOBE_DELAY_LEN); @@ -829,8 +838,8 @@ static int32_t LnnRegisterEvent(void) LNN_LOGE(LNN_BUILDER, "Net regist data share evt handler fail"); return SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR; } - if (LnnRegisterEventHandler(LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, NetDeviceRootStateEventHandler) != SOFTBUS_OK) { - LNN_LOGE(LNN_BUILDER, "Net regist device root evt handler fail"); + if (LnnRegisterEventHandler(LNN_EVENT_DEVICE_RISK_STATE_CHANGED, NetDeviceRiskStateEventHandler) != SOFTBUS_OK) { + LNN_LOGE(LNN_BUILDER, "Net regist device risk evt handler fail"); return SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR; } return SOFTBUS_OK; @@ -944,11 +953,11 @@ bool LnnIsAutoNetWorkingEnabled(void) } LNN_LOGI(LNN_BUILDER, "wifi condition state:config=%{public}d, background=%{public}d, nightMode=%{public}d, OOBEEnd=%{public}d, " - "unlock=%{public}d, init check=%{public}d, deviceRoot=%{public}d", + "unlock=%{public}d, init check=%{public}d, DeviceRisk=%{public}d", isConfigEnabled, g_backgroundState == SOFTBUS_USER_BACKGROUND, g_isNightMode, g_isOOBEEnd, g_isUnLock, - isInitCheckSuc, g_isDeviceRoot); + isInitCheckSuc, g_isDeviceRisk); return isConfigEnabled && (g_backgroundState == SOFTBUS_USER_FOREGROUND) && !g_isNightMode && - g_isOOBEEnd && g_isUnLock && isInitCheckSuc && !g_isDeviceRoot; + g_isOOBEEnd && g_isUnLock && isInitCheckSuc && !g_isDeviceRisk; } void LnnDeinitNetworkManager(void) @@ -984,7 +993,7 @@ void LnnDeinitNetworkManager(void) LnnUnregisterEventHandler(LNN_EVENT_OOBE_STATE_CHANGED, NetOOBEStateEventHandler); LnnUnregisterEventHandler(LNN_EVENT_ACCOUNT_CHANGED, NetAccountStateChangeEventHandler); LnnUnregisterEventHandler(LNN_EVENT_DATA_SHARE_STATE_CHANGE, DataShareStateEventHandler); - LnnUnregisterEventHandler(LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, NetDeviceRootStateEventHandler); + LnnUnregisterEventHandler(LNN_EVENT_DEVICE_RISK_STATE_CHANGED, NetDeviceRiskStateEventHandler); (void)SoftBusMutexDestroy(&g_dataShareLock); } diff --git a/core/bus_center/service/include/bus_center_event.h b/core/bus_center/service/include/bus_center_event.h index 6290410ca1e8f5db2adc3e150fe0aef7f97bd7b5..6006b1ea1418f62217430d756c6c55d8ea273137 100644 --- a/core/bus_center/service/include/bus_center_event.h +++ b/core/bus_center/service/include/bus_center_event.h @@ -94,7 +94,7 @@ void LnnNotifyWifiServiceStart(void *para); void LnnNotifyAddRawEnhanceP2pEvent(LnnNotifyRawEnhanceP2pEvent *event); -void LnnNotifyDeviceRootStateChangeEvent(void); +void LnnNotifyDeviceRiskStateChangeEvent(void); #ifdef __cplusplus } diff --git a/core/bus_center/service/src/bus_center_decision_center.c b/core/bus_center/service/src/bus_center_decision_center.c index 33a9d8aa4a55757d0c7a6fc84314aa4367c0210d..cc5ae3a24e7c8d0ddc45c7549d22f0b5b04fabe2 100755 --- a/core/bus_center/service/src/bus_center_decision_center.c +++ b/core/bus_center/service/src/bus_center_decision_center.c @@ -57,7 +57,7 @@ static void LeaveSpecificBrNetwork(const char *addr) return; } - int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BR); + int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BR, DEVICE_LEAVE_REASON_DEFAULT); if (ret != SOFTBUS_OK) { LNN_LOGW(LNN_STATE, "leave br network failed, ret=%{public}d", ret); } diff --git a/core/bus_center/service/src/bus_center_event.c b/core/bus_center/service/src/bus_center_event.c index f365cb7271b0b7f96f3b09ec8d439c4a9aa51dd1..e830d0eb18c28b4330b2928c3cf65ff6d1614b1d 100644 --- a/core/bus_center/service/src/bus_center_event.c +++ b/core/bus_center/service/src/bus_center_event.c @@ -690,16 +690,16 @@ void LnnNotifyVapInfoChangeEvent(int32_t preferChannel) NotifyEvent((const LnnEventBasicInfo *)&event); } -void LnnNotifyDeviceRootStateChangeEvent(void) +void LnnNotifyDeviceRiskStateChangeEvent(void) { - SoftBusDeviceRootState state = SOFTBUS_DEVICE_ROOT_UNKNOWN; + SoftBusDeviceRiskState state = SOFTBUS_DEVICE_RISK_UNKNOWN; if (IsDeviceHasRiskFactorPacked()) { - state = SOFTBUS_DEVICE_IS_ROOT; + state = SOFTBUS_DEVICE_IS_RISK; } else { - state = SOFTBUS_DEVICE_NOT_ROOT; + state = SOFTBUS_DEVICE_NOT_RISK; } - LnnDeviceRootStateChangeEvent event = {.basic.event = LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, - .status = (uint8_t)state}; + LnnDeviceRiskStateChangeEvent event = {.basic.event = LNN_EVENT_DEVICE_RISK_STATE_CHANGED, + .status = state}; NotifyEvent((const LnnEventBasicInfo *)&event); } diff --git a/core/frame/init/include/g_reg_lnn_ext_func.h b/core/frame/init/include/g_reg_lnn_ext_func.h index f9e66c1b2c28657452054eeec2179469c0fad1d0..9508c06b92185ece418b1bbe70dde11ad47417b0 100644 --- a/core/frame/init/include/g_reg_lnn_ext_func.h +++ b/core/frame/init/include/g_reg_lnn_ext_func.h @@ -163,7 +163,8 @@ typedef int (*SoftBusChannelToFrequencyFunc)(int channel); typedef bool (*SoftBusIs5GBandFunc)(int frequency); typedef int32_t (*LnnNotifyDiscoveryDeviceFunc)( const ConnectionAddr *addr, const LnnDfxDeviceInfoReport *infoReport, bool isNeedConnect); -typedef int32_t (*LnnRequestLeaveSpecificFunc)(const char *networkId, ConnectionAddrType addrType); +typedef int32_t (*LnnRequestLeaveSpecificFunc)(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason); typedef ListenerModule (*LnnGetProtocolListenerModuleFunc)(ProtocolType protocol, ListenerMode mode); typedef char *(*LnnConvertIdToDeviceTypeFunc)(uint16_t typeId); typedef int32_t (*LnnConvertDeviceTypeToIdFunc)(const char *deviceType, uint16_t *typeId); diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c index 221b893097f130bc24e893f9a7e7f2073320930f..f65765a6eb838b7dcff641e1671993171c55e38f 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c @@ -297,7 +297,7 @@ static void SendFailToFlushDevice(SessionConn *conn) AnonymizeFree(tmpId); if (AuthFlushDevice(conn->appInfo.peerData.deviceId) != SOFTBUS_OK) { TRANS_LOGE(TRANS_CTRL, "tcp flush failed, wifi will offline"); - LnnRequestLeaveSpecific(conn->appInfo.peerNetWorkId, CONNECTION_ADDR_WLAN); + LnnRequestLeaveSpecific(conn->appInfo.peerNetWorkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); } } } diff --git a/interfaces/kits/bus_center/bus_center_event_struct.h b/interfaces/kits/bus_center/bus_center_event_struct.h index 3729b906a3f35fe32507446a20ee73b0fd445afe..c3502c1bcafe65481e6212aae5efa08d62cdfa88 100644 --- a/interfaces/kits/bus_center/bus_center_event_struct.h +++ b/interfaces/kits/bus_center/bus_center_event_struct.h @@ -62,7 +62,8 @@ typedef enum { /* event from sa monitor */ LNN_EVENT_WIFI_SERVICE_START, LNN_EVENT_NOTIFY_RAW_ENHANCE_P2P, - LNN_EVENT_DEVICE_ROOT_STATE_CHANGED, + LNN_EVENT_DEVICE_RISK_STATE_CHANGED, + LNN_EVENT_HA_LEAVE_META_NODE, LNN_EVENT_TYPE_MAX, } LnnEventType; @@ -201,10 +202,10 @@ typedef enum { } NetManagerIfNameState; typedef enum { - SOFTBUS_DEVICE_NOT_ROOT, - SOFTBUS_DEVICE_IS_ROOT, - SOFTBUS_DEVICE_ROOT_UNKNOWN, -} SoftBusDeviceRootState; + SOFTBUS_DEVICE_NOT_RISK, + SOFTBUS_DEVICE_IS_RISK, + SOFTBUS_DEVICE_RISK_UNKNOWN, +} SoftBusDeviceRiskState; typedef struct { LnnEventBasicInfo basic; @@ -312,8 +313,8 @@ typedef struct { typedef struct { LnnEventBasicInfo basic; - uint8_t status; -} LnnDeviceRootStateChangeEvent; + SoftBusDeviceRiskState status; +} LnnDeviceRiskStateChangeEvent; typedef void (*LnnEventHandler)(const LnnEventBasicInfo *info); diff --git a/interfaces/kits/common/softbus_common.h b/interfaces/kits/common/softbus_common.h index 090c4c8ad06b96d172406534b4e7aaeebbbb08fc..95041f1f824496acc2d225d7a93d25f4274c9c50 100644 --- a/interfaces/kits/common/softbus_common.h +++ b/interfaces/kits/common/softbus_common.h @@ -654,6 +654,17 @@ typedef enum { SAME_ACCOUNT_REQUEST_ENABLE_BLE_DISCOVERY, } StrategyForBle; +/** + * @brief Defines the Device Leaving Reason. + */ +typedef enum { + /* Default leave reason */ + DEVICE_LEAVE_REASON_DEFAULT = 0, + /* Device not trust leave reason */ + DEVICE_LEAVE_REASON_NOT_TRUST, + DEVICE_LEAVE_REASON_MAX, +} DeviceLeaveReason; + #ifdef __cplusplus } #endif diff --git a/interfaces/kits/lnn/lnn_net_builder_struct.h b/interfaces/kits/lnn/lnn_net_builder_struct.h index b00c7468bfeaa16aebf92c68e3386c665d2a5118..13b2049c0e5257f214969d8beafb389965bedb02 100644 --- a/interfaces/kits/lnn/lnn_net_builder_struct.h +++ b/interfaces/kits/lnn/lnn_net_builder_struct.h @@ -130,6 +130,7 @@ typedef struct { typedef struct { char networkId[NETWORK_ID_BUF_LEN]; ConnectionAddrType addrType; + DeviceLeaveReason leaveReason; } SpecificLeaveMsgPara; typedef struct { diff --git a/tests/core/authentication/unittest/auth_common_mock.cpp b/tests/core/authentication/unittest/auth_common_mock.cpp index d62c0d48443b74fa6d6716aa529aa9f497ce05af..046e58d1cc3dce6a6d6e3a93f8ac8db9d94055ee 100644 --- a/tests/core/authentication/unittest/auth_common_mock.cpp +++ b/tests/core/authentication/unittest/auth_common_mock.cpp @@ -118,9 +118,10 @@ int32_t LnnNotifyLeaveLnnByAuthHandle(AuthHandle *authHandle) return GetCommonInterface()->LnnNotifyLeaveLnnByAuthHandle(authHandle); } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) { - return GetCommonInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return GetCommonInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac) diff --git a/tests/core/authentication/unittest/auth_common_mock.h b/tests/core/authentication/unittest/auth_common_mock.h index 4a9c541c97dc49eb1b14af225b4663cc17aecb6a..11b44d462f53f1fd1896b983828b639c51d00c67 100644 --- a/tests/core/authentication/unittest/auth_common_mock.h +++ b/tests/core/authentication/unittest/auth_common_mock.h @@ -59,7 +59,8 @@ public: virtual int32_t LnnSetLocalStrInfo(InfoKey key, const char *info) = 0; virtual int32_t LnnNotifyEmptySessionKey(int64_t authId) = 0; virtual int32_t LnnNotifyLeaveLnnByAuthHandle(AuthHandle *authHandle); - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType); + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason); virtual int32_t LnnGetRemoteNumU64Info(const char *networkId, InfoKey key, uint64_t *info) = 0; virtual int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0; virtual int32_t GetNodeFromPcRestrictMap(const char *udidHash, uint32_t *count) = 0; @@ -103,7 +104,7 @@ public: MOCK_METHOD2(LnnSetLocalStrInfo, int32_t(InfoKey, const char *)); MOCK_METHOD1(LnnNotifyEmptySessionKey, int32_t(int64_t)); MOCK_METHOD1(LnnNotifyLeaveLnnByAuthHandle, int32_t(AuthHandle *)); - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD1(SoftBusGetBtMacAddr, int32_t(SoftBusBtAddr *)); MOCK_METHOD2(GetNodeFromPcRestrictMap, int32_t(const char *, uint32_t *)); MOCK_METHOD1(DeleteNodeFromPcRestrictMap, void(const char *)); diff --git a/tests/core/bus_center/lnn/BUILD.gn b/tests/core/bus_center/lnn/BUILD.gn index 3bee6fb8aa44cff78814dcbc4215f38be000d105..17538257591efca8efb682445f112282334f62d6 100644 --- a/tests/core/bus_center/lnn/BUILD.gn +++ b/tests/core/bus_center/lnn/BUILD.gn @@ -2331,12 +2331,12 @@ ohos_unittest("LNNHeartBeatTest") { ] } -ohos_unittest("LNNHeartBeatDeviceRootTest") +ohos_unittest("LnnHeartBeatDeviceRiskTest") { module_out_path = module_output_path sources = [ - "$dsoftbus_root_path/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_root_test.cpp", - "$dsoftbus_root_path/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.cpp", + "$dsoftbus_root_path/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_risk_test.cpp", + "$dsoftbus_root_path/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.cpp", ] include_dirs = [ @@ -4009,6 +4009,7 @@ group("unittest") { ":LNNTimeSyncTest", ":LNNTimeSyncOtherTest", ":LNNHeartBeatTest", + ":LnnHeartBeatDeviceRiskTest", ] if (dsoftbus_feature_lnn_lane_mgr) { deps += [ diff --git a/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_root_test.cpp b/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_risk_test.cpp similarity index 59% rename from tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_root_test.cpp rename to tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_risk_test.cpp index 052dbe9c1d460f5f8d34a570231bb74a5fa7036d..e57874942e97ca25747d15cd12c2d22b4311f245 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_root_test.cpp +++ b/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_device_risk_test.cpp @@ -23,7 +23,7 @@ #include "lnn_connection_fsm.h" #include "lnn_device_info.h" #include "lnn_heartbeat_ctrl.c" -#include "lnn_heartbeat_device_root_mock.h" +#include "lnn_heartbeat_device_risk_mock.h" #include "lnn_heartbeat_strategy.h" #include "lnn_node_info.h" #include "message_handler.h" @@ -36,7 +36,7 @@ using namespace testing::ext; NodeInfo nodeinfo1; -class LnnHeartBeatDeviceRootTest : public testing::Test { +class LnnHeartBeatDeviceRiskTest : public testing::Test { public: static void SetUpTestCase(); @@ -47,63 +47,63 @@ public: void TearDown(); }; -void LnnHeartBeatDeviceRootTest::SetUpTestCase() +void LnnHeartBeatDeviceRiskTest::SetUpTestCase() { } -void LnnHeartBeatDeviceRootTest::TearDownTestCase() +void LnnHeartBeatDeviceRiskTest::TearDownTestCase() { } -void LnnHeartBeatDeviceRootTest::SetUp() +void LnnHeartBeatDeviceRiskTest::SetUp() {} -void LnnHeartBeatDeviceRootTest::TearDown() +void LnnHeartBeatDeviceRiskTest::TearDown() {} /* - * @tc.name: HbRootDeviceLeaveLnnTest01 + * @tc.name: RiskDeviceLeaveLnnTest01 * @tc.desc: use abnomal parameter * @tc.type: FUNC * @tc.require: */ -HWTEST_F(LnnHeartBeatDeviceRootTest, HbRootDeviceLeaveLnnTest001, TestSize.Level1) +HWTEST_F(LnnHeartBeatDeviceRiskTest, RiskDeviceLeaveLnnTest001, TestSize.Level1) { int ret = 0; - NiceMock LnnMock; + NiceMock LnnMock; EXPECT_CALL(LnnMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_ERR)); - ret = HbRootDeviceLeaveLnn(); + ret = RiskDeviceLeaveLnn(); EXPECT_EQ(ret, SOFTBUS_NETWORK_GET_ALL_NODE_INFO_ERR); EXPECT_CALL(LnnMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_OK)); - ret = HbRootDeviceLeaveLnn(); + ret = RiskDeviceLeaveLnn(); EXPECT_EQ(ret, SOFTBUS_NO_ONLINE_DEVICE); } /* - * @tc.name: HbDeviceRootStateEventHandlerTest01 + * @tc.name: HbDeviceRiskStateEventHandlerTest01 * @tc.desc: use abnomal parameter * @tc.type: FUNC * @tc.require: */ -HWTEST_F(LnnHeartBeatDeviceRootTest, HbDeviceRootStateEventHandlerTest001, TestSize.Level1) +HWTEST_F(LnnHeartBeatDeviceRiskTest, HbDeviceRiskStateEventHandlerTest001, TestSize.Level1) { - LnnDeviceRootStateChangeEvent *event = - reinterpret_cast(SoftBusCalloc(sizeof(LnnDeviceRootStateChangeEvent))); + LnnDeviceRiskStateChangeEvent *event = + reinterpret_cast(SoftBusCalloc(sizeof(LnnDeviceRiskStateChangeEvent))); event->basic.event = LNN_EVENT_TYPE_MAX; - event->status = SOFTBUS_DEVICE_IS_ROOT; - g_hbConditionState.deviceRootState = SOFTBUS_DEVICE_IS_ROOT; - HbDeviceRootStateEventHandler(NULL); + event->status = SOFTBUS_DEVICE_IS_RISK; + g_hbConditionState.deviceRiskState = SOFTBUS_DEVICE_IS_RISK; + HbDeviceRiskStateEventHandler(NULL); - HbDeviceRootStateEventHandler(&event->basic); + HbDeviceRiskStateEventHandler(&event->basic); - event->basic.event = LNN_EVENT_DEVICE_ROOT_STATE_CHANGED; - HbDeviceRootStateEventHandler(&event->basic); + event->basic.event = LNN_EVENT_DEVICE_RISK_STATE_CHANGED; + HbDeviceRiskStateEventHandler(&event->basic); - g_hbConditionState.deviceRootState = SOFTBUS_DEVICE_NOT_ROOT; - event->status = SOFTBUS_DEVICE_NOT_ROOT; - HbDeviceRootStateEventHandler(&event->basic); + g_hbConditionState.deviceRiskState = SOFTBUS_DEVICE_NOT_RISK; + event->status = SOFTBUS_DEVICE_NOT_RISK; + HbDeviceRiskStateEventHandler(&event->basic); EXPECT_EQ(event->status, 0); } diff --git a/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_test.cpp b/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_test.cpp index 72d50dc8dfaf16c697edea3dd08ddfc0a80528e0..26e5edc6e5259d7912d9f9220c3170aede61ade4 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_test.cpp +++ b/tests/core/bus_center/lnn/lane/lane_hub/heartbeat/lnn_heartbeat_test.cpp @@ -64,7 +64,7 @@ void InitLedgerMock(LedgerInterfaceMock &hbLnnMock) ON_CALL(hbLnnMock, LnnGetDLHeartbeatTimestamp(_, _)).WillByDefault(DoAll(SetArgPointee<1>(1), Return(SOFTBUS_OK))); ON_CALL(hbLnnMock, LnnGetOnlineStateById(_, _)).WillByDefault(Return(true)); ON_CALL(hbLnnMock, LnnGetRemoteStrInfo(_, _, _, _)).WillByDefault(Return(SOFTBUS_OK)); - ON_CALL(hbLnnMock, LnnRequestLeaveSpecific(_, _)).WillByDefault(Return(SOFTBUS_OK)); + ON_CALL(hbLnnMock, LnnRequestLeaveSpecific(_, _, _)).WillByDefault(Return(SOFTBUS_OK)); ON_CALL(hbLnnMock, LnnGetAllOnlineNodeInfo(_, _)).WillByDefault(Return(SOFTBUS_OK)); ON_CALL(hbLnnMock, LnnGetTrustedDevInfoFromDb(_, _)) .WillByDefault(LedgerInterfaceMock::ActionOfGetTrustedDevInfoFromDb); diff --git a/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.cpp b/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.cpp index bf8089a77ab75cf13ca96a859dbac885e3cbc514..51bf488994585853d43d2c440c0f1119e3d37d05 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.cpp +++ b/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.cpp @@ -81,9 +81,9 @@ int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint return GetLedgerInterface()->LnnGetRemoteStrInfo(netWorkId, key, info, len); } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return GetLedgerInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return GetLedgerInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum) diff --git a/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.h b/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.h index d054f3e2b067df267e1a26d5b033c356b1129fa2..9cd840edafa52303b6371d46f87e12b146b7c608 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.h +++ b/tests/core/bus_center/lnn/lane/lane_hub/mock/ledger_mock.h @@ -47,7 +47,8 @@ public: virtual int32_t LnnGetDLHeartbeatTimestamp(const char *networkId, uint64_t *timestamp) = 0; virtual bool LnnGetOnlineStateById(const char *id, IdCategory type) = 0; virtual int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len) = 0; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum) = 0; virtual int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num) = 0; virtual const char *LnnConvertDLidToUdid(const char *id, IdCategory type) = 0; @@ -78,7 +79,7 @@ public: MOCK_METHOD2(LnnGetDLHeartbeatTimestamp, int32_t(const char *, uint64_t *)); MOCK_METHOD2(LnnGetOnlineStateById, bool(const char *, IdCategory)); MOCK_METHOD4(LnnGetRemoteStrInfo, int32_t(const char *, InfoKey, char *, uint32_t)); - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD2(LnnGetAllOnlineNodeInfo, int32_t(NodeBasicInfo **, int32_t *)); MOCK_METHOD2(LnnGetTrustedDevInfoFromDb, int32_t(char **, uint32_t *)); MOCK_METHOD2(LnnConvertDLidToUdid, char*(const char *, IdCategory)); @@ -117,7 +118,7 @@ extern "C" { int32_t LnnGetDLHeartbeatTimestamp(const char *networkId, uint64_t *timestamp); bool LnnGetOnlineStateById(const char *id, IdCategory type); int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len); - int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType); + int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason); int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum); int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num); const char *LnnConvertDLidToUdid(const char *id, IdCategory type); diff --git a/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.cpp b/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.cpp similarity index 52% rename from tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.cpp rename to tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.cpp index c8bc56bf0a8e200e74d5c73235bc7ebc004c9f3b..a332ef64a8a9513a3e48d09e41230f4e3d05120c 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.cpp +++ b/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.cpp @@ -13,42 +13,42 @@ * limitations under the License. */ -#include "lnn_heartbeat_device_root_mock.h" +#include "lnn_heartbeat_device_risk_mock.h" using namespace testing; using namespace testing::ext; namespace OHOS { -void *g_lnnHeatbeatStaticInterface; -LnnHeatbeatStaticInterfaceMock::LnnHeatbeatStaticInterfaceMock() +void *g_lnnHeatbeatDeviceRiskInterface; +LnnHeatbeatDeviceRiskInterfaceMock::LnnHeatbeatDeviceRiskInterfaceMock() { - g_lnnHeatbeatStaticInterface = reinterpret_cast(this); + g_lnnHeatbeatDeviceRiskInterface = reinterpret_cast(this); } -LnnHeatbeatStaticInterfaceMock::~LnnHeatbeatStaticInterfaceMock() +LnnHeatbeatDeviceRiskInterfaceMock::~LnnHeatbeatDeviceRiskInterfaceMock() { - g_lnnHeatbeatStaticInterface = nullptr; + g_lnnHeatbeatDeviceRiskInterface = nullptr; } -static LnnHeatbeatStaticInterface *GetLnnHeatbeatStaticInterface() +static LnnHeatbeatDeviceRiskInterface *GetLnnHeatbeatDeviceRiskInterface() { - return reinterpret_cast(g_lnnHeatbeatStaticInterface); + return reinterpret_cast(g_lnnHeatbeatDeviceRiskInterface); } extern "C" { -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return GetLnnHeatbeatStaticInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return GetLnnHeatbeatDeviceRiskInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum) { - return GetLnnHeatbeatStaticInterface()->LnnGetAllOnlineNodeInfo(info, infoNum); + return GetLnnHeatbeatDeviceRiskInterface()->LnnGetAllOnlineNodeInfo(info, infoNum); } int32_t LnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info) { - return GetLnnHeatbeatStaticInterface()->LnnGetRemoteNodeInfoById(id, type, info); + return GetLnnHeatbeatDeviceRiskInterface()->LnnGetRemoteNodeInfoById(id, type, info); } } } // namespace OHOS \ No newline at end of file diff --git a/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.h b/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.h similarity index 73% rename from tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.h rename to tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.h index 6f2ef6986c5f89134dda397c095efc0cc69990ef..6a637bf3834d0bdeb3c6d2adea98141ecdef765f 100644 --- a/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_root_mock.h +++ b/tests/core/bus_center/lnn/lane/lane_hub/mock/lnn_heartbeat_device_risk_mock.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef LNN_HEARTBEAT_SATIC_MOCK_H -#define LNN_HEARTBEAT_SATIC_MOCK_H +#ifndef LNN_HEARTBEAT_DEVICE_RISK_MOCK_H +#define LNN_HEARTBEAT_DEVICE_RISK_MOCK_H #include #include @@ -33,22 +33,23 @@ #include "softbus_error_code.h" namespace OHOS { -class LnnHeatbeatStaticInterface { +class LnnHeatbeatDeviceRiskInterface { public: - LnnHeatbeatStaticInterface() {}; - virtual ~LnnHeatbeatStaticInterface() {}; + LnnHeatbeatDeviceRiskInterface() {}; + virtual ~LnnHeatbeatDeviceRiskInterface() {}; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum) = 0; virtual int32_t LnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info) = 0; }; -class LnnHeatbeatStaticInterfaceMock : public LnnHeatbeatStaticInterface { +class LnnHeatbeatDeviceRiskInterfaceMock : public LnnHeatbeatDeviceRiskInterface { public: - LnnHeatbeatStaticInterfaceMock(); - ~LnnHeatbeatStaticInterfaceMock() override; + LnnHeatbeatDeviceRiskInterfaceMock(); + ~LnnHeatbeatDeviceRiskInterfaceMock() override; MOCK_METHOD2(LnnGetAllOnlineNodeInfo, int32_t(NodeBasicInfo **, int32_t *)); - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD3(LnnGetRemoteNodeInfoById, int32_t(const char *id, IdCategory type, NodeInfo *info)); }; } // namespace OHOS diff --git a/tests/core/bus_center/lnn/net_builder/include/lnn_net_builder_mock.h b/tests/core/bus_center/lnn/net_builder/include/lnn_net_builder_mock.h index 5d1cf9b71251d2ae6b998fbd34c0f46f7feceab6..e80e54c242fa92f233f2c91e22f92d9e657f82a1 100644 --- a/tests/core/bus_center/lnn/net_builder/include/lnn_net_builder_mock.h +++ b/tests/core/bus_center/lnn/net_builder/include/lnn_net_builder_mock.h @@ -27,7 +27,8 @@ public: LnnNetBuilderInterface() {}; virtual ~LnnNetBuilderInterface() {}; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual int32_t LnnSetDLConnUserId(const char *networkId, int32_t userId) = 0; virtual int32_t LnnSetDLConnUserIdCheckSum(const char *networkId, int32_t userIdCheckSum) = 0; }; @@ -37,7 +38,7 @@ public: LnnNetBuilderInterfaceMock(); ~LnnNetBuilderInterfaceMock() override; - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD2(LnnSetDLConnUserId, int32_t(const char *networkId, int32_t userId)); MOCK_METHOD2(LnnSetDLConnUserIdCheckSum, int32_t(const char *networkId, int32_t userIdCheckSum)); }; diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock.cpp index 3a816919dc07d0cb3661b706a8fe84f60be5b42c..eaabd7868dddd96074c947945a02b2d339c562b5 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock.cpp @@ -36,9 +36,9 @@ static LnnNetBuilderInterface *GetLnnNetBuilderInterface() } extern "C" { -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return GetLnnNetBuilderInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return GetLnnNetBuilderInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t LnnSetDLConnUserId(const char *networkId, int32_t userId) diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_test.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_test.cpp index 3051b50aec1971452918628f970962ac385ca6e2..9f307c932aeb0af1449330769809dcfd6cfdfc2a 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_test.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_test.cpp @@ -133,13 +133,13 @@ HWTEST_F(LNNNetBuilderTest, LNN_REQUEST_LEAVE_BY_ADDRTYPE_TEST_001, TestSize.Lev HWTEST_F(LNNNetBuilderTest, LNN_REQUEST_LEAVE_SPECIFIC_TEST_001, TestSize.Level0) { char *networkId = nullptr; - int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN); + int32_t ret = LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM); - ret = LnnRequestLeaveSpecific(NETWORKID, CONNECTION_ADDR_WLAN); + ret = LnnRequestLeaveSpecific(NETWORKID, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); EXPECT_TRUE(ret == SOFTBUS_NO_INIT); ret = LnnInitNetBuilder(); EXPECT_TRUE(ret == SOFTBUS_OK); - ret = LnnRequestLeaveSpecific(NETWORKID, CONNECTION_ADDR_WLAN); + ret = LnnRequestLeaveSpecific(NETWORKID, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT); EXPECT_TRUE(ret == SOFTBUS_OK); } diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_network_info_test.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_network_info_test.cpp index b12200b17e64d389d233a969bd2b9a093e9aa7c4..96f6beb8fc6d695d1d7d840ea8b797e98ecec5bc 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_network_info_test.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_network_info_test.cpp @@ -64,10 +64,11 @@ void LNNNetworkInfoTest::SetUp() { } void LNNNetworkInfoTest::TearDown() { } -int32_t TestLnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t TestLnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { (void)networkId; (void)addrType; + (void)leaveReason; return SOFTBUS_OK; } diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager_test.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager_test.cpp index d2c6f94defb673a05a7ffca2c97598e4bcf398f8..46704b0072c63be2c62e236871fcc95cf333399a 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager_test.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_sync_info_manager_test.cpp @@ -1205,7 +1205,7 @@ HWTEST_F(LNNSyncInfoManagerTest, BleOffLineProcess_004, TestSize.Level1) /* * @tc.name: BleOffLineProcess_005 - * @tc.desc: LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE) != SOFTBUS_OK + * @tc.desc: LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_BLE, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK * @tc.type: FUNC * @tc.require: 1 */ @@ -1446,7 +1446,7 @@ HWTEST_F(LNNSyncInfoManagerTest, WlanOffLineProcess_004, TestSize.Level1) /* * @tc.name: WlanOffLineProcess_005 * @tc.desc: CheckWifiOfflineMsgResult(networkId, authPort, convertOfflineCode) == true && - * LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN) != SOFTBUS_OK + * LnnRequestLeaveSpecific(networkId, CONNECTION_ADDR_WLAN, DEVICE_LEAVE_REASON_DEFAULT) != SOFTBUS_OK * @tc.type: FUNC * @tc.require: 1 */ diff --git a/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.cpp b/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.cpp index e5bb737cf0c259aa97032c63b5aaeb9c3587895c..028c10c7d0e54b7ab70dca1744ec3b805dd2093a 100644 --- a/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.cpp +++ b/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.cpp @@ -49,9 +49,9 @@ int32_t LnnBtNetworkImplInterfaceMock::ActionOfLnnGetNetIfTypeByNameBle(const ch } extern "C" { -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return GetLnnBtNetworkImplInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return GetLnnBtNetworkImplInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) diff --git a/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.h b/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.h index c84f7b3c6a4f4d9ee59c5f35fe9e887939a0b13d..0c91e7dc68919bf4049d2221df76a37a6d6f2fed 100644 --- a/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.h +++ b/tests/core/bus_center/lnn/net_buscenter/lnn_bt_network_impl_mock.h @@ -39,7 +39,8 @@ class LnnBtNetworkImplInterface { public: LnnBtNetworkImplInterface() {}; virtual ~LnnBtNetworkImplInterface() {}; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0; virtual int32_t SoftBusGetBtState(void) = 0; virtual int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0; @@ -132,7 +133,7 @@ class LnnBtNetworkImplInterfaceMock : public LnnBtNetworkImplInterface { public: LnnBtNetworkImplInterfaceMock(); ~LnnBtNetworkImplInterfaceMock() override; - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t(const bool *, uint32_t)); MOCK_METHOD0(SoftBusGetBtState, int32_t(void)); MOCK_METHOD1(SoftBusGetBtMacAddr, int32_t(SoftBusBtAddr *)); diff --git a/tests/core/bus_center/lnn/net_buscenter/lnn_network_manager_test.cpp b/tests/core/bus_center/lnn/net_buscenter/lnn_network_manager_test.cpp index 9650a984e1272f763b70c335e2a09e30963a3869..33f6c3343e715342e0c700abd561da0240cb20b0 100644 --- a/tests/core/bus_center/lnn/net_buscenter/lnn_network_manager_test.cpp +++ b/tests/core/bus_center/lnn/net_buscenter/lnn_network_manager_test.cpp @@ -636,40 +636,40 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_REGISTER_EVENT_001, TestSize.Level1) EXPECT_EQ(ret, SOFTBUS_OK); } -HWTEST_F(LNNNetworkManagerMockTest, NetRootDeviceLeaveLnnTest_001, TestSize.Level1) +HWTEST_F(LNNNetworkManagerMockTest, RiskDeviceLeaveLnnTest_001, TestSize.Level1) { int ret = 0; NiceMock managerMock; NiceMock ledgerMock; EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillOnce(Return(SOFTBUS_INVALID_PARAM)); - ret = NetRootDeviceLeaveLnn(); + ret = RiskDeviceLeaveLnn(); EXPECT_EQ(ret, SOFTBUS_NETWORK_GET_ALL_NODE_INFO_ERR); EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillOnce(Return(SOFTBUS_OK)); - ret = NetRootDeviceLeaveLnn(); + ret = RiskDeviceLeaveLnn(); EXPECT_EQ(ret, SOFTBUS_NO_ONLINE_DEVICE); } -HWTEST_F(LNNNetworkManagerMockTest, NetDeviceRootStateEventHandler_001, TestSize.Level1) +HWTEST_F(LNNNetworkManagerMockTest, NetDeviceRiskStateEventHandler_001, TestSize.Level1) { - LnnDeviceRootStateChangeEvent *event = - reinterpret_cast(SoftBusCalloc(sizeof(LnnDeviceRootStateChangeEvent))); + LnnDeviceRiskStateChangeEvent *event = + reinterpret_cast(SoftBusCalloc(sizeof(LnnDeviceRiskStateChangeEvent))); event->basic.event = LNN_EVENT_TYPE_MAX; - event->status = SOFTBUS_DEVICE_IS_ROOT; + event->status = SOFTBUS_DEVICE_IS_RISK; NiceMock managerMock; NiceMock ledgerMock; EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM)); - NetDeviceRootStateEventHandler(NULL); + NetDeviceRiskStateEventHandler(NULL); - NetDeviceRootStateEventHandler(&event->basic); + NetDeviceRiskStateEventHandler(&event->basic); - event->basic.event = LNN_EVENT_DEVICE_ROOT_STATE_CHANGED; - NetDeviceRootStateEventHandler(&event->basic); + event->basic.event = LNN_EVENT_DEVICE_RISK_STATE_CHANGED; + NetDeviceRiskStateEventHandler(&event->basic); - event->status = SOFTBUS_DEVICE_NOT_ROOT; - NetDeviceRootStateEventHandler(&event->basic); + event->status = SOFTBUS_DEVICE_NOT_RISK; + NetDeviceRiskStateEventHandler(&event->basic); EXPECT_EQ(event->status, 0); } diff --git a/tests/core/bus_center/test/heartbeat/hb_ctrl_static_test.cpp b/tests/core/bus_center/test/heartbeat/hb_ctrl_static_test.cpp index 19c6901efbd2398d65845469dc6b4574ceb942df..8fd51cb9b0f805109dab0cf4070b1e790d63fc7d 100644 --- a/tests/core/bus_center/test/heartbeat/hb_ctrl_static_test.cpp +++ b/tests/core/bus_center/test/heartbeat/hb_ctrl_static_test.cpp @@ -417,7 +417,7 @@ HWTEST_F(HeartBeatCtrlStaticTest, LNN_REGISTER_COMMON_EVENT_TEST_007, TestSize.L .WillRepeatedly(Return(SOFTBUS_OK)); EXPECT_CALL(hbStaticMock, LnnRegisterEventHandler(Eq(LNN_EVENT_SLE_STATE_CHANGED), _)) .WillRepeatedly(Return(SOFTBUS_OK)); - EXPECT_CALL(hbStaticMock, LnnRegisterEventHandler(Eq(LNN_EVENT_DEVICE_ROOT_STATE_CHANGED), _)) + EXPECT_CALL(hbStaticMock, LnnRegisterEventHandler(Eq(LNN_EVENT_DEVICE_RISK_STATE_CHANGED), _)) .WillRepeatedly(Return(SOFTBUS_INVALID_PARAM)); int32_t ret = LnnRegisterCommonEvent(); EXPECT_NE(ret, SOFTBUS_OK); diff --git a/tests/core/bus_center/test/mock/include/hb_fsm_mock.h b/tests/core/bus_center/test/mock/include/hb_fsm_mock.h index 09fd89238bf400218fb50621e601af24383e43b2..2a2d8190934a3f27bedf84929e23df72831ea11d 100644 --- a/tests/core/bus_center/test/mock/include/hb_fsm_mock.h +++ b/tests/core/bus_center/test/mock/include/hb_fsm_mock.h @@ -48,7 +48,8 @@ public: virtual int32_t LnnGetGearModeBySpecificType(GearMode *mode, char *callerId, LnnHeartbeatType type) = 0; virtual DiscoveryType LnnConvAddrTypeToDiscType(ConnectionAddrType type) = 0; virtual int32_t LnnOfflineTimingByHeartbeat(const char *networkId, ConnectionAddrType addrType) = 0; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual int32_t LnnHbMediumMgrSendBegin(LnnHeartbeatSendBeginData *custData) = 0; virtual int32_t LnnHbMediumMgrSendEnd(LnnHeartbeatSendEndData *type) = 0; virtual int32_t LnnGetHbStrategyManager( @@ -82,7 +83,7 @@ public: MOCK_METHOD3(LnnGetGearModeBySpecificType, int32_t(GearMode *, char *, LnnHeartbeatType)); MOCK_METHOD1(LnnConvAddrTypeToDiscType, DiscoveryType(ConnectionAddrType)); MOCK_METHOD2(LnnOfflineTimingByHeartbeat, int32_t(const char *, ConnectionAddrType)); - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD1(LnnHbMediumMgrSendBegin, int32_t(LnnHeartbeatSendBeginData *)); MOCK_METHOD1(LnnHbMediumMgrSendEnd, int32_t(LnnHeartbeatSendEndData *)); MOCK_METHOD3( diff --git a/tests/core/bus_center/test/mock/include/hb_strategy_mock.h b/tests/core/bus_center/test/mock/include/hb_strategy_mock.h index d63dbd7d16139fd8bc2f5f508a5253d854276e4f..9f6d8c000f2a50fb238d103bdf5bbb9d396a5405 100644 --- a/tests/core/bus_center/test/mock/include/hb_strategy_mock.h +++ b/tests/core/bus_center/test/mock/include/hb_strategy_mock.h @@ -39,7 +39,8 @@ public: virtual int32_t LnnNotifyMasterElect(const char *networkId, const char *masterUdid, int32_t masterWeight) = 0; virtual int32_t LnnStartHbByTypeAndStrategy( LnnHeartbeatType hbType, LnnHeartbeatStrategyType strategyType, bool isRelay) = 0; - virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; + virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, + DeviceLeaveReason leaveReason) = 0; virtual AuthVerifyCallback *LnnGetReAuthVerifyCallback(void) = 0; virtual int32_t LnnSetGearModeBySpecificType(const char *callerId, const GearMode *mode, LnnHeartbeatType type) = 0; virtual int32_t LnnEnableHeartbeatByType(LnnHeartbeatType type, bool isEnable) = 0; @@ -84,7 +85,7 @@ public: MOCK_METHOD3(LnnNotifyMasterElect, int32_t(const char *, const char *, int32_t)); MOCK_METHOD1(LnnSetHbAsMasterNodeState, int32_t(bool)); MOCK_METHOD3(LnnStartHbByTypeAndStrategy, int32_t(LnnHeartbeatType, LnnHeartbeatStrategyType, bool)); - MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType)); + MOCK_METHOD3(LnnRequestLeaveSpecific, int32_t(const char *, ConnectionAddrType, DeviceLeaveReason)); MOCK_METHOD0(LnnGetReAuthVerifyCallback, AuthVerifyCallback *(void)); MOCK_METHOD3(LnnSetGearModeBySpecificType, int32_t(const char *, const GearMode *, LnnHeartbeatType)); MOCK_METHOD2(LnnEnableHeartbeatByType, int32_t(LnnHeartbeatType, bool)); diff --git a/tests/core/bus_center/test/mock/src/hb_fsm_mock.cpp b/tests/core/bus_center/test/mock/src/hb_fsm_mock.cpp index 6f97ed972cc9ae3b53a5cfab9e022e14a5d1334a..78575375389c4b6f3d51713a22c14ecfe113ea61 100644 --- a/tests/core/bus_center/test/mock/src/hb_fsm_mock.cpp +++ b/tests/core/bus_center/test/mock/src/hb_fsm_mock.cpp @@ -108,9 +108,9 @@ int32_t LnnOfflineTimingByHeartbeat(const char *networkId, ConnectionAddrType ad return HeartBeatFSMInterfaceInstance()->LnnOfflineTimingByHeartbeat(networkId, addrType); } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return HeartBeatFSMInterfaceInstance()->LnnRequestLeaveSpecific(networkId, addrType); + return HeartBeatFSMInterfaceInstance()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } int32_t LnnHbMediumMgrSendBegin(LnnHeartbeatSendBeginData *custData) diff --git a/tests/core/bus_center/test/mock/src/hb_strategy_mock.cpp b/tests/core/bus_center/test/mock/src/hb_strategy_mock.cpp index 3f55d56d48b53337c943943c814f81aedeec283f..d5ca11944cddfc23e019625d80e36a7ca716119a 100644 --- a/tests/core/bus_center/test/mock/src/hb_strategy_mock.cpp +++ b/tests/core/bus_center/test/mock/src/hb_strategy_mock.cpp @@ -68,9 +68,9 @@ int32_t LnnStartHbByTypeAndStrategy(LnnHeartbeatType hbType, LnnHeartbeatStrateg return HeartBeatStrategyInterface()->LnnStartHbByTypeAndStrategy(hbType, strategyType, isRelay); } -int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) +int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType, DeviceLeaveReason leaveReason) { - return HeartBeatStrategyInterface()->LnnRequestLeaveSpecific(networkId, addrType); + return HeartBeatStrategyInterface()->LnnRequestLeaveSpecific(networkId, addrType, leaveReason); } AuthVerifyCallback *LnnGetReAuthVerifyCallback(void)