From 259f0183efdd5b0f80c49c8dd043f5d8cbcbe8fa Mon Sep 17 00:00:00 2001 From: zhonglufu Date: Wed, 6 Mar 2024 15:33:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?dcamera=E6=95=8F=E6=84=9F=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhonglufu --- .../src/utils/dcamera_hisysevent_adapter.cpp | 3 +- .../channel/src/dcamera_softbus_session.cpp | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/common/src/utils/dcamera_hisysevent_adapter.cpp b/common/src/utils/dcamera_hisysevent_adapter.cpp index 260f0a65..9fa83934 100644 --- a/common/src/utils/dcamera_hisysevent_adapter.cpp +++ b/common/src/utils/dcamera_hisysevent_adapter.cpp @@ -18,6 +18,7 @@ #include "hisysevent.h" #include "securec.h" +#include "anonymous_string.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" @@ -57,7 +58,7 @@ void ReportRegisterCameraFail(const std::string& eventName, const std::string& d "VERSION", version, "MSG", errMsg); if (ret != DCAMERA_OK) { - DHLOGE("Write HiSysEvent error ret %d, devId %s, dhId %s, errMsg %s.", ret, devId.c_str(), + DHLOGE("Write HiSysEvent error ret %d, devId %s, dhId %s, errMsg %s.", ret, GetAnonyString(devId).c_str(), dhId.c_str(), errMsg.c_str()); } } diff --git a/services/channel/src/dcamera_softbus_session.cpp b/services/channel/src/dcamera_softbus_session.cpp index b6257e2e..7bb9853d 100644 --- a/services/channel/src/dcamera_softbus_session.cpp +++ b/services/channel/src/dcamera_softbus_session.cpp @@ -135,7 +135,8 @@ void DCameraSoftbusSession::PackRecvData(std::shared_ptr& buffer) if (buffer->Size() != (headerPara.dataLen + BINARY_HEADER_FRAG_LEN) || headerPara.dataLen > headerPara.totalLen || headerPara.dataLen > BINARY_DATA_MAX_LEN || headerPara.totalLen > BINARY_DATA_MAX_TOTAL_LEN) { DHLOGE("pack recv data failed, size: %d, dataLen: %d, totalLen: %d sess: %s peerSess: %s", - buffer->Size(), headerPara.dataLen, headerPara.totalLen, mySessionName_.c_str(), peerSessionName_.c_str()); + buffer->Size(), headerPara.dataLen, headerPara.totalLen, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return; } DHLOGD("pack recv data Assemble, size: %d, dataLen: %d, totalLen: %d, nowTime: %lld start", @@ -153,7 +154,8 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, { if (headerPara.dataLen != headerPara.totalLen) { DHLOGE("DCameraSoftbusSession PackRecvData failed, dataLen: %d, totalLen: %d, sess: %s peerSess: %s", - headerPara.dataLen, headerPara.totalLen, mySessionName_.c_str(), peerSessionName_.c_str()); + headerPara.dataLen, headerPara.totalLen, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return; } std::shared_ptr postData = std::make_shared(headerPara.dataLen); @@ -161,7 +163,7 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession PackRecvData failed, ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return; } PostData(postData); @@ -180,7 +182,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); ResetAssembleFrag(); return; } @@ -199,7 +201,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Data() + BINARY_HEADER_FRAG_LEN, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, memcpy_s ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); ResetAssembleFrag(); return; } @@ -216,26 +218,28 @@ int32_t DCameraSoftbusSession::CheckUnPackBuffer(SessionDataHeader& headerPara) { if (!isWaiting_) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, not start one, sess: %s peerSess: %s", - mySessionName_.c_str(), peerSessionName_.c_str()); + GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (nowSeq_ != headerPara.seqNum) { DHLOGE("DCameraSoftbusSession AssembleFrag seq error nowSeq: %d actualSeq: %d, sess: %s peerSess: %s", - nowSeq_, headerPara.seqNum, mySessionName_.c_str(), peerSessionName_.c_str()); + nowSeq_, headerPara.seqNum, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (nowSubSeq_ + 1 != headerPara.subSeq) { DHLOGE("DCameraSoftbusSession AssembleFrag subSeq error nowSeq: %d actualSeq: %d, sess: %s peerSess: %s", - nowSubSeq_, headerPara.subSeq, mySessionName_.c_str(), peerSessionName_.c_str()); + nowSubSeq_, headerPara.subSeq, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } if (totalLen_ < headerPara.dataLen + offset_) { DHLOGE("DCameraSoftbusSession AssembleFrag len error cap: %d size: %d, dataLen: %d sess: %s peerSess: %s", - totalLen_, offset_, headerPara.dataLen, mySessionName_.c_str(), - peerSessionName_.c_str()); + totalLen_, offset_, headerPara.dataLen, GetAnonyString(mySessionName_).c_str(), + GetAnonyString(peerSessionName_).c_str()); return DCAMERA_BAD_VALUE; } return DCAMERA_OK; @@ -309,7 +313,7 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe buffer->Data(), buffer->Size()); if (ret != EOK) { DHLOGE("DCameraSoftbusSession UnPackSendData START_END memcpy_s failed, ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } return (this->*memberFunc)(unpackData); @@ -327,13 +331,13 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe buffer->Data() + offset, headPara.dataLen); if (ret != EOK) { DHLOGE("DCameraSoftbusSession UnPackSendData memcpy_s failed, ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } ret = (this->*memberFunc)(unpackData); if (ret != DCAMERA_OK) { DHLOGE("DCameraSoftbusSession sendData failed, ret: %d, sess: %s peerSess: %s", - ret, mySessionName_.c_str(), peerSessionName_.c_str()); + ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); return ret; } DHLOGD("DCameraSoftbusSession UnPackSendData, size: %d, dataLen: %d, totalLen: %d, nowTime: %lld end:", -- Gitee From 3268cf4e677fcd438f98cf83c569dbb36321c44b Mon Sep 17 00:00:00 2001 From: zhonglufu Date: Wed, 6 Mar 2024 16:33:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?dcamera=E6=95=8F=E6=84=9F=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhonglufu --- .../channel/src/dcamera_softbus_session.cpp | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/services/channel/src/dcamera_softbus_session.cpp b/services/channel/src/dcamera_softbus_session.cpp index 7bb9853d..c7499277 100644 --- a/services/channel/src/dcamera_softbus_session.cpp +++ b/services/channel/src/dcamera_softbus_session.cpp @@ -135,8 +135,7 @@ void DCameraSoftbusSession::PackRecvData(std::shared_ptr& buffer) if (buffer->Size() != (headerPara.dataLen + BINARY_HEADER_FRAG_LEN) || headerPara.dataLen > headerPara.totalLen || headerPara.dataLen > BINARY_DATA_MAX_LEN || headerPara.totalLen > BINARY_DATA_MAX_TOTAL_LEN) { DHLOGE("pack recv data failed, size: %d, dataLen: %d, totalLen: %d sess: %s peerSess: %s", - buffer->Size(), headerPara.dataLen, headerPara.totalLen, GetAnonyString(mySessionName_).c_str(), - GetAnonyString(peerSessionName_).c_str()); + buffer->Size(), headerPara.dataLen, headerPara.totalLen, mySessionName_.c_str(), peerSessionName_.c_str()); return; } DHLOGD("pack recv data Assemble, size: %d, dataLen: %d, totalLen: %d, nowTime: %lld start", @@ -154,8 +153,7 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, { if (headerPara.dataLen != headerPara.totalLen) { DHLOGE("DCameraSoftbusSession PackRecvData failed, dataLen: %d, totalLen: %d, sess: %s peerSess: %s", - headerPara.dataLen, headerPara.totalLen, GetAnonyString(mySessionName_).c_str(), - GetAnonyString(peerSessionName_).c_str()); + headerPara.dataLen, headerPara.totalLen, mySessionName_.c_str(), peerSessionName_.c_str()); return; } std::shared_ptr postData = std::make_shared(headerPara.dataLen); @@ -163,7 +161,7 @@ void DCameraSoftbusSession::AssembleNoFrag(std::shared_ptr& buffer, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession PackRecvData failed, ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); return; } PostData(postData); @@ -182,7 +180,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); ResetAssembleFrag(); return; } @@ -201,7 +199,7 @@ void DCameraSoftbusSession::AssembleFrag(std::shared_ptr& buffer, Se buffer->Data() + BINARY_HEADER_FRAG_LEN, buffer->Size() - BINARY_HEADER_FRAG_LEN); if (ret != EOK) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, memcpy_s ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); ResetAssembleFrag(); return; } @@ -218,28 +216,25 @@ int32_t DCameraSoftbusSession::CheckUnPackBuffer(SessionDataHeader& headerPara) { if (!isWaiting_) { DHLOGE("DCameraSoftbusSession AssembleFrag failed, not start one, sess: %s peerSess: %s", - GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + mySessionName_.c_str(), peerSessionName_.c_str()); return DCAMERA_BAD_VALUE; } if (nowSeq_ != headerPara.seqNum) { DHLOGE("DCameraSoftbusSession AssembleFrag seq error nowSeq: %d actualSeq: %d, sess: %s peerSess: %s", - nowSeq_, headerPara.seqNum, GetAnonyString(mySessionName_).c_str(), - GetAnonyString(peerSessionName_).c_str()); + nowSeq_, headerPara.seqNum, mySessionName_.c_str(), peerSessionName_.c_str()); return DCAMERA_BAD_VALUE; } if (nowSubSeq_ + 1 != headerPara.subSeq) { DHLOGE("DCameraSoftbusSession AssembleFrag subSeq error nowSeq: %d actualSeq: %d, sess: %s peerSess: %s", - nowSubSeq_, headerPara.subSeq, GetAnonyString(mySessionName_).c_str(), - GetAnonyString(peerSessionName_).c_str()); + nowSubSeq_, headerPara.subSeq, mySessionName_.c_str(), peerSessionName_.c_str()); return DCAMERA_BAD_VALUE; } if (totalLen_ < headerPara.dataLen + offset_) { DHLOGE("DCameraSoftbusSession AssembleFrag len error cap: %d size: %d, dataLen: %d sess: %s peerSess: %s", - totalLen_, offset_, headerPara.dataLen, GetAnonyString(mySessionName_).c_str(), - GetAnonyString(peerSessionName_).c_str()); + totalLen_, offset_, headerPara.dataLen, mySessionName_.c_str(), peerSessionName_.c_str()); return DCAMERA_BAD_VALUE; } return DCAMERA_OK; @@ -313,7 +308,7 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe buffer->Data(), buffer->Size()); if (ret != EOK) { DHLOGE("DCameraSoftbusSession UnPackSendData START_END memcpy_s failed, ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); return ret; } return (this->*memberFunc)(unpackData); @@ -331,13 +326,13 @@ int32_t DCameraSoftbusSession::UnPackSendData(std::shared_ptr& buffe buffer->Data() + offset, headPara.dataLen); if (ret != EOK) { DHLOGE("DCameraSoftbusSession UnPackSendData memcpy_s failed, ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); return ret; } ret = (this->*memberFunc)(unpackData); if (ret != DCAMERA_OK) { DHLOGE("DCameraSoftbusSession sendData failed, ret: %d, sess: %s peerSess: %s", - ret, GetAnonyString(mySessionName_).c_str(), GetAnonyString(peerSessionName_).c_str()); + ret, mySessionName_.c_str(), peerSessionName_.c_str()); return ret; } DHLOGD("DCameraSoftbusSession UnPackSendData, size: %d, dataLen: %d, totalLen: %d, nowTime: %lld end:", -- Gitee