diff --git a/radar/include/dm_radar_helper.h b/radar/include/dm_radar_helper.h index 1bfb18159c614c960a8e574a1cededc4404a4557..1ab665ba914959c3b11469af32b03468ae12e2d0 100644 --- a/radar/include/dm_radar_helper.h +++ b/radar/include/dm_radar_helper.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -245,6 +246,8 @@ public: private: std::string GetAnonyUdid(std::string udid); int32_t GetApiType(); + std::string localCallerName_; + std::mutex lock_; }; extern "C" IDmRadarHelper *CreateDmRadarInstance(); diff --git a/radar/src/dm_radar_helper.cpp b/radar/src/dm_radar_helper.cpp index c62a930cb20b391f21a91383cdabdc1226bc9ba7..7c8f66f807b667b78ab13deda2a72287f8ee081a 100644 --- a/radar/src/dm_radar_helper.cpp +++ b/radar/src/dm_radar_helper.cpp @@ -1251,9 +1251,15 @@ void DmRadarHelper::ReportGetLocalDevInfo(std::string hostName, std::string funcName, DmDeviceInfo &info, int32_t errCode, std::string localUdid) { int32_t res = DM_OK; - static std::string localCallerName = ""; - if (localCallerName != hostName) { - localCallerName = hostName; + bool compare = false; + { + std::lock_guard autoLock(lock_); + if (localCallerName_ != hostName) { + compare = true; + localCallerName_ = hostName; + } + } + if (compare) { if (errCode == DM_OK) { res = ReportGetLocalDevInfoResultSucc(hostName, funcName, info, errCode, localUdid); } else {