mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-30 04:10:59 +00:00
feat:add device online log management
Signed-off-by: weiqian <weiqian22@huawei.com>
This commit is contained in:
parent
f01fff19ac
commit
86887623bc
@ -338,34 +338,28 @@ static void ReportAuthResultEvt(AuthFsm *authFsm, int32_t result)
|
||||
authFsm->statisticData.endAuthTime = LnnUpTimeMs();
|
||||
uint64_t costTime = authFsm->statisticData.endAuthTime - authFsm->statisticData.startAuthTime;
|
||||
DfxRecordLnnAuthEnd(authFsm, costTime, result);
|
||||
AuthFailStage stage;
|
||||
if (result >= SOFTBUS_HICHAIN_MIN && result <= SOFTBUS_HICHAIN_MAX) {
|
||||
AuthFailStage stage = AUTH_STAGE_BUTT;
|
||||
|
||||
if (result == SOFTBUS_OK) {
|
||||
if (SoftBusRecordAuthResult(linkType, SOFTBUS_OK, costTime, AUTH_STAGE_BUTT) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "report static auth result fail");
|
||||
}
|
||||
return;
|
||||
} else if (result == SOFTBUS_AUTH_SYNC_DEVID_FAIL || result == SOFTBUS_AUTH_SYNC_DEVINFO_FAIL ||
|
||||
result == SOFTBUS_AUTH_UNPACK_DEVINFO_FAIL || result == SOFTBUS_AUTH_SEND_FAIL) {
|
||||
stage = AUTH_EXCHANGE_STAGE;
|
||||
} else if (result == SOFTBUS_AUTH_DEVICE_DISCONNECTED) {
|
||||
stage = AUTH_CONNECT_STAGE;
|
||||
} else if (result == SOFTBUS_AUTH_HICHAIN_PROCESS_FAIL || result == SOFTBUS_AUTH_TIMEOUT ||
|
||||
result == SOFTBUS_AUTH_HICHAIN_NOT_TRUSTED) {
|
||||
stage = AUTH_VERIFY_STAGE;
|
||||
} else if (result >= SOFTBUS_HICHAIN_MIN && result <= SOFTBUS_HICHAIN_MAX) {
|
||||
stage = AUTH_VERIFY_STAGE;
|
||||
} else {
|
||||
AUTH_LOGE(AUTH_FSM, "unsupport result=%{public}d.", result);
|
||||
return;
|
||||
}
|
||||
switch (result) {
|
||||
case SOFTBUS_OK:
|
||||
if (SoftBusRecordAuthResult(linkType, SOFTBUS_OK, costTime, AUTH_STAGE_BUTT) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "report static auth result fail");
|
||||
}
|
||||
return;
|
||||
case SOFTBUS_AUTH_SYNC_DEVID_FAIL:
|
||||
case SOFTBUS_AUTH_SYNC_DEVINFO_FAIL:
|
||||
case SOFTBUS_AUTH_UNPACK_DEVINFO_FAIL:
|
||||
case SOFTBUS_AUTH_SEND_FAIL:
|
||||
stage = AUTH_EXCHANGE_STAGE;
|
||||
break;
|
||||
case SOFTBUS_AUTH_DEVICE_DISCONNECTED:
|
||||
stage = AUTH_CONNECT_STAGE;
|
||||
break;
|
||||
case SOFTBUS_AUTH_HICHAIN_PROCESS_FAIL:
|
||||
case SOFTBUS_AUTH_TIMEOUT:
|
||||
case SOFTBUS_AUTH_HICHAIN_NOT_TRUSTED:
|
||||
stage = AUTH_VERIFY_STAGE;
|
||||
break;
|
||||
default:
|
||||
AUTH_LOGE(AUTH_FSM, "unsupport reasn=%{public}d.", result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoftBusRecordAuthResult(linkType, SOFTBUS_ERR, costTime, stage) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "report static auth result fail");
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
#define DATA_SIZE 32
|
||||
#define DISCOVERY_TYPE_MASK 0x7FFF
|
||||
#define DEVICE_TYPE_SIZE_LEN 3
|
||||
|
||||
typedef enum {
|
||||
STATE_AUTH_INDEX = 0,
|
||||
@ -405,6 +406,46 @@ static void SetLnnConnNodeInfo(
|
||||
connInfo->nodeInfo->deviceInfo.deviceUdid, connInfo->addr.type, relation[connInfo->addr.type], true);
|
||||
}
|
||||
|
||||
static void DfxRecordLnnAddOnlineNodeEnd(NodeInfo *info, int32_t onlineNum, int32_t reason)
|
||||
{
|
||||
LnnEventExtra extra = { 0 };
|
||||
LnnEventExtraInit(&extra);
|
||||
extra.onlineNum = onlineNum;
|
||||
extra.errcode = reason;
|
||||
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
|
||||
if (info == NULL) {
|
||||
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
|
||||
return;
|
||||
}
|
||||
|
||||
char netWorkId[NETWORK_ID_BUF_LEN] = { 0 };
|
||||
if (strcpy_s(netWorkId, NETWORK_ID_BUF_LEN, info->networkId) != EOK) {
|
||||
LNN_LOGE(LNN_BUILDER, "strcpy_s netWorkId fail");
|
||||
return;
|
||||
}
|
||||
char udidData[UDID_BUF_LEN] = { 0 };
|
||||
if (strcpy_s(udidData, UDID_BUF_LEN, info->deviceInfo.deviceUdid) != EOK) {
|
||||
LNN_LOGE(LNN_BUILDER, "strcpy_s udidData fail");
|
||||
return;
|
||||
}
|
||||
char bleMacAddr[MAC_LEN] = { 0 };
|
||||
if (strcpy_s(bleMacAddr, MAC_LEN, info->connectInfo.bleMacAddr) != EOK) {
|
||||
LNN_LOGE(LNN_BUILDER, "strcpy_s bleMacAddr fail");
|
||||
return;
|
||||
}
|
||||
char deviceType[DEVICE_TYPE_SIZE_LEN + 1] = { 0 };
|
||||
if (snprintf_s(deviceType, DEVICE_TYPE_SIZE_LEN + 1, DEVICE_TYPE_SIZE_LEN, "%X",
|
||||
info->deviceInfo.deviceTypeId) < 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "snprintf_s deviceType fail");
|
||||
return;
|
||||
}
|
||||
extra.peerNetworkId = netWorkId;
|
||||
extra.peerUdid = udidData;
|
||||
extra.peerBleMac = bleMacAddr;
|
||||
extra.peerDeviceType = deviceType;
|
||||
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
|
||||
}
|
||||
|
||||
static void CompleteJoinLNN(LnnConnectionFsm *connFsm, const char *networkId, int32_t retCode)
|
||||
{
|
||||
LnnConntionInfo *connInfo = &connFsm->connInfo;
|
||||
@ -425,6 +466,21 @@ static void CompleteJoinLNN(LnnConnectionFsm *connFsm, const char *networkId, in
|
||||
NotifyJoinResult(connFsm, networkId, retCode);
|
||||
AuthHandleLeaveLNN(connInfo->authHandle);
|
||||
}
|
||||
|
||||
if ((connInfo->flag & LNN_CONN_INFO_FLAG_JOIN_PASSIVE) == 0) {
|
||||
int32_t infoNum = 0;
|
||||
NodeBasicInfo *info = NULL;
|
||||
bool isSuccessFlag = true;
|
||||
if (LnnGetAllOnlineNodeInfo(&info, &infoNum) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "Lnn get online node fail");
|
||||
isSuccessFlag = false;
|
||||
}
|
||||
if (isSuccessFlag) {
|
||||
DfxRecordLnnAddOnlineNodeEnd(connInfo->nodeInfo, infoNum, retCode);
|
||||
SoftBusFree(info);
|
||||
}
|
||||
}
|
||||
|
||||
if (connInfo->nodeInfo != NULL) {
|
||||
SoftBusFree(connInfo->nodeInfo);
|
||||
connInfo->nodeInfo = NULL;
|
||||
|
@ -52,7 +52,6 @@
|
||||
#define BLE_ADV_LOST_TIME 5000
|
||||
#define LONG_TO_STRING_MAX_LEN 21
|
||||
#define LNN_COMMON_LEN_64 8
|
||||
#define DEVICE_TYPE_SIZE_LEN 3
|
||||
#define SOFTBUS_BUSCENTER_DUMP_REMOTEDEVICEINFO "remote_device_info"
|
||||
|
||||
#define RETURN_IF_GET_NODE_VALID(networkId, buf, info) \
|
||||
@ -1716,38 +1715,6 @@ static void GetNodeInfoDiscovery(NodeInfo *oldInfo, NodeInfo *info, NodeInfoAbil
|
||||
}
|
||||
}
|
||||
|
||||
static void DfxRecordLnnAddOnlineNodeEnd(NodeInfo *info, int32_t onlineNum, int32_t reason)
|
||||
{
|
||||
LnnEventExtra extra = { 0 };
|
||||
LnnEventExtraInit(&extra);
|
||||
extra.onlineNum = onlineNum;
|
||||
extra.errcode = reason;
|
||||
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
|
||||
if (info == NULL) {
|
||||
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
|
||||
return;
|
||||
}
|
||||
|
||||
char netWorkId[NETWORK_ID_BUF_LEN] = { 0 };
|
||||
if (strncpy_s(netWorkId, NETWORK_ID_BUF_LEN, info->networkId, NETWORK_ID_BUF_LEN - 1) == EOK) {
|
||||
extra.peerNetworkId = netWorkId;
|
||||
}
|
||||
char udidData[UDID_BUF_LEN] = { 0 };
|
||||
if (strncpy_s(udidData, UDID_BUF_LEN, info->deviceInfo.deviceUdid, UDID_BUF_LEN - 1) == EOK) {
|
||||
extra.peerUdid = udidData;
|
||||
}
|
||||
char bleMacAddr[MAC_LEN] = { 0 };
|
||||
if (strncpy_s(bleMacAddr, MAC_LEN, info->connectInfo.bleMacAddr, MAC_LEN - 1) == EOK) {
|
||||
extra.peerBleMac = bleMacAddr;
|
||||
}
|
||||
char deviceType[DEVICE_TYPE_SIZE_LEN + 1] = { 0 };
|
||||
if (snprintf_s(deviceType, DEVICE_TYPE_SIZE_LEN + 1, DEVICE_TYPE_SIZE_LEN, "%03X",
|
||||
info->deviceInfo.deviceTypeId) >= 0) {
|
||||
extra.peerDeviceType = deviceType;
|
||||
}
|
||||
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
|
||||
}
|
||||
|
||||
static void DfxRecordLnnSetNodeOfflineEnd(const char *udid, int32_t onlineNum, int32_t reason)
|
||||
{
|
||||
LnnEventExtra extra = { 0 };
|
||||
@ -1831,7 +1798,6 @@ ReportCategory LnnAddOnlineNode(NodeInfo *info)
|
||||
OnlinePreventBrConnection(info);
|
||||
}
|
||||
InsertToProfile(info);
|
||||
DfxRecordLnnAddOnlineNodeEnd(info, (int32_t)MapGetSize(&map->udidMap), SOFTBUS_OK);
|
||||
return REPORT_ONLINE;
|
||||
}
|
||||
if (infoAbility.isMigrateEvent) {
|
||||
|
@ -121,7 +121,6 @@ HWTEST_F(LNNDisctributedLedgerTest, LNN_ADD_ONLINE_NODE_Test_001, TestSize.Level
|
||||
(void)strncpy_s(info.networkId, NETWORK_ID_BUF_LEN, NODE1_NETWORK_ID, strlen(NODE1_NETWORK_ID));
|
||||
(void)strncpy_s(info.connectInfo.macAddr, MAC_LEN, NODE1_BT_MAC, strlen(NODE1_BT_MAC));
|
||||
EXPECT_TRUE(REPORT_NONE == LnnAddOnlineNode(&info));
|
||||
DfxRecordLnnAddOnlineNodeEnd(&info, 1, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user