From 805b05aa6cbbf06334b6b219943a07f495fb9d02 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Fri, 3 Jan 2025 11:34:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8E=92=E6=9F=A5dm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84hichain=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- .../src/authentication/dm_auth_manager.cpp | 2 -- .../hichain/hichain_auth_connector.cpp | 21 ++++++++++--------- .../dependency/hichain/hichain_connector.cpp | 21 +++++++++---------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 9dc318af6..9bd9fed71 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -636,8 +636,6 @@ void DmAuthManager::ProcessSinkMsg() void DmAuthManager::OnDataReceived(const int32_t sessionId, const std::string message) { - LOGI("sessionId %{public}d, authResponseContext_->sessionId %{public}d.", sessionId, - authResponseContext_->sessionId); if (authResponseContext_ == nullptr || authMessageProcessor_ == nullptr || sessionId != authResponseContext_->sessionId) { LOGE("OnDataReceived failed, authResponseContext or authMessageProcessor_ is nullptr."); diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index 4bce015e4..09cf86e43 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -18,6 +18,7 @@ #include "dm_anonymous.h" #include "hichain_connector_callback.h" #include "parameter.h" +#include "cJSON.h" namespace OHOS { namespace DistributedHardware { @@ -165,11 +166,11 @@ int32_t HiChainAuthConnector::GenerateCredential(std::string &localUdid, int32_t char *returnData = nullptr; if (ProcessCredential(CRED_OP_CREATE, requestParam.c_str(), &returnData) != HC_SUCCESS) { LOGE("Hichain generate credential failed."); - DeleteArrayPtr(returnData); + cJSON_free(returnData); return ERR_DM_FAILED; } std::string returnDataStr = static_cast(returnData); - DeleteArrayPtr(returnData); + cJSON_free(returnData); nlohmann::json jsonObject = nlohmann::json::parse(returnDataStr, nullptr, false); if (jsonObject.is_discarded()) { LOGE("Decode generate return data jsonStr error."); @@ -200,11 +201,11 @@ bool HiChainAuthConnector::QueryCredential(std::string &localUdid, int32_t osAcc char *returnData = nullptr; if (ProcessCredential(CRED_OP_QUERY, requestParam.c_str(), &returnData) != HC_SUCCESS) { LOGE("Hichain query credential failed."); - DeleteArrayPtr(returnData); + cJSON_free(returnData); return false; } std::string returnDataStr = static_cast(returnData); - DeleteArrayPtr(returnData); + cJSON_free(returnData); nlohmann::json jsonObject = nlohmann::json::parse(returnDataStr, nullptr, false); if (jsonObject.is_discarded()) { LOGE("Decode query return data jsonStr error."); @@ -233,11 +234,11 @@ int32_t HiChainAuthConnector::GetCredential(std::string &localUdid, int32_t osAc char *returnData = nullptr; if (ProcessCredential(CRED_OP_QUERY, requestParam.c_str(), &returnData) != HC_SUCCESS) { LOGE("Hichain query credential failed."); - DeleteArrayPtr(returnData); + cJSON_free(returnData); return ERR_DM_FAILED; } std::string returnDataStr = static_cast(returnData); - DeleteArrayPtr(returnData); + cJSON_free(returnData); nlohmann::json jsonObject = nlohmann::json::parse(returnDataStr, nullptr, false); if (jsonObject.is_discarded()) { LOGE("Decode query return data jsonStr error."); @@ -267,11 +268,11 @@ int32_t HiChainAuthConnector::ImportCredential(int32_t osAccountId, std::string char *returnData = nullptr; if (ProcessCredential(CRED_OP_IMPORT, requestParam.c_str(), &returnData) != HC_SUCCESS) { LOGE("Hichain query credential failed."); - DeleteArrayPtr(returnData); + cJSON_free(returnData); return ERR_DM_FAILED; } std::string returnDataStr = static_cast(returnData); - DeleteArrayPtr(returnData); + cJSON_free(returnData); nlohmann::json jsonObject = nlohmann::json::parse(returnDataStr, nullptr, false); if (jsonObject.is_discarded()) { LOGE("Decode import return data jsonStr error."); @@ -300,11 +301,11 @@ int32_t HiChainAuthConnector::DeleteCredential(const std::string &deviceId, int3 char *returnData = nullptr; if (ProcessCredential(CRED_OP_DELETE, requestParam.c_str(), &returnData) != HC_SUCCESS) { LOGE("Hichain query credential failed."); - DeleteArrayPtr(returnData); + cJSON_free(returnData); return false; } std::string returnDataStr = static_cast(returnData); - DeleteArrayPtr(returnData); + cJSON_free(returnData); nlohmann::json jsonObject = nlohmann::json::parse(returnDataStr, nullptr, false); if (jsonObject.is_discarded()) { LOGE("Decode import return data jsonStr error."); diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index 79610f892..0da7cff77 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -243,7 +243,7 @@ bool HiChainConnector::GetGroupInfoCommon(const int32_t userId, const std::strin int32_t ret = deviceGroupManager_->getGroupInfo(userId, pkgName, queryParams.c_str(), &groupVec, &num); if (ret != 0) { LOGE("[HICHAIN]fail to get group info with ret:%{public}d.", ret); - DeleteArrayPtr(groupVec); + deviceGroupManager_->destroyInfo(&groupVec); return false; } if (groupVec == nullptr) { @@ -252,13 +252,12 @@ bool HiChainConnector::GetGroupInfoCommon(const int32_t userId, const std::strin } if (num == 0) { LOGE("[HICHAIN]return groups info number is zero."); - DeleteArrayPtr(groupVec); + deviceGroupManager_->destroyInfo(&groupVec); return false; } LOGI("HiChainConnector::GetGroupInfo groupNum(%{public}u)", num); std::string relatedGroups = std::string(groupVec); deviceGroupManager_->destroyInfo(&groupVec); - DeleteArrayPtr(groupVec); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups, nullptr, false); if (jsonObject.is_discarded()) { LOGE("returnGroups parse error"); @@ -832,13 +831,12 @@ int32_t HiChainConnector::getRegisterInfo(const std::string &queryParams, std::s char *credentialInfo = nullptr; if (deviceGroupManager_->getRegisterInfo(queryParams.c_str(), &credentialInfo) != DM_OK) { LOGE("[HICHAIN]fail to request hichain registerinfo."); - DeleteArrayPtr(credentialInfo); + deviceGroupManager_->destroyInfo(&credentialInfo); return ERR_DM_FAILED; } returnJsonStr = credentialInfo; deviceGroupManager_->destroyInfo(&credentialInfo); - DeleteArrayPtr(credentialInfo); LOGI("request hichain device registerinfo successfully."); return DM_OK; } @@ -1063,6 +1061,7 @@ std::vector HiChainConnector::GetTrustedDevices(const std::string & &devicesJson, &devNum); if (ret != 0 || devicesJson == nullptr) { LOGE("[HICHAIN]failed to get trusted devicesJson, ret: %{public}d", ret); + deviceGroupManager_->destroyInfo(&devicesJson); return {}; } GetTrustedDevicesUdid(devicesJson, trustedDevices); @@ -1125,7 +1124,7 @@ int32_t HiChainConnector::GetRelatedGroupsCommon(const std::string &deviceId, co deviceGroupManager_->getRelatedGroups(userId, pkgName, deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { LOGE("[HICHAIN] fail to get related groups with ret:%{public}d.", ret); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); return ERR_DM_FAILED; } if (returnGroups == nullptr) { @@ -1134,11 +1133,11 @@ int32_t HiChainConnector::GetRelatedGroupsCommon(const std::string &deviceId, co } if (groupNum == 0) { LOGE("[HICHAIN]return related goups number is zero."); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); return ERR_DM_FAILED; } std::string relatedGroups = std::string(returnGroups); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups, nullptr, false); if (jsonObject.is_discarded()) { LOGE("returnGroups parse error"); @@ -1189,7 +1188,7 @@ int32_t HiChainConnector::GetRelatedGroupsCommon(int32_t userId, const std::stri deviceGroupManager_->getRelatedGroups(userId, pkgName, deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { LOGE("[HICHAIN] fail to get related groups with ret:%{public}d.", ret); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); return ERR_DM_FAILED; } if (returnGroups == nullptr) { @@ -1198,11 +1197,11 @@ int32_t HiChainConnector::GetRelatedGroupsCommon(int32_t userId, const std::stri } if (groupNum == 0) { LOGE("[HICHAIN]return related goups number is zero."); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); return ERR_DM_FAILED; } std::string relatedGroups = std::string(returnGroups); - DeleteArrayPtr(returnGroups); + deviceGroupManager_->destroyInfo(&returnGroups); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups, nullptr, false); if (jsonObject.is_discarded()) { LOGE("returnGroups parse error"); -- Gitee From ee2878323fe768df8760693f9bc709d5722274cc Mon Sep 17 00:00:00 2001 From: l60055366 Date: Fri, 3 Jan 2025 14:41:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8E=92=E6=9F=A5dm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84hichain=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- services/implementation/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/implementation/BUILD.gn b/services/implementation/BUILD.gn index 2fcda9634..949270521 100644 --- a/services/implementation/BUILD.gn +++ b/services/implementation/BUILD.gn @@ -206,6 +206,7 @@ if (defined(ohos_lite)) { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", -- Gitee From 6ab3687b85b8682f448890eda6111da363c296b2 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Fri, 3 Jan 2025 16:13:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=92=E6=9F=A5dm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84hichain=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- services/implementation/src/authentication/dm_auth_manager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 9bd9fed71..1178814f0 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2406,8 +2406,6 @@ void DmAuthManager::ProcIncompatible(const int32_t &sessionId) void DmAuthManager::OnAuthDeviceDataReceived(const int32_t sessionId, const std::string message) { - LOGI("sessionId %{public}d, authResponseContext_->sessionId %{public}d.", sessionId, - authResponseContext_->sessionId); if (authResponseContext_ == nullptr || authMessageProcessor_ == nullptr || hiChainAuthConnector_ == nullptr || authResponseContext_->sessionId != sessionId) { LOGE("OnAuthDeviceDataReceived param is invalid"); -- Gitee