From 619ff2bb8a3e1d5ef3c3009dc7e9d0dabc8fda79 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Wed, 8 Jun 2022 15:43:18 +0800 Subject: [PATCH] =?UTF-8?q?codex=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinlong0101 --- common/include/dscreen_util.h | 1 + common/src/dscreen_util.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/include/dscreen_util.h b/common/include/dscreen_util.h index 8b113e5..aea2439 100644 --- a/common/include/dscreen_util.h +++ b/common/include/dscreen_util.h @@ -23,6 +23,7 @@ namespace DistributedHardware { int32_t GetLocalDeviceNetworkId(std::string &networkId); std::string GetRandomID(); std::string GetAnonyString(const std::string &value); +std::string GetInterruptString(const std::string &value); } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/common/src/dscreen_util.cpp b/common/src/dscreen_util.cpp index 129902f..bd38019 100644 --- a/common/src/dscreen_util.cpp +++ b/common/src/dscreen_util.cpp @@ -98,12 +98,13 @@ std::string GetAnonyString(const std::string &value) std::string GetInterruptString(const std::string &value) { constexpr size_t INT32_MIN_ID_LENGTH = 3; + constexpr size_t STRING_HALF_LENGTH = 2; std::string res; size_t strlen = value.length(); - if(strlen <= INT32_MIN_ID_LENGTH) { + if (strlen <= INT32_MIN_ID_LENGTH) { res = value; } else { - res = value.substr(0, strlen / 2); + res = value.substr(0, strlen / STRING_HALF_LENGTH); } return res;