!8298 fix: add pc auth proof event report

Merge pull request !8298 from xingchu/master
This commit is contained in:
openharmony_ci 2024-11-08 12:19:54 +00:00 committed by Gitee
commit 1fd2ef2514
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 31 additions and 1 deletions

View File

@ -29,6 +29,7 @@ extern "C" {
#define GROUP_TYPE_P2P (1 << 1)
#define GROUP_TYPE_MESH (1 << 2)
#define GROUP_TYPE_COMPATIBLE (1 << 3)
#define PC_META_NODE_ERRCODE 2046820418
typedef struct {
void (*onGroupCreated)(const char *groupId, int32_t groupType);

View File

@ -201,6 +201,23 @@ void GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode, uint32_t *softbusEr
}
}
static int32_t GetDeviceSideFlag(int64_t authSeq, bool *flag)
{
if (!RequireAuthLock()) {
return SOFTBUS_LOCK_ERR;
}
AuthFsm *authFsm = GetAuthFsmByAuthSeq(authSeq);
if (authFsm == NULL) {
AUTH_LOGE(AUTH_HICHAIN, "auth fsm not found");
ReleaseAuthLock();
return SOFTBUS_AUTH_NOT_FOUND;
}
*flag = authFsm->info.isServer;
AUTH_LOGI(AUTH_HICHAIN, "find authFsm success, side=%{public}s", GetAuthSideStr(*flag));
ReleaseAuthLock();
return SOFTBUS_OK;
}
static int32_t CheckErrReturnValidity(const char *errorReturn)
{
cJSON *json = cJSON_Parse(errorReturn);
@ -267,6 +284,17 @@ static void OnError(int64_t authSeq, int operationCode, int errCode, const char
if (errCode == PC_AUTH_ERRCODE && errorReturn != NULL && CheckErrReturnValidity(errorReturn) == SOFTBUS_OK) {
NotifyAuthFailEvent(errCode, errorReturn);
}
if (errCode == PC_META_NODE_ERRCODE) {
bool flag = false;
if (errorReturn == NULL) {
AUTH_LOGE(AUTH_HICHAIN, "errorReturn is null");
}
if (GetDeviceSideFlag(authSeq, &flag) == SOFTBUS_OK && flag) {
if (errorReturn != NULL && CheckErrReturnValidity(errorReturn) == SOFTBUS_OK) {
NotifyAuthFailEvent(errCode, errorReturn);
}
}
}
(void)AuthSessionHandleAuthError(authSeq, authErrCode);
}

View File

@ -869,7 +869,8 @@ static void GetConnectOnlineReason(LnnConntionInfo *connInfo, uint32_t *connOnli
static void NotifyProofExceptionEvent(DeviceType type, int32_t reason, const char *peerDeviceType)
{
if ((reason == SOFTBUS_AUTH_HICHAIN_NO_CANDIDATE_GROUP || reason == SOFTBUS_AUTH_HICHAIN_PROOF_MISMATCH) &&
if ((reason == SOFTBUS_AUTH_HICHAIN_NO_CANDIDATE_GROUP || reason == SOFTBUS_AUTH_HICHAIN_PROOF_MISMATCH ||
reason == PC_META_NODE_ERRCODE) &&
(strncmp(peerDeviceType, PC_DEV_TYPE, strlen(PC_DEV_TYPE)) == 0)) {
LnnNotifyHichainProofException(NULL, 0, (uint16_t)type, reason);
LNN_LOGE(LNN_BUILDER, "notify hichain proof exception event, reason=%{public}d, type=%{public}hu", reason,