From e62c292f3453e1a58a5c7fac9002790a526d43c2 Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Thu, 26 Oct 2023 20:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E6=94=B9=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 --- common/include/dscreen_log.h | 16 +++---- common/src/dscreen_hisysevent.cpp | 31 ++++---------- common/src/dscreen_log.cpp | 4 +- common/src/dscreen_util.cpp | 42 +++++++++---------- .../screen_sink/src/dscreen_sink_proxy.cpp | 12 +++--- .../callback/dscreen_source_callback_stub.cpp | 6 +-- .../src/dscreen_source_handler.cpp | 2 +- .../src/dscreen_source_proxy.cpp | 16 +++---- .../subscribelocalhardware_fuzzer.cpp | 6 +-- .../unsubscribelocalhardware_fuzzer.cpp | 6 +-- .../sinkproxydscreennotify_fuzzer.cpp | 7 ++-- .../callbackonremoterequest_fuzzer.cpp | 4 +- .../onremotesourcesvrdied_fuzzer.cpp | 7 ++-- .../registerdistributedhardware_fuzzer.cpp | 2 +- .../configdistributedhardware_fuzzer.cpp | 4 +- .../dscreennotify_fuzzer.cpp | 2 +- .../include/dscreen_source_common.h | 8 ++-- .../utils/dscreen_maprelation_test.cpp | 2 +- .../test/unittest/utils/video_param_test.cpp | 4 +- .../common/utils/src/dscreen_hidumper.cpp | 12 +++--- services/screendemo/decoder_demo.cpp | 37 +++++++--------- .../src/dscreen_sink_service.cpp | 2 +- .../1.0/src/screenregionmgr.cpp | 4 +- .../screenregionmgr/2.0/src/screenregion.cpp | 36 ++++++++-------- .../2.0/src/screenregionmgr.cpp | 31 ++++++++------ .../dscreen_source_callback_proxy.cpp | 2 +- .../src/dscreen_source_service.cpp | 8 ++-- .../unittest/src/softbus_adapter_test.cpp | 11 ++--- 28 files changed, 157 insertions(+), 167 deletions(-) diff --git a/common/include/dscreen_log.h b/common/include/dscreen_log.h index ec0e0b41..97928b57 100644 --- a/common/include/dscreen_log.h +++ b/common/include/dscreen_log.h @@ -28,17 +28,17 @@ typedef enum { void DHLog(DHLogLevel logLevel, const char *fmt, ...); -#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGD(fmt, ...) DHLog( \ + DH_LOG_DEBUG, (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGI(fmt, ...) DHLog( \ + DH_LOG_INFO, (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGW(fmt, ...) DHLog( \ + DH_LOG_WARN, (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGE(fmt, ...) DHLog( \ + DH_LOG_ERROR, (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/common/src/dscreen_hisysevent.cpp b/common/src/dscreen_hisysevent.cpp index 2d187673..ccedffe4 100644 --- a/common/src/dscreen_hisysevent.cpp +++ b/common/src/dscreen_hisysevent.cpp @@ -39,14 +39,9 @@ void ReportSaFail(const std::string &eventName, int32_t errCode, int32_t saId, c void ReportRegisterFail(const std::string &eventName, int32_t errCode, const std::string &devId, const std::string &dhId, const std::string &errMsg) { - int32_t res = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - eventName, - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "ERRCODE", errCode, - "DEVID", devId, - "DHID", dhId, - "MSG", errMsg); + int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName, + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "ERRCODE", errCode, + "DEVID", devId, "DHID", dhId, "MSG", errMsg); if (res != DH_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%" PRId32, res); } @@ -97,13 +92,9 @@ void ReportSaEvent(const std::string &eventName, int32_t saId, const std::string void ReportRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId, const std::string &errMsg) { - int32_t res = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - eventName, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "DEVID", devId, - "DHID", dhId, - "MSG", errMsg); + int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "DEVID", devId, + "DHID", dhId, "MSG", errMsg); if (res != DH_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%" PRId32, res); } @@ -112,13 +103,9 @@ void ReportRegisterScreenEvent(const std::string &eventName, const std::string & void ReportUnRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId, const std::string &errMsg) { - int32_t res = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - eventName, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "DEVID", devId, - "DHID", dhId, - "MSG", errMsg); + int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "DEVID", devId, "DHID", dhId, + "MSG", errMsg); if (res != DH_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%" PRId32, res); } diff --git a/common/src/dscreen_log.cpp b/common/src/dscreen_log.cpp index edbb85b3..7214cfb9 100644 --- a/common/src/dscreen_log.cpp +++ b/common/src/dscreen_log.cpp @@ -75,9 +75,9 @@ void DHLog(DHLogLevel logLevel, const char *fmt, ...) (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); va_start(arg, fmt); - int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); + int32_t result = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); va_end(arg); - if (ret < 0) { + if (result < 0) { DHLogOut(logLevel, "DH log length error."); return; } diff --git a/common/src/dscreen_util.cpp b/common/src/dscreen_util.cpp index 86782ea2..939db173 100644 --- a/common/src/dscreen_util.cpp +++ b/common/src/dscreen_util.cpp @@ -49,34 +49,34 @@ int32_t GetLocalDeviceNetworkId(std::string &networkId) std::string GetRandomID() { - static std::random_device rd; + static std::random_device randomDevice; static std::uniform_int_distribution dist(0ULL, 0xFFFFFFFFFFFFFFFFULL); - uint64_t ab = dist(rd); - uint64_t cd = dist(rd); + uint64_t ab = dist(randomDevice); + uint64_t cd = dist(randomDevice); uint32_t a, b, c, d; - std::stringstream ss; + std::stringstream stringStream; ab = (ab & 0xFFFFFFFFFFFF0FFFULL) | 0x0000000000004000ULL; cd = (cd & 0x3FFFFFFFFFFFFFFFULL) | 0x8000000000000000ULL; a = (ab >> 32U); b = (ab & 0xFFFFFFFFU); c = (cd >> 32U); d = (cd & 0xFFFFFFFFU); - ss << std::hex << std::nouppercase << std::setfill('0'); - ss << std::setw(WORD_WIDTH_8) << (a); - ss << std::setw(WORD_WIDTH_4) << (b >> 16U); - ss << std::setw(WORD_WIDTH_4) << (b & 0xFFFFU); - ss << std::setw(WORD_WIDTH_4) << (c >> 16U); - ss << std::setw(WORD_WIDTH_4) << (c & 0xFFFFU); - ss << std::setw(WORD_WIDTH_8) << d; - - return ss.str(); + stringStream << std::hex << std::nouppercase << std::setfill('0'); + stringStream << std::setw(WORD_WIDTH_8) << (a); + stringStream << std::setw(WORD_WIDTH_4) << (b >> 16U); + stringStream << std::setw(WORD_WIDTH_4) << (b & 0xFFFFU); + stringStream << std::setw(WORD_WIDTH_4) << (c >> 16U); + stringStream << std::setw(WORD_WIDTH_4) << (c & 0xFFFFU); + stringStream << std::setw(WORD_WIDTH_8) << d; + + return stringStream.str(); } std::string GetAnonyString(const std::string &value) { constexpr size_t INT32_SHORT_ID_LENGTH = 20; constexpr size_t INT32_MIN_ID_LENGTH = 3; - std::string res; + std::string result; std::string tmpStr("******"); size_t strLen = value.length(); if (strLen < INT32_MIN_ID_LENGTH) { @@ -84,17 +84,17 @@ std::string GetAnonyString(const std::string &value) } if (strLen <= INT32_SHORT_ID_LENGTH) { - res += value[0]; - res += tmpStr; - res += value[strLen - 1]; + result += value[0]; + result += tmpStr; + result += value[strLen - 1]; } else { constexpr size_t INT32_PLAINTEXT_LENGTH = 4; - res.append(value, 0, INT32_PLAINTEXT_LENGTH); - res += tmpStr; - res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); + result.append(value, 0, INT32_PLAINTEXT_LENGTH); + result += tmpStr; + result.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); } - return res; + return result; } std::string GetInterruptString(const std::string &value) diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp index 43e48c3b..74525576 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp @@ -35,7 +35,7 @@ int32_t DScreenSinkProxy::InitSink(const std::string ¶ms) } sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSinkProxy remote service null"); + DHLOGE("DScreenSinkProxy remote service nullptr"); return DSCREEN_BAD_VALUE; } MessageParcel data; @@ -60,7 +60,7 @@ int32_t DScreenSinkProxy::ReleaseSink() { sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSinkProxy remote service null"); + DHLOGE("DScreenSinkProxy remote service null."); return DSCREEN_BAD_VALUE; } MessageParcel data; @@ -114,14 +114,14 @@ int32_t DScreenSinkProxy::UnsubscribeLocalHardware(const std::string &dhId) } sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSinkProxy remote service null"); + DHLOGE("DScreenSinkProxy remote service nullptr."); return DSCREEN_BAD_VALUE; } MessageParcel data; MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed"); + DHLOGE("WriteInterfaceToken failed."); return ERR_DH_SCREEN_SA_WRITEINTERFACETOKEN_FAILED; } @@ -145,14 +145,14 @@ void DScreenSinkProxy::DScreenNotify(const std::string &devId, int32_t eventCode } sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSinkProxy remote service null"); + DHLOGE("DScreenSinkProxy remote service null."); return; } MessageParcel data; MessageParcel reply; MessageOption option = { MessageOption::TF_ASYNC }; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed"); + DHLOGE("WriteInterfaceToken failed."); return; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp index 28bff3d4..8d75dca8 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp @@ -62,12 +62,12 @@ int32_t DScreenSourceCallbackStub::OnNotifyRegResultInner(MessageParcel &data, M std::string dhId = data.ReadString(); std::string reqId = data.ReadString(); int32_t status = data.ReadInt32(); - std::string resultData = data.ReadString(); - if (!CheckParams(devId, dhId, reqId, resultData)) { + std::string resultDataStr = data.ReadString(); + if (!CheckParams(devId, dhId, reqId, resultDataStr)) { DHLOGE("OnNotifyRegResultInner error: Invalid parameter."); return ERR_DH_SCREEN_INPUT_PARAM_INVALID; } - int32_t ret = OnNotifyRegResult(devId, dhId, reqId, status, resultData); + int32_t ret = OnNotifyRegResult(devId, dhId, reqId, status, resultDataStr); return ret; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index 4e6cfc6c..4b14d84d 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -152,7 +152,7 @@ int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &dev GetAnonyString(dhId).c_str()); std::lock_guard lock(proxyMutex_); if (dScreenSourceProxy_ == nullptr) { - DHLOGE("screen source proxy not init."); + DHLOGE("screen source proxy not init"); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } if (dScreenSourceCallback_ == nullptr) { diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp index ea7ffd5e..d8c8b415 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp @@ -36,7 +36,7 @@ int32_t DScreenSourceProxy::InitSource(const std::string ¶ms, const sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSourceProxy remote service null"); + DHLOGE("DScreenSourceProxy remote service null."); return DSCREEN_BAD_VALUE; } @@ -44,7 +44,7 @@ int32_t DScreenSourceProxy::InitSource(const std::string ¶ms, const sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSourceProxy remote service null"); + DHLOGE("DScreenSourceProxy remote service null!"); return DSCREEN_BAD_VALUE; } @@ -96,7 +96,7 @@ int32_t DScreenSourceProxy::RegisterDistributedHardware(const std::string &devId MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed"); + DHLOGE("WriteInterfaceToken failed!"); return ERR_DH_SCREEN_SA_WRITEINTERFACETOKEN_FAILED; } @@ -120,7 +120,7 @@ int32_t DScreenSourceProxy::UnregisterDistributedHardware(const std::string &dev } sptr remote = Remote(); if (remote == nullptr) { - DHLOGE("DScreenSourceProxy remote service null"); + DHLOGE("DScreenSourceProxy remote service is null"); return DSCREEN_BAD_VALUE; } @@ -128,7 +128,7 @@ int32_t DScreenSourceProxy::UnregisterDistributedHardware(const std::string &dev MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed"); + DHLOGE("WriteInterfaceToken Failed"); return ERR_DH_SCREEN_SA_WRITEINTERFACETOKEN_FAILED; } @@ -190,7 +190,7 @@ void DScreenSourceProxy::DScreenNotify(const std::string &devId, int32_t eventCo MessageParcel reply; MessageOption option = { MessageOption::TF_ASYNC }; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed"); + DHLOGE("WriteInterfaceToken failed."); return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp index 17eff228..0beef2fe 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp @@ -35,13 +35,13 @@ void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) std::string dhId(reinterpret_cast(data), size); std::string param(reinterpret_cast(data), size); - sptr samgr = + sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + if (systemAbilityManager == nullptr) { return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); + sptr remoteObject = systemAbilityManager->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp index 7631c026..a3729f86 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp @@ -34,13 +34,13 @@ void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) std::string dhId(reinterpret_cast(data), size); - sptr samgr = + sptr saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + if (saMgr == nullptr) { return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); + sptr remoteObject = saMgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp index 557544d5..bc01ce40 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp @@ -36,13 +36,12 @@ void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) int32_t eventCode = *(reinterpret_cast(data)); std::string eventContent(reinterpret_cast(data), size); - sptr samgr = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + sptr saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saMgr == nullptr) { return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); + sptr remoteObject = saMgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp index 396cb445..77e4bb55 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp @@ -31,7 +31,7 @@ namespace OHOS { namespace DistributedHardware { void CallbackOnRemoteRequestFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size < sizeof(uint32_t))) { + if ((size < sizeof(uint32_t)) || (data == nullptr)) { return; } @@ -40,8 +40,8 @@ void CallbackOnRemoteRequestFuzzTest(const uint8_t* data, size_t size) MessageOption option; uint32_t code = *(reinterpret_cast(data)) % 2; int32_t status = *(reinterpret_cast(data)); - std::string devId(reinterpret_cast(data), size); std::string dhId(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); std::string reqId(reinterpret_cast(data), size); std::string dataStr(reinterpret_cast(data), size); pdata.WriteInt32(status); diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp index eb0cab56..5ebf93ce 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp @@ -31,13 +31,12 @@ void OnRemoteSourceSvrDiedFuzzTest(const uint8_t* data, size_t size) return; } - sptr samgr = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (systemAbilityManager == nullptr) { return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); + sptr remoteObject = systemAbilityManager->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp index a820169c..0f9d90f8 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -30,8 +30,8 @@ void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) } std::string devId(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); std::string version(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); std::string attrs(reinterpret_cast(data), size); EnableParam param; param.sinkVersion = version; diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp index a7e8f34a..ad0eb1ed 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -39,12 +39,12 @@ void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + if (!samgr) { return; } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); - if (remoteObject == nullptr) { + if (!remoteObject) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp index 85ac6c86..49f5dc9f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp @@ -28,7 +28,7 @@ namespace DistributedHardware { constexpr int32_t DISTRIBUTED_HARDWARE_DM_SA_ID = 4802; void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size < sizeof(int32_t))) { + if ((size < sizeof(int32_t)) || (data == nullptr)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h index 823afec6..54139634 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h @@ -67,8 +67,8 @@ public: RegisterCallbackTest() = default; virtual ~RegisterCallbackTest() = default; - int32_t OnRegisterResult(const std::string &uuid, const std::string &dhId, int32_t status, - const std::string &data) + int32_t OnRegisterResult(const std::string &uuid, const std::string &dhId, + int32_t status, const std::string &data) { return 0; } @@ -80,8 +80,8 @@ public: UnregisterCallbackTest() = default; virtual ~UnregisterCallbackTest() = default; - int32_t OnUnregisterResult(const std::string &uuid, const std::string &dhId, int32_t status, - const std::string &data) + int32_t OnUnregisterResult(const std::string &uuid, const std::string &dhId, + int32_t status, const std::string &data) { return 0; } diff --git a/services/common/test/unittest/utils/dscreen_maprelation_test.cpp b/services/common/test/unittest/utils/dscreen_maprelation_test.cpp index d18a89cd..888d18d5 100644 --- a/services/common/test/unittest/utils/dscreen_maprelation_test.cpp +++ b/services/common/test/unittest/utils/dscreen_maprelation_test.cpp @@ -105,8 +105,8 @@ HWTEST_F(DScreenMapRelationTest, to_json_001, TestSize.Level1) json j; uint64_t displayId = 1; uint64_t screenId = 2; - DisplayRect displayRect = {0, 0, 100, 100}; ScreenRect screenRect = {0, 0, 200, 200}; + DisplayRect displayRect = {0, 0, 100, 100}; DScreenMapRelation dScreenMapRelation; dScreenMapRelation.SetDisplayId(displayId); dScreenMapRelation.SetScreenId(screenId); diff --git a/services/common/test/unittest/utils/video_param_test.cpp b/services/common/test/unittest/utils/video_param_test.cpp index 2d15f458..dd1fe823 100644 --- a/services/common/test/unittest/utils/video_param_test.cpp +++ b/services/common/test/unittest/utils/video_param_test.cpp @@ -146,8 +146,8 @@ HWTEST_F(VideoParamTest, to_json_001, TestSize.Level1) uint32_t videoWidth = 100; uint32_t videoHeight = 100; uint32_t fps = 30; - uint8_t codecType = DEFAULT_CODECTYPE; uint8_t videoFormat = DEFAULT_VIDEO_FORMAT; + uint8_t codecType = DEFAULT_CODECTYPE; VideoParam videoParam; videoParam.SetScreenWidth(screenWidth); @@ -155,8 +155,8 @@ HWTEST_F(VideoParamTest, to_json_001, TestSize.Level1) videoParam.SetVideoWidth(videoWidth); videoParam.SetVideoHeight(videoHeight); videoParam.SetFps(fps); - videoParam.SetCodecType(codecType); videoParam.SetVideoFormat(videoFormat); + videoParam.SetCodecType(codecType); to_json(j, videoParam); uint32_t jsonVideoWidth = 0; diff --git a/services/common/utils/src/dscreen_hidumper.cpp b/services/common/utils/src/dscreen_hidumper.cpp index 12837c19..aa34dea7 100644 --- a/services/common/utils/src/dscreen_hidumper.cpp +++ b/services/common/utils/src/dscreen_hidumper.cpp @@ -62,7 +62,9 @@ bool DscreenHidumper::Dump(const std::vector &args, std::string &re if (args.empty()) { ShowHelp(result); return true; - } else if (args.size() > 1) { + } + + if (args.size() > 1) { ShowIllegalInfomation(result); return true; } @@ -73,18 +75,18 @@ bool DscreenHidumper::Dump(const std::vector &args, std::string &re int32_t DscreenHidumper::ProcessDump(const std::string &args, std::string &result) { DHLOGI("Process dump."); - HidumpFlag hf = HidumpFlag::UNKNOWN; + HidumpFlag hidumpFlag = HidumpFlag::UNKNOWN; auto operatorIter = ARGS_MAP.find(args); if (operatorIter != ARGS_MAP.end()) { - hf = operatorIter->second; + hidumpFlag = operatorIter->second; } - if (hf == HidumpFlag::GET_HELP) { + if (hidumpFlag == HidumpFlag::GET_HELP) { ShowHelp(result); return DH_SUCCESS; } result.clear(); - switch (hf) { + switch (hidumpFlag) { case HidumpFlag::DUMP_SCREEN_DATA: { return DumpScreenData(result); } diff --git a/services/screendemo/decoder_demo.cpp b/services/screendemo/decoder_demo.cpp index 12a07eb4..934b98a4 100644 --- a/services/screendemo/decoder_demo.cpp +++ b/services/screendemo/decoder_demo.cpp @@ -25,22 +25,21 @@ #include "window_option.h" static const int32_t ES_R[325] = { - 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959, - 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451, - 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317, - 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401, - 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423, - 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439, - 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268, - 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334, - 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287, - 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302, - 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259, - 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433, - 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287, - 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235, - 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228, - 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719 + 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959, 677, + 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451, 608, 431, + 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317, 355, 422, 467, + 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401, 487, 4404, 362, 378, + 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423, 369, 443, 406, 392, 4231, + 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439, 378, 355, 374, 484, 381, 373, + 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268, 315, 416, 383, 373, 381, 354, 383, + 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334, 326, 3439, 266, 324, 329, 353, 405, 303, + 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287, 367, 341, 276, 258, 3980, 246, 245, 259, 309, + 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302, 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, + 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259, 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, + 269, 242, 209, 314, 267, 278, 280, 314, 250, 433, 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, + 368, 3810, 231, 212, 279, 289, 252, 303, 287, 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, + 317, 232, 348, 4077, 259, 222, 268, 235, 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, + 273, 301, 304, 253, 266, 3978, 228, 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719 }; static const int32_t ES_W[183] = { @@ -287,11 +286,7 @@ void VDecDemo::InputFunc() void VDecDemo::OutputFunc() { - while (true) { - if (!isRunning_.load()) { - break; - } - + while (isRunning_.load()) { unique_lock lock(signal_->outMutex_); signal_->outCond_.wait(lock, [this]() { return signal_->outQueue_.size() > 0; }); diff --git a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp index 43d45bf7..a82cc4e0 100644 --- a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp +++ b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp @@ -122,7 +122,7 @@ void DScreenSinkService::DScreenNotify(const std::string &devId, int32_t eventCo int32_t DScreenSinkService::Dump(int32_t fd, const std::vector& args) { - DHLOGI("DScreenSinkService Dump."); + DHLOGI("DScreenSinkService Dump."); (void)args; std::string result_v1; V1_0::ScreenRegionManager::GetInstance().GetScreenDumpInfo(result_v1); diff --git a/services/screenservice/sinkservice/screenregionmgr/1.0/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/1.0/src/screenregionmgr.cpp index f1b65a6a..3d962643 100644 --- a/services/screenservice/sinkservice/screenregionmgr/1.0/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/1.0/src/screenregionmgr.cpp @@ -20,15 +20,15 @@ #include "iservice_registry.h" #include "nlohmann/json.hpp" -#include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_constants.h" #include "dscreen_fwkkit.h" #include "dscreen_json_util.h" #include "dscreen_log.h" #include "dscreen_maprelation.h" #include "dscreen_util.h" -#include "idscreen_source.h" #include "screen_client.h" +#include "idscreen_source.h" #include "screen_client_common.h" using json = nlohmann::json; diff --git a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp index b178fee5..5a8844d5 100644 --- a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp @@ -185,36 +185,36 @@ int32_t ScreenRegion::SetUp(const std::string &content) int32_t ScreenRegion::ConfigWindow() { DHLOGI("ConfigWindow enter"); - std::shared_ptr windowProperty = std::make_shared(); - windowProperty->displayId = displayId_; if (mapRelation_ == nullptr) { DHLOGE("mapRelation is nullptr."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } ScreenRect screenRect = mapRelation_->GetScreenRect(); - windowProperty->startX = screenRect.startX; - windowProperty->startY = screenRect.startY; - windowProperty->width = screenRect.width; - windowProperty->height = screenRect.height; + std::shared_ptr windowProperty = std::make_shared(WindowProperty { + .displayId = displayId_, + .startX = screenRect.startX, + .startY = screenRect.startY, + .width = screenRect.width, + .height = screenRect.height + }); windowProperty_ = windowProperty; - windowId_ = ScreenClient::GetInstance().AddWindow(windowProperty); if (windowId_ < 0) { - DHLOGE("AddWindow failed."); - ReportOptFail(DSCREEN_OPT_FAIL, ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, "AddWindow failed."); + DHLOGE("Add window failed."); + ReportOptFail(DSCREEN_OPT_FAIL, ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, "Add window failed."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } int32_t ret = ScreenClient::GetInstance().ShowWindow(windowId_); if (ret != DH_SUCCESS) { - DHLOGE("show window failed."); - ReportOptFail(DSCREEN_OPT_FAIL, ret, "show window failed."); + DHLOGE("Show window failed."); + ReportOptFail(DSCREEN_OPT_FAIL, ret, "Show window failed."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } sptr surface = ScreenClient::GetInstance().GetSurface(windowId_); if (surface == nullptr) { - DHLOGE("get window surface failed."); - ReportOptFail(DSCREEN_OPT_FAIL, ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, "get window surface failed."); + DHLOGE("Get window surface failed."); + ReportOptFail(DSCREEN_OPT_FAIL, ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, "Get window surface failed."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } windowSurface_ = surface; @@ -232,8 +232,8 @@ void ScreenRegion::PublishMessage(const DHTopic topic, const uint64_t &screenId, json messageJosn; std::string message; messageJosn[SOURCE_WIN_ID] = screenId; - messageJosn[SOURCE_DEV_ID] = remoteDevId; messageJosn[SINK_SHOW_WIN_ID] = windowId; + messageJosn[SOURCE_DEV_ID] = remoteDevId; messageJosn[SINK_PROJ_SHOW_WIDTH] = windowProperty->width; messageJosn[SINK_PROJ_SHOW_HEIGHT] = windowProperty->height; messageJosn[SINK_WIN_SHOW_X] = windowProperty->startX; @@ -372,14 +372,14 @@ std::string ScreenRegion::GetRemoteDevId() return remoteDevId_; } -std::shared_ptr ScreenRegion::GetVideoParam() +int32_t ScreenRegion::GetWindowId() { - return videoParam_; + return windowId_; } -int32_t ScreenRegion::GetWindowId() +std::shared_ptr ScreenRegion::GetVideoParam() { - return windowId_; + return videoParam_; } std::shared_ptr ScreenRegion::GetWindowProperty() diff --git a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp index b501f1f3..e607f2fc 100644 --- a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "display_manager.h" #include "if_system_ability_manager.h" @@ -118,37 +119,43 @@ int32_t ScreenRegionManager::DestoryDScreenRegion(const std::string &peerDevId) void ScreenRegionManager::GetScreenDumpInfo(std::string &result) { DHLOGI("GetScreenDumpInfo."); + result.clear(); result.append("screenRegion OnLine:\n[\n"); - if (screenRegions_.size() == 0) { + + if (screenRegions_.empty()) { result.append("]"); DHLOGD("no screenRegion"); return; } + std::stringstream screenInfo; + std::string localDevIdAnony = GetAnonyString(localDevId_); for (const auto &screenRegion : screenRegions_) { - result.append(" {\n"); - if (screenRegion == nullptr) { + if (!screenRegion) { continue; } uint64_t screenId = screenRegion->GetScreenId(); std::string remoteDevId = screenRegion->GetRemoteDevId(); std::shared_ptr videoParam = screenRegion->GetVideoParam(); - if (videoParam == nullptr) { + if (!videoParam) { continue; } uint32_t screenHeight = videoParam->GetScreenHeight(); uint32_t screenWidth = videoParam->GetScreenWidth(); int32_t windowId = screenRegion->GetWindowId(); - std::string screenInfo = " \"clientWindowId\" : \"" + std::to_string(windowId) + "\",\n" + - " \"remoteScreenId\" : \"" + std::to_string(screenId) + "\",\n" + - " \"localDevId\" : \"" + GetAnonyString(localDevId_) + "\",\n" + - " \"remoteDevId\" : \"" + GetAnonyString(remoteDevId) + "\",\n" + - " \"screenWidth\" : \"" + std::to_string(screenWidth) + "\",\n" + - " \"screenHeight\" : \"" + std::to_string(screenHeight) + "\"\n"; - result.append(screenInfo); + screenInfo << " {\n" + << " \"clientWindowId\" : \"" << windowId << "\",\n" + << " \"remoteScreenId\" : \"" << screenId << "\",\n" + << " \"localDevId\" : \"" << localDevIdAnony << "\",\n" + << " \"remoteDevId\" : \"" << GetAnonyString(remoteDevId) << "\",\n" + << " \"screenWidth\" : \"" << screenWidth << "\",\n" + << " \"screenHeight\" : \"" << screenHeight << "\"\n" + << " }\n"; } - result.append(" }\n]"); + + result.append(screenInfo.str()); + result.append("]"); } int32_t ScreenRegionManager::LoadAVReceiverEngineProvider() diff --git a/services/screenservice/sourceservice/dscreenservice/src/callback/dscreen_source_callback_proxy.cpp b/services/screenservice/sourceservice/dscreenservice/src/callback/dscreen_source_callback_proxy.cpp index 729d0819..4f338018 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/callback/dscreen_source_callback_proxy.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/callback/dscreen_source_callback_proxy.cpp @@ -40,7 +40,7 @@ int32_t DScreenSourceCallbackProxy::OnNotifyRegResult(const std::string &devId, MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("WriteInterfaceToken failed."); + DHLOGE("WriteInterfaceToken failed"); return ERR_DH_SCREEN_SA_WRITEINTERFACETOKEN_FAILED; } diff --git a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index deeaca7a..a381a4f6 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -184,7 +184,7 @@ void DScreenSourceService::DScreenNotify(const std::string &devId, const int32_t int32_t DScreenSourceService::Dump(int32_t fd, const std::vector& args) { - DHLOGI("DScreenSourceService Dump."); + DHLOGI("DScreenSourceService Dump."); (void)args; std::string result_v1; V1_0::DScreenManager::GetInstance().GetScreenDumpInfo(result_v1); @@ -192,7 +192,7 @@ int32_t DScreenSourceService::Dump(int32_t fd, const std::vector V2_0::DScreenManager::GetInstance().GetScreenDumpInfo(result_v2); int ret = dprintf(fd, "%s\n", (result_v1 + result_v2).c_str()); if (ret < 0) { - DHLOGE("dprintf error"); + DHLOGE("Dprintf error."); return ERR_DH_SCREEN_SA_HIDUMPER_ERROR; } std::string result; @@ -202,13 +202,13 @@ int32_t DScreenSourceService::Dump(int32_t fd, const std::vector [](const std::u16string &item) { return Str16ToStr8(item); }); if (!DscreenHidumper::GetInstance().Dump(argsStr, result)) { - DHLOGE("Hidump error"); + DHLOGE("Hidump error."); return ERR_DH_SCREEN_SA_HIDUMPER_ERROR; } ret = dprintf(fd, "%s\n", result.c_str()); if (ret < 0) { - DHLOGE("Dprintf error"); + DHLOGE("Dprintf error."); return DSCREEN_BAD_VALUE; } return ERR_OK; diff --git a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp index 61553bf4..cb4b4f54 100644 --- a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp +++ b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp @@ -30,16 +30,17 @@ void SoftbusAdapterTest::TearDownTestCase(void) {} void SoftbusAdapterTest::SetUp(void) { uint64_t tokenId; - const char *perms[2]; - perms[0] = OHOS_PERMISSION_DISTRIBUTED_SOFTBUS_CENTER; - perms[1] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC; + const char *perms[] = { + OHOS_PERMISSION_DISTRIBUTED_SOFTBUS_CENTER, + OHOS_PERMISSION_DISTRIBUTED_DATASYNC + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 2, .aclsNum = 0, - .dcaps = NULL, + .dcaps = nullptr, .perms = perms, - .acls = NULL, + .acls = nullptr, .processName = "softbus_adapter_test", .aplStr = "system_basic", }; -- Gitee