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;