!6257 增加组网上线DFX打点管控

Merge pull request !6257 from xingchu/master
This commit is contained in:
openharmony_ci 2024-05-28 09:10:31 +00:00 committed by Gitee
commit d14cb21556
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 344 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include "bus_center_manager.h"
#include "lnn_heartbeat_ctrl.h"
#include "lnn_log.h"
#include "lnn_net_builder.h"
#include "ohos_account_kits.h"
#include "softbus_adapter_crypto.h"
#include "softbus_adapter_mem.h"
@ -106,6 +107,7 @@ void LnnUpdateOhosAccount(bool isNeedUpdateHeartbeat)
return;
}
ClearAuthLimitMap();
ClearLnnBleReportExtraMap();
LNN_LOGI(LNN_STATE,
"accountHash update. localAccountHash=[%{public}02X, %{public}02X], accountHash=[%{public}02X, %{public}02X]",
localAccountHash[0], localAccountHash[1], accountHash[0], accountHash[1]);

View File

@ -307,6 +307,7 @@ static void HbBtStateChangeEventHandler(const LnnEventBasicInfo *info)
LNN_LOGI(LNN_HEART_BEAT, "HB handle SOFTBUS_BLE_TURN_ON, state=%{public}d", btState);
LnnUpdateHeartbeatInfo(UPDATE_BT_STATE_OPEN_INFO);
ClearAuthLimitMap();
ClearLnnBleReportExtraMap();
HbConditionChanged(false);
if (LnnStartHbByTypeAndStrategy(HEARTBEAT_TYPE_BLE_V0, STRATEGY_HB_SEND_ADJUSTABLE_PERIOD, false) !=
SOFTBUS_OK) {
@ -332,6 +333,7 @@ static void HbBtStateChangeEventHandler(const LnnEventBasicInfo *info)
LnnUpdateHeartbeatInfo(UPDATE_BT_STATE_CLOSE_INFO);
HbConditionChanged(false);
ClearAuthLimitMap();
ClearLnnBleReportExtraMap();
break;
default:
return;

View File

@ -25,6 +25,7 @@
#include "bus_center_info_key.h"
#include "bus_center_manager.h"
#include "common_list.h"
#include "lnn_async_callback_utils.h"
#include "lnn_ble_heartbeat.h"
#include "lnn_ble_lpdevice.h"
#include "lnn_cipherkey_manager.h"
@ -50,6 +51,7 @@
#define HB_RECV_INFO_SAVE_LEN (60 * 60 * HB_TIME_FACTOR)
#define HB_REAUTH_TIME (10 * HB_TIME_FACTOR)
#define HB_DFX_DELAY_TIME (7 * HB_TIME_FACTOR)
typedef struct {
ListNode node;
DeviceInfo *device;
@ -488,6 +490,92 @@ static uint64_t GetNowTime()
return (uint64_t)times.sec * HB_TIME_FACTOR + (uint64_t)times.usec / HB_TIME_FACTOR;
}
static void CopyBleReportExtra(const LnnBleReportExtra *bleExtra, LnnEventExtra *extra)
{
if (bleExtra == NULL || extra == NULL) {
LNN_LOGE(LNN_HEART_BEAT, "invalid param");
return;
}
extra->onlineNum = bleExtra->extra.onlineNum;
extra->errcode = bleExtra->extra.errcode;
extra->lnnType = bleExtra->extra.lnnType;
extra->result = bleExtra->extra.result;
extra->localUdidHash = bleExtra->extra.localUdidHash;
extra->peerUdidHash = bleExtra->extra.peerUdidHash;
if (bleExtra->extra.peerNetworkId[0] != '\0') {
extra->peerNetworkId = bleExtra->extra.peerNetworkId;
extra->peerUdid = bleExtra->extra.peerUdid;
extra->peerBleMac = bleExtra->extra.peerBleMac;
extra->peerDeviceType = bleExtra->extra.peerDeviceType;
}
}
static void HbProcessDfxMessage(void *para)
{
if (para == NULL) {
LNN_LOGE(LNN_HEART_BEAT, "invalid para");
return;
}
LnnBleReportExtra bleExtra;
(void)memset_s(&bleExtra, sizeof(LnnBleReportExtra), 0, sizeof(LnnBleReportExtra));
if (GetNodeFromLnnBleReportExtraMap((char *)para, &bleExtra) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "get ble report node from lnnBleReportExtraMap fail");
SoftBusFree(para);
return;
}
if (bleExtra.status == BLE_REPORT_EVENT_SUCCESS || bleExtra.status == BLE_REPORT_EVENT_INIT) {
DeleteNodeFromLnnBleReportExtraMap((char *)para);
SoftBusFree(para);
return;
}
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
CopyBleReportExtra(&bleExtra, &extra);
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
LNN_LOGI(LNN_HEART_BEAT, "the device online failed within 7 seconds.");
DeleteNodeFromLnnBleReportExtraMap((char *)para);
SoftBusFree(para);
}
static int32_t HbAddAsyncProcessCallbackDelay(DeviceInfo *device)
{
if (device == NULL) {
LNN_LOGE(LNN_HEART_BEAT, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = SOFTBUS_OK;
LnnBleReportExtra bleExtra;
(void)memset_s(&bleExtra, sizeof(LnnBleReportExtra), 0, sizeof(LnnBleReportExtra));
if (device->addr[0].type == CONNECTION_ADDR_BLE) {
char *udidHash = (char *)SoftBusCalloc(SHORT_UDID_HASH_HEX_LEN + 1);
if (udidHash == NULL) {
LNN_LOGE(LNN_HEART_BEAT, "udidHash calloc fail");
return SOFTBUS_MALLOC_ERR;
}
ret = ConvertBytesToHexString(
udidHash, SHORT_UDID_HASH_HEX_LEN + 1, device->addr[0].info.ble.udidHash, SHORT_UDID_HASH_LEN);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "convert bytes to string fail");
SoftBusFree(udidHash);
return ret;
}
if (!IsExistLnnDfxNodeByUdidHash(udidHash, &bleExtra)) {
ret = LnnAsyncCallbackDelayHelper(
GetLooper(LOOP_TYPE_DEFAULT), HbProcessDfxMessage, (void *)udidHash, HB_DFX_DELAY_TIME);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "HbProcessDfxMessage failed, due to set async callback fail");
SoftBusFree(udidHash);
return ret;
}
bleExtra.status = BLE_REPORT_EVENT_INIT;
AddNodeToLnnBleReportExtraMap(udidHash, &bleExtra);
}
SoftBusFree(udidHash);
}
return SOFTBUS_OK;
}
static int32_t SoftBusNetNodeResult(DeviceInfo *device, bool isConnect)
{
char *anonyUdid = NULL;
@ -496,6 +584,10 @@ static int32_t SoftBusNetNodeResult(DeviceInfo *device, bool isConnect)
"heartbeat(HB) find device, udidHash=%{public}s, ConnectionAddrType=%{public}02X, isConnect=%{public}d",
anonyUdid, device->addr[0].type, isConnect);
AnonymizeFree(anonyUdid);
if (HbAddAsyncProcessCallbackDelay(device) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "HbAddAsyncProcessCallbackDelay fail");
}
if (LnnNotifyDiscoveryDevice(device->addr, isConnect) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "mgr recv process notify device found fail");
return SOFTBUS_ERR;

View File

@ -19,6 +19,7 @@
#include <stdint.h>
#include "auth_interface.h"
#include "lnn_event.h"
#include "lnn_sync_info_manager.h"
#include "softbus_bus_center.h"
@ -79,6 +80,11 @@ AuthVerifyCallback *LnnGetVerifyCallback(void);
AuthVerifyCallback *LnnGetReAuthVerifyCallback(void);
void SetWatchdogFlag(bool flag);
bool GetWatchdogFlag(void);
void AddNodeToLnnBleReportExtraMap(const char *udidHash, const LnnBleReportExtra *bleExtra);
int32_t GetNodeFromLnnBleReportExtraMap(const char *udidHash, LnnBleReportExtra *bleExtra);
bool IsExistLnnDfxNodeByUdidHash(const char *udidHash, LnnBleReportExtra *bleExtra);
void DeleteNodeFromLnnBleReportExtraMap(const char *udidHash);
void ClearLnnBleReportExtraMap(void);
#ifdef __cplusplus
}

View File

@ -51,7 +51,6 @@
#define DATA_SIZE 32
#define DISCOVERY_TYPE_MASK 0x7FFF
#define DEVICE_TYPE_SIZE_LEN 3
typedef enum {
STATE_AUTH_INDEX = 0,
@ -535,6 +534,91 @@ static int32_t GetPeerUdidInfo(NodeInfo *nodeInfo, char *udidData, char *peerUdi
}
return SOFTBUS_OK;
}
static int32_t FillDeviceBleReportExtra(const LnnEventExtra *extra, LnnBleReportExtra *bleExtra)
{
if (extra == NULL || bleExtra == NULL) {
LNN_LOGE(LNN_BUILDER, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
if (strcpy_s(bleExtra->extra.peerNetworkId, NETWORK_ID_BUF_LEN, extra->peerNetworkId) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerNetworkId fail");
return SOFTBUS_STRCPY_ERR;
}
if (strcpy_s(bleExtra->extra.peerUdid, UDID_BUF_LEN, extra->peerUdid) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerUdid fail");
return SOFTBUS_STRCPY_ERR;
}
if (strcpy_s(bleExtra->extra.peerUdidHash, HB_SHORT_UDID_HASH_HEX_LEN + 1, extra->peerUdidHash) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerUdidHash fail");
return SOFTBUS_STRCPY_ERR;
}
if (strcpy_s(bleExtra->extra.peerBleMac, BT_MAC_LEN, extra->peerBleMac) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerBleMac fail");
return SOFTBUS_STRCPY_ERR;
}
if (strcpy_s(bleExtra->extra.peerDeviceType, DEVICE_TYPE_SIZE_LEN + 1, extra->peerDeviceType) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerDeviceType fail");
return SOFTBUS_STRCPY_ERR;
}
return SOFTBUS_OK;
}
static void DfxAddBleReportExtra(
const LnnConntionInfo *connInfo, const LnnEventExtra *extra, LnnBleReportExtra *bleExtra)
{
if (connInfo == NULL || extra == NULL || bleExtra == NULL) {
LNN_LOGE(LNN_BUILDER, "invalid param");
return;
}
bleExtra->extra.onlineNum = extra->onlineNum;
bleExtra->extra.errcode = extra->errcode;
bleExtra->extra.lnnType = extra->lnnType;
bleExtra->extra.result = extra->result;
if (strcpy_s(bleExtra->extra.localUdidHash, HB_SHORT_UDID_HASH_HEX_LEN + 1, extra->localUdidHash) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s localUdidHash fail");
return;
}
if (strcpy_s(bleExtra->extra.peerUdidHash, HB_SHORT_UDID_HASH_HEX_LEN + 1, extra->peerUdidHash) != EOK) {
LNN_LOGE(LNN_BUILDER, "strcpy_s peerUdidHash fail");
return;
}
if (connInfo->nodeInfo == NULL) {
bleExtra->status = BLE_REPORT_EVENT_FAIL;
AddNodeToLnnBleReportExtraMap(bleExtra->extra.peerUdidHash, bleExtra);
return;
}
if (FillDeviceBleReportExtra(extra, bleExtra) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "FillDeviceBleReportExtra fail");
return;
}
bleExtra->status = BLE_REPORT_EVENT_FAIL;
AddNodeToLnnBleReportExtraMap(bleExtra->extra.peerUdidHash, bleExtra);
}
static void DfxReportOnlineEvent(LnnConntionInfo *connInfo, int32_t reason, LnnEventExtra extra)
{
if (connInfo == NULL) {
LNN_LOGE(LNN_BUILDER, "connInfo is NULL");
return;
}
if (connInfo->addr.type == CONNECTION_ADDR_BLE) {
LnnBleReportExtra bleExtra;
(void)memset_s(&bleExtra, sizeof(LnnBleReportExtra), 0, sizeof(LnnBleReportExtra));
if (IsExistLnnDfxNodeByUdidHash(extra.peerUdidHash, &bleExtra)) {
if (reason == SOFTBUS_OK) {
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
bleExtra.status = BLE_REPORT_EVENT_SUCCESS;
AddNodeToLnnBleReportExtraMap(extra.peerUdidHash, &bleExtra);
return;
} else {
DfxAddBleReportExtra(connInfo, &extra, &bleExtra);
return;
}
}
}
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
}
static void SetOnlineType(int32_t reason, NodeInfo *nodeInfo, LnnEventExtra extra)
{
@ -562,7 +646,7 @@ static void DfxRecordLnnAddOnlineNodeEnd(LnnConntionInfo *connInfo, int32_t onli
extra.localUdidHash = localUdidHash;
extra.peerUdidHash = peerUdidHash;
if (connInfo->nodeInfo == NULL) {
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
DfxReportOnlineEvent(connInfo, reason, extra);
return;
}
SetOnlineType(reason, connInfo->nodeInfo, extra);
@ -592,7 +676,7 @@ static void DfxRecordLnnAddOnlineNodeEnd(LnnConntionInfo *connInfo, int32_t onli
extra.peerUdidHash = peerUdidHash;
extra.peerBleMac = bleMacAddr;
extra.peerDeviceType = deviceType;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
DfxReportOnlineEvent(connInfo, reason, extra);
}
static void CompleteJoinLNN(LnnConnectionFsm *connFsm, const char *networkId, int32_t retCode)
@ -625,6 +709,10 @@ static void CompleteJoinLNN(LnnConnectionFsm *connFsm, const char *networkId, in
LNN_LOGE(LNN_BUILDER, "Lnn get online node fail");
isSuccessFlag = false;
}
if ((connInfo->flag & LNN_CONN_INFO_FLAG_JOIN_REQUEST) == 0 && lnnType == LNN_TYPE_BR_CONNECT_ONLINE) {
isSuccessFlag = false;
SoftBusFree(info);
}
if (isSuccessFlag) {
DfxRecordLnnAddOnlineNodeEnd(connInfo, infoNum, lnnType, retCode);
SoftBusFree(info);

View File

@ -35,12 +35,12 @@
#include "lnn_devicename_info.h"
#include "lnn_discovery_manager.h"
#include "lnn_distributed_net_ledger.h"
#include "lnn_event.h"
#include "lnn_fast_offline.h"
#include "lnn_heartbeat_utils.h"
#include "lnn_link_finder.h"
#include "lnn_local_net_ledger.h"
#include "lnn_log.h"
#include "lnn_map.h"
#include "lnn_network_id.h"
#include "lnn_network_info.h"
#include "lnn_network_manager.h"
@ -159,6 +159,10 @@ typedef struct {
static NetBuilder g_netBuilder;
static bool g_watchdogFlag = true;
static Map g_lnnDfxReportMap;
static SoftBusMutex g_lnnDfxReportMutex;
static bool g_lnnDfxReportIsInit = false;
void __attribute__((weak)) SfcSyncNodeAddrHandle(const char *networkId, int32_t code)
{
(void)networkId;
@ -2718,4 +2722,112 @@ void LnnRequestLeaveAllOnlineNodes(void)
}
}
SoftBusFree(info);
}
static bool LnnBleReportExtraMapInit(void)
{
if (SoftBusMutexInit(&g_lnnDfxReportMutex, NULL) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "lnnDfxReport mutex init fail");
return false;
}
LnnMapInit(&g_lnnDfxReportMap);
g_lnnDfxReportIsInit = true;
LNN_LOGI(LNN_BUILDER, "lnnDfxReport map init success");
return true;
}
void AddNodeToLnnBleReportExtraMap(const char *udidHash, const LnnBleReportExtra *bleExtra)
{
if (!g_lnnDfxReportIsInit || udidHash == NULL || bleExtra == NULL) {
LNN_LOGE(LNN_BUILDER, "invalid param");
return;
}
if (SoftBusMutexLock(&g_lnnDfxReportMutex) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "SoftBusMutexLock fail");
return;
}
if (LnnMapSet(&g_lnnDfxReportMap, udidHash, bleExtra, sizeof(LnnBleReportExtra)) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "LnnMapSet fail");
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
return;
}
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
}
int32_t GetNodeFromLnnBleReportExtraMap(const char *udidHash, LnnBleReportExtra *bleExtra)
{
if (!g_lnnDfxReportIsInit || udidHash == NULL || bleExtra == NULL) {
return SOFTBUS_INVALID_PARAM;
}
if (SoftBusMutexLock(&g_lnnDfxReportMutex) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "SoftBusMutexLock fail");
return SOFTBUS_LOCK_ERR;
}
LnnBleReportExtra *extra = NULL;
extra = (LnnBleReportExtra *)LnnMapGet(&g_lnnDfxReportMap, udidHash);
if (extra == NULL) {
LNN_LOGE(LNN_BUILDER, "LnnMapGet fail");
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
return SOFTBUS_NOT_FIND;
}
if (memcpy_s(bleExtra, sizeof(LnnBleReportExtra), extra, sizeof(LnnBleReportExtra)) != EOK) {
LNN_LOGE(LNN_BUILDER, "memcpy_s extra fail");
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
return SOFTBUS_MEM_ERR;
}
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
return SOFTBUS_OK;
}
bool IsExistLnnDfxNodeByUdidHash(const char *udidHash, LnnBleReportExtra *bleExtra)
{
if (udidHash == NULL || bleExtra == NULL) {
LNN_LOGE(LNN_BUILDER, "invalid param");
return false;
}
if (!g_lnnDfxReportIsInit && !LnnBleReportExtraMapInit()) {
LNN_LOGE(LNN_BUILDER, "LnnBleReportExtraMap is not init");
return false;
}
if (GetNodeFromLnnBleReportExtraMap(udidHash, bleExtra) != SOFTBUS_OK) {
return false;
}
char *anonyUdidHash = NULL;
Anonymize(udidHash, &anonyUdidHash);
LNN_LOGI(LNN_BUILDER, "device report node is exist, udidHash=%{public}s", anonyUdidHash);
AnonymizeFree(anonyUdidHash);
return true;
}
void DeleteNodeFromLnnBleReportExtraMap(const char *udidHash)
{
if (!g_lnnDfxReportIsInit || udidHash == NULL) {
LNN_LOGE(LNN_BUILDER, "invalid param");
return;
}
if (SoftBusMutexLock(&g_lnnDfxReportMutex) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "SoftBusMutexLock fail");
return;
}
int32_t ret = LnnMapErase(&g_lnnDfxReportMap, udidHash);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "delete item fail, ret=%{public}d", ret);
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
return;
}
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
}
void ClearLnnBleReportExtraMap(void)
{
if (!g_lnnDfxReportIsInit) {
return;
}
if (SoftBusMutexLock(&g_lnnDfxReportMutex) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "SoftBusMutexLock fail");
return;
}
LnnMapDelete(&g_lnnDfxReportMap);
LNN_LOGI(LNN_BUILDER, "ClearLnnBleReportExtraMap success");
(void)SoftBusMutexUnlock(&g_lnnDfxReportMutex);
}

View File

@ -27,6 +27,8 @@ extern "C" {
#endif
#define LNN_DEFAULT_PKG_NAME "MODULE_LNN"
#define DEVICE_TYPE_SIZE_LEN 3
#define HB_SHORT_UDID_HASH_HEX_LEN 16
typedef enum {
EVENT_SCENE_LNN = 1,
@ -106,6 +108,30 @@ typedef struct {
const char *calleePkg; // TO_CALL_PKG
} LnnEventExtra;
typedef struct {
int32_t result; // STAGE_RES
int32_t errcode; // ERROR_CODE
int32_t lnnType; // LNN_TYPE
int32_t onlineNum; // ONLINE_NUM
char peerBleMac[BT_MAC_LEN]; // PEER_BLE_MAC
char peerUdid[UDID_BUF_LEN]; // PEER_UDID
char peerNetworkId[NETWORK_ID_BUF_LEN]; // PEER_NET_ID
char peerDeviceType[DEVICE_TYPE_SIZE_LEN + 1]; // PEER_DEV_TYPE
char localUdidHash[HB_SHORT_UDID_HASH_HEX_LEN + 1]; // LOCAL_UDID_HASH
char peerUdidHash[HB_SHORT_UDID_HASH_HEX_LEN + 1]; // PEER_UDID_HASH
} LnnReportEventExtra;
typedef enum {
BLE_REPORT_EVENT_INIT = 1,
BLE_REPORT_EVENT_FAIL = 2,
BLE_REPORT_EVENT_SUCCESS = 3,
} ReportStatus;
typedef struct {
LnnReportEventExtra extra;
ReportStatus status;
} LnnBleReportExtra;
typedef enum {
ALARM_SCENE_LNN_RESERVED = 1,
} LnnAlarmScene;

View File

@ -416,6 +416,7 @@ ohos_unittest("LNNConnectionFsmTest") {
"$dsoftbus_root_path/core/bus_center/lnn/net_builder/src/lnn_p2p_info.c",
"$dsoftbus_root_path/core/bus_center/utils/src/lnn_async_callback_utils.c",
"$dsoftbus_root_path/core/bus_center/utils/src/lnn_connection_addr_utils.c",
"$dsoftbus_root_path/core/bus_center/utils/src/lnn_map.c",
"$dsoftbus_root_path/core/bus_center/utils/src/lnn_state_machine.c",
"$dsoftbus_root_path/tests/core/bus_center/lnn/net_builder/src/lnn_sync_info_mock.cpp",
"$dsoftbus_root_path/tests/core/bus_center/mock_common/src/distribute_net_ledger_mock.cpp",

View File

@ -21,6 +21,7 @@
#include "lnn_connection_fsm.c"
#include "lnn_connection_fsm_mock.h"
#include "lnn_devicename_info.h"
#include "lnn_map.h"
#include "lnn_net_builder.h"
#include "lnn_net_ledger_mock.h"
#include "lnn_service_mock.h"

View File

@ -27,6 +27,7 @@
#include "lnn_heartbeat_ctrl_virtual.c"
#include "lnn_heartbeat_medium_mgr.c"
#include "lnn_heartbeat_utils.h"
#include "lnn_net_builder.h"
#include "lnn_net_ledger_mock.h"
#include "lnn_parameter_utils_virtual.c"
#include "softbus_common.h"
@ -308,6 +309,7 @@ HWTEST_F(HeartBeatMediumTest, HbMediumMgrRecvProcessTest_01, TestSize.Level1)
ON_CALL(hbStrateMock, LnnStopOfflineTimingStrategy).WillByDefault(Return(SOFTBUS_OK));
ON_CALL(hbStrateMock, LnnStartOfflineTimingStrategy).WillByDefault(Return(SOFTBUS_OK));
EXPECT_CALL(hbStrateMock, IsNeedAuthLimit).WillRepeatedly(Return(false));
EXPECT_CALL(hbStrateMock, IsExistLnnDfxNodeByUdidHash).WillRepeatedly(Return(true));
int ret = HbMediumMgrRecvProcess(&device, &mediumWeight, HEARTBEAT_TYPE_BLE_V1, false, &hbResp);
EXPECT_TRUE(ret == SOFTBUS_NETWORK_NOT_CONNECTABLE);
HbFirstSaveRecvTime(&storedInfo, &device,
@ -824,6 +826,7 @@ HWTEST_F(HeartBeatMediumTest, SoftBusNetNodeResult_TEST01, TestSize.Level1)
EXPECT_CALL(heartBeatMock, LnnNotifyDiscoveryDevice)
.WillOnce(Return(SOFTBUS_ERR))
.WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(heartBeatMock, IsExistLnnDfxNodeByUdidHash).WillRepeatedly(Return(true));
int32_t ret = SoftBusNetNodeResult(&device, false);
EXPECT_TRUE(ret == SOFTBUS_ERR);
ret = SoftBusNetNodeResult(&device, false);

View File

@ -53,6 +53,7 @@ public:
void *para, uint64_t delayMillis) = 0;
virtual int32_t LnnStartHeartbeat(uint64_t delayMillis) = 0;
virtual bool IsNeedAuthLimit(const char *udidHash) = 0;
virtual bool IsExistLnnDfxNodeByUdidHash(const char *udidHash, LnnBleReportExtra *bleExtra) = 0;
virtual int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo) = 0;
};
class HeartBeatStategyInterfaceMock : public HeartBeatStategyInterface {
@ -80,6 +81,7 @@ public:
MOCK_METHOD4(LnnAsyncCallbackDelayHelper, int32_t(SoftBusLooper *, LnnAsyncCallbackFunc, void *, uint64_t));
MOCK_METHOD1(LnnStartHeartbeat, int32_t(uint64_t));
MOCK_METHOD1(IsNeedAuthLimit, bool(const char *));
MOCK_METHOD2(IsExistLnnDfxNodeByUdidHash, bool(const char *, LnnBleReportExtra *));
MOCK_METHOD2(LnnRetrieveDeviceInfo, int32_t (const char *, NodeInfo *));
};
} // namespace OHOS

View File

@ -138,6 +138,11 @@ bool IsNeedAuthLimit(const char *udidHash)
return HeartBeatStrategyInterface()->IsNeedAuthLimit(udidHash);
}
bool IsExistLnnDfxNodeByUdidHash(const char *udidHash, LnnBleReportExtra *bleExtra)
{
return HeartBeatStrategyInterface()->IsExistLnnDfxNodeByUdidHash(udidHash, bleExtra);
}
int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo)
{
return HeartBeatStrategyInterface()->LnnRetrieveDeviceInfo(udid, deviceInfo);