From b4a32d42af5b3cf9108cb329c677642d0d0ebade Mon Sep 17 00:00:00 2001 From: libo429 Date: Thu, 7 Aug 2025 22:53:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E7=BA=BF=E4=B8=8A=E6=8A=A5=E4=B8=8A?= =?UTF-8?q?=E7=BA=BF=E3=80=81=E4=B8=8B=E7=BA=BF=E3=80=81=E7=BB=84=E7=BD=91?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=94=B9=E5=8F=98=E3=80=81=E5=B1=8F=E5=B9=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=94=B9=E5=8F=98=E7=AD=89=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=97=B6=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: libo429 --- .../devicestate/dm_device_state_manager.h | 8 +- .../src/device_manager_service_impl.cpp | 51 +++-- .../src/device_manager_service_impl_lite.cpp | 12 +- .../devicestate/dm_device_state_manager.cpp | 34 ++- .../include/softbus/softbus_listener.h | 21 ++ .../service/src/device_manager_service.cpp | 9 +- .../service/src/softbus/softbus_listener.cpp | 204 +++++++++++++----- .../UTTest_dm_device_state_manager_two.cpp | 8 +- ...Test_device_manager_service_impl_first.cpp | 12 +- .../mock/dm_device_state_manager_mock.cpp | 5 +- .../mock/dm_device_state_manager_mock.h | 6 +- .../src/jsonstr_handle/dm_jsonstr_handle.cpp | 10 +- 12 files changed, 248 insertions(+), 132 deletions(-) diff --git a/services/implementation/include/devicestate/dm_device_state_manager.h b/services/implementation/include/devicestate/dm_device_state_manager.h index 254024269..a7ea1c6a4 100644 --- a/services/implementation/include/devicestate/dm_device_state_manager.h +++ b/services/implementation/include/devicestate/dm_device_state_manager.h @@ -86,7 +86,8 @@ public: int32_t ProcNotifyEvent(const int32_t eventId, const std::string &deviceId); void SaveOnlineDeviceInfo(const DmDeviceInfo &info); void DeleteOfflineDeviceInfo(const DmDeviceInfo &info); - void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo); + void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo, + std::vector &processInfoVec); void OnDbReady(const std::string &pkgName, const std::string &uuid); void RegisterOffLineTimer(const DmDeviceInfo &deviceInfo); void StartOffLineTimer(const DmDeviceInfo &deviceInfo); @@ -98,7 +99,7 @@ public: std::string GetUdidByNetWorkId(std::string networkId); bool CheckIsOnline(const std::string &udid); void DeleteOffLineTimer(std::string udidHash); - void HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo); + void HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo, std::vector &processInfos); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) int32_t DeleteSkCredAndAcl(const std::vector &acls); #endif @@ -113,7 +114,8 @@ private: int32_t DeleteGroupByDP(const std::string &deviceId); void DeleteCredential(DmOfflineParam offlineParam, const std::string &deviceId); #endif - void ProcessDeviceStateChange(const DmDeviceState devState, const DmDeviceInfo &devInfo); + void ProcessDeviceStateChange(const DmDeviceState devState, const DmDeviceInfo &devInfo, + std::vector &processInfoVec); private: std::mutex timerMapMutex_; std::mutex remoteDeviceInfosMutex_; diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 25b29563f..ec8fc1518 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -686,31 +686,31 @@ void DeviceManagerServiceImpl::HandleOffline(DmDeviceState devState, DmDeviceInf if (userIdAndBindLevel.empty() || userIdAndBindLevel.find(processInfo.userId) == userIdAndBindLevel.end()) { userIdAndBindLevel[processInfo.userId] = INVALIED_TYPE; } + std::vector processInfoVec; for (const auto &item : userIdAndBindLevel) { if (static_cast(item.second) == INVALIED_TYPE) { LOGI("The offline device is identical account bind type."); devInfo.authForm = DmAuthForm::IDENTICAL_ACCOUNT; processInfo.userId = item.first; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (static_cast(item.second) == USER && bindType == SHARE_TYPE) { LOGI("The offline device is device bind level and share bind type."); devInfo.authForm = DmAuthForm::SHARE; processInfo.userId = item.first; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (static_cast(item.second) == USER && bindType != SHARE_TYPE) { LOGI("The offline device is device bind type."); devInfo.authForm = DmAuthForm::PEER_TO_PEER; processInfo.userId = item.first; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (static_cast(item.second) == SERVICE || static_cast(item.second) == APP) { LOGI("The offline device is PEER_TO_PEER_TYPE bind type, %{public}" PRIu32, item.second); - auto processInfoVec = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId( + processInfoVec = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId( requestDeviceId, trustDeviceId, item.first); std::set processInfoSet(processInfoVec.begin(), processInfoVec.end()); processInfoVec.assign(processInfoSet.begin(), processInfoSet.end()); - softbusConnector_->SetProcessInfoVec(processInfoVec); } - deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo); + deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo, processInfoVec); } } @@ -741,30 +741,27 @@ void DeviceManagerServiceImpl::HandleOnline(DmDeviceState devState, DmDeviceInfo void DeviceManagerServiceImpl::SetOnlineProcessInfo(const uint32_t &bindType, ProcessInfo &processInfo, DmDeviceInfo &devInfo, const std::string &requestDeviceId, const std::string &trustDeviceId, DmDeviceState devState) { + std::vector processInfoVec; if (bindType == IDENTICAL_ACCOUNT_TYPE) { devInfo.authForm = DmAuthForm::IDENTICAL_ACCOUNT; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (bindType == DEVICE_PEER_TO_PEER_TYPE) { devInfo.authForm = DmAuthForm::PEER_TO_PEER; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (bindType == DEVICE_ACROSS_ACCOUNT_TYPE) { devInfo.authForm = DmAuthForm::ACROSS_ACCOUNT; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (bindType == APP_PEER_TO_PEER_TYPE || bindType == SERVICE_PEER_TO_PEER_TYPE) { - std::vector processInfoVec = - DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, trustDeviceId, - MultipleUserConnector::GetFirstForegroundUserId()); + processInfoVec = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, + trustDeviceId, MultipleUserConnector::GetFirstForegroundUserId()); std::set processInfoSet(processInfoVec.begin(), processInfoVec.end()); processInfoVec.assign(processInfoSet.begin(), processInfoSet.end()); - softbusConnector_->SetProcessInfoVec(processInfoVec); devInfo.authForm = DmAuthForm::PEER_TO_PEER; } else if (bindType == APP_ACROSS_ACCOUNT_TYPE || bindType == SERVICE_ACROSS_ACCOUNT_TYPE) { - std::vector processInfoVec = - DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, trustDeviceId, - MultipleUserConnector::GetFirstForegroundUserId()); + processInfoVec = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, + trustDeviceId, MultipleUserConnector::GetFirstForegroundUserId()); std::set processInfoSet(processInfoVec.begin(), processInfoVec.end()); processInfoVec.assign(processInfoSet.begin(), processInfoSet.end()); - softbusConnector_->SetProcessInfoVec(processInfoVec); devInfo.authForm = DmAuthForm::ACROSS_ACCOUNT; } else if (bindType == SHARE_TYPE) { if (CheckSharePeerSrc(trustDeviceId, requestDeviceId)) { @@ -772,10 +769,10 @@ void DeviceManagerServiceImpl::SetOnlineProcessInfo(const uint32_t &bindType, Pr return; } devInfo.authForm = DmAuthForm::SHARE; - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } LOGI("HandleOnline success devInfo authForm is %{public}d.", devInfo.authForm); - deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo); + deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo, processInfoVec); return; } @@ -819,8 +816,9 @@ void DeviceManagerServiceImpl::HandleDeviceStatusChange(DmDeviceState devState, ProcessInfo processInfo; processInfo.pkgName = std::string(DM_PKG_NAME); processInfo.userId = MultipleUserConnector::GetFirstForegroundUserId(); - softbusConnector_->SetChangeProcessInfo(processInfo); - deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo); + std::vector processInfoVec; + processInfoVec.push_back(processInfo); + deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo, processInfoVec); } } @@ -2313,6 +2311,7 @@ void DeviceManagerServiceImpl::HandleDeviceScreenStatusChange(DmDeviceInfo &devI std::string requestDeviceId = static_cast(localUdid); uint32_t bindType = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId); LOGI("bind type is %{public}d.", bindType); + std::vector processInfoVec; if (bindType == INVALIED_TYPE) { return; } else if (bindType == IDENTICAL_ACCOUNT_TYPE || bindType == DEVICE_PEER_TO_PEER_TYPE || @@ -2320,14 +2319,12 @@ void DeviceManagerServiceImpl::HandleDeviceScreenStatusChange(DmDeviceInfo &devI ProcessInfo processInfo; processInfo.pkgName = std::string(DM_PKG_NAME); processInfo.userId = MultipleUserConnector::GetFirstForegroundUserId(); - softbusConnector_->SetProcessInfo(processInfo); + processInfoVec.push_back(processInfo); } else if (bindType == APP_PEER_TO_PEER_TYPE || bindType == APP_ACROSS_ACCOUNT_TYPE) { - std::vector processInfoVec = - DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, trustDeviceId, - MultipleUserConnector::GetFirstForegroundUserId()); - softbusConnector_->SetProcessInfoVec(processInfoVec); + processInfoVec = DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(requestDeviceId, + trustDeviceId, MultipleUserConnector::GetFirstForegroundUserId()); } - deviceStateMgr_->HandleDeviceScreenStatusChange(devInfo); + deviceStateMgr_->HandleDeviceScreenStatusChange(devInfo, processInfoVec); } int32_t DeviceManagerServiceImpl::SyncLocalAclListProcess(const DevUserInfo &localDevUserInfo, diff --git a/services/implementation/src/device_manager_service_impl_lite.cpp b/services/implementation/src/device_manager_service_impl_lite.cpp index 445f2b070..9ba5f9ca1 100644 --- a/services/implementation/src/device_manager_service_impl_lite.cpp +++ b/services/implementation/src/device_manager_service_impl_lite.cpp @@ -111,8 +111,8 @@ int32_t DeviceManagerServiceImpl::SetUserOperation(std::string &pkgName, int32_t void DeviceManagerServiceImpl::HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) { - if (deviceStateMgr_ == nullptr) { - LOGE("deviceStateMgr_ is nullpter!"); + if (deviceStateMgr_ == nullptr || softbusConnector_ == nullptr) { + LOGE("deviceStateMgr_ or softbusConnector_ is nullpter!"); return; } std::string deviceId = GetUdidHashByNetworkId(devInfo.networkId); @@ -120,7 +120,13 @@ void DeviceManagerServiceImpl::HandleDeviceStatusChange(DmDeviceState devState, LOGE("get deviceId: %{public}s failed", GetAnonyString(deviceId).c_str()); return; } - deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo); + std::vector processInfoVec; + if (devState == DEVICE_INFO_CHANGED) { + processInfoVec = softbusConnector_->GetChangeProcessInfo(); + } else { + processInfoVec = softbusConnector_->GetProcessInfo(); + } + deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo, processInfoVec); return; } diff --git a/services/implementation/src/devicestate/dm_device_state_manager.cpp b/services/implementation/src/devicestate/dm_device_state_manager.cpp index 573c67757..e77e579b7 100644 --- a/services/implementation/src/devicestate/dm_device_state_manager.cpp +++ b/services/implementation/src/devicestate/dm_device_state_manager.cpp @@ -115,7 +115,8 @@ void DmDeviceStateManager::OnDeviceOnline(std::string deviceId, int32_t authForm stateDeviceInfos_[deviceId] = devInfo; } } - ProcessDeviceStateChange(DEVICE_STATE_ONLINE, devInfo); + std::vector processInfoVec = softbusConnector_->GetProcessInfo(); + ProcessDeviceStateChange(DEVICE_STATE_ONLINE, devInfo, processInfoVec); softbusConnector_->ClearProcessInfo(); } @@ -131,11 +132,13 @@ void DmDeviceStateManager::OnDeviceOffline(std::string deviceId) } devInfo = stateDeviceInfos_[deviceId]; } - ProcessDeviceStateChange(DEVICE_STATE_OFFLINE, devInfo); + std::vector processInfoVec = softbusConnector_->GetProcessInfo(); + ProcessDeviceStateChange(DEVICE_STATE_OFFLINE, devInfo, processInfoVec); softbusConnector_->ClearProcessInfo(); } -void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) +void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo, + std::vector &processInfoVec) { LOGI("Handle device status change: devState=%{public}d, deviceId=%{public}s.", devState, GetAnonyString(devInfo.deviceId).c_str()); @@ -144,8 +147,7 @@ void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDe RegisterOffLineTimer(devInfo); SaveOnlineDeviceInfo(devInfo); DmDistributedHardwareLoad::GetInstance().LoadDistributedHardwareFwk(); - ProcessDeviceStateChange(devState, devInfo); - softbusConnector_->ClearProcessInfo(); + ProcessDeviceStateChange(devState, devInfo, processInfoVec); break; case DEVICE_STATE_OFFLINE: StartOffLineTimer(devInfo); @@ -155,13 +157,11 @@ void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDe softbusConnector_->GetUdidByNetworkId(devInfo.networkId, udid); softbusConnector_->EraseUdidFromMap(udid); } - ProcessDeviceStateChange(devState, devInfo); - softbusConnector_->ClearProcessInfo(); + ProcessDeviceStateChange(devState, devInfo, processInfoVec); break; case DEVICE_INFO_CHANGED: ChangeDeviceInfo(devInfo); - ProcessDeviceStateChange(devState, devInfo); - softbusConnector_->ClearChangeProcessInfo(); + ProcessDeviceStateChange(devState, devInfo, processInfoVec); break; default: LOGE("HandleDeviceStatusChange error, unknown device state = %{public}d", devState); @@ -169,18 +169,12 @@ void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDe } } -void DmDeviceStateManager::ProcessDeviceStateChange(const DmDeviceState devState, const DmDeviceInfo &devInfo) +void DmDeviceStateManager::ProcessDeviceStateChange(const DmDeviceState devState, const DmDeviceInfo &devInfo, + std::vector &processInfoVec) { LOGI("begin, devState = %{public}d networkId: %{public}s.", devState, GetAnonyString(devInfo.networkId).c_str()); - CHECK_NULL_VOID(softbusConnector_); CHECK_NULL_VOID(listener_); - std::vector processInfoVec; - if (devState == DEVICE_INFO_CHANGED) { - processInfoVec = softbusConnector_->GetChangeProcessInfo(); - } else { - processInfoVec = softbusConnector_->GetProcessInfo(); - } for (const auto &item : processInfoVec) { if (!item.pkgName.empty()) { LOGI("ProcessDeviceStateChange, pkgName = %{public}s", item.pkgName.c_str()); @@ -563,12 +557,10 @@ bool DmDeviceStateManager::CheckIsOnline(const std::string &udid) return false; } -void DmDeviceStateManager::HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo) +void DmDeviceStateManager::HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo, + std::vector &processInfos) { - CHECK_NULL_VOID(softbusConnector_); CHECK_NULL_VOID(listener_); - std::vector processInfos = softbusConnector_->GetProcessInfo(); - softbusConnector_->ClearProcessInfo(); LOGI("pkgName size: %{public}zu", processInfos.size()); for (const auto &item : processInfos) { listener_->OnDeviceScreenStateChange(item, devInfo); diff --git a/services/service/include/softbus/softbus_listener.h b/services/service/include/softbus/softbus_listener.h index cc50ac399..0559fa581 100644 --- a/services/service/include/softbus/softbus_listener.h +++ b/services/service/include/softbus/softbus_listener.h @@ -24,9 +24,11 @@ #include #include #include +#include #include "cJSON.h" #include "softbus_bus_center.h" +#include "dm_device_info.h" #include "dm_publish_info.h" #include "dm_radar_helper.h" #include "i_softbus_discovering_callback.h" @@ -37,6 +39,20 @@ namespace OHOS { namespace DistributedHardware { + +typedef enum DmSoftbusEventType { + EVENT_TYPE_UNKNOWN = 0, + EVENT_TYPE_ONLINE = 1, + EVENT_TYPE_OFFLINE = 2, + EVENT_TYPE_CHANGED = 3, + EVENT_TYPE_SCREEN = 4, +} DmSoftbusEventType; + +typedef struct DmSoftbusEvent { + DmDeviceInfo dmDeviceInfo; + DmSoftbusEventType eventType; +} DmSoftbusEvent; + class SoftbusListener { public: SoftbusListener(); @@ -132,6 +148,11 @@ public: std::vector &deviceList); int32_t GetUdidFromDp(const std::string &udidHash, std::string &udid); static void GetActionId(const std::string &deviceId, int32_t &actionId); +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + static bool SaveDeviceIdHash(DmDeviceInfo &deviceInfo); + static void SoftbusEventQueueHandle(std::string deviceId); + static int32_t SoftbusEventQueueAdd(DmSoftbusEvent &dmSoftbusEventInfo); +#endif private: static int32_t FillDeviceInfo(const DeviceInfo &device, DmDeviceInfo &dmDevice); static void ParseConnAddrInfo(const ConnectionAddr *addrInfo, JsonObject &jsonObj); diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index a1333d81e..36cb066f9 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -997,10 +997,7 @@ int32_t DeviceManagerService::UnBindDeviceParseExtra(const std::string &pkgName, return ERR_DM_FAILED; } auto proxyInfo = proxyInfoSet.begin(); - uint64_t peerTokenId = 0; - std::string peerBundleName = ""; - JsonStrHandle::GetInstance().GetPeerAppInfoParseExtra(proxyInfo->second, peerTokenId, peerBundleName); - if (peerBundleName == "") { + if (proxyInfo->second == "") { result = UnBindDevice(proxyInfo->first, udidHash); } else { result = UnBindDevice(proxyInfo->first, udidHash, proxyInfo->second); @@ -3289,8 +3286,8 @@ bool DeviceManagerService::ParseRelationShipChangeType(const RelationShipChangeM case RelationShipChangeType::APP_UNBIND: if (relationShipMsg.peerTokenId != 0) { dmServiceImpl_->HandleAppUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid, - static_cast(relationShipMsg.tokenId), - static_cast(relationShipMsg.peerTokenId)); + static_cast(relationShipMsg.peerTokenId), + static_cast(relationShipMsg.tokenId)); } else { dmServiceImpl_->HandleAppUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid, static_cast(relationShipMsg.tokenId)); diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index 92f01c34a..e9f54bf43 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -25,7 +25,6 @@ #include "device_manager_service.h" #include "dm_crypto.h" #include "dm_constants.h" -#include "dm_device_info.h" #include "dm_log.h" #include "dm_softbus_cache.h" #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) @@ -90,6 +89,8 @@ void* SoftbusListener::radarHandle_ = nullptr; static std::mutex g_hostNameMutex; std::string SoftbusListener::hostName_ = ""; int32_t g_onlineDeviceNum = 0; +static std::map> g_dmSoftbusEventQueueMap; +static std::mutex g_dmSoftbusEventQueueLock; static int OnSessionOpened(int sessionId, int result) { @@ -236,6 +237,105 @@ void SoftbusListener::OnCredentialAuthStatus(const char *deviceList, uint32_t de #endif } +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +bool SoftbusListener::SaveDeviceIdHash(DmDeviceInfo &deviceInfo) +{ + std::string udid = ""; + if (deviceInfo.networkId[0] == '\0') { + LOGE("networkId is empty."); + return false; + } + GetUdidByNetworkId(deviceInfo.networkId, udid); + if (udid.empty()) { + LOGE("udid is empty."); + return false; + } + char udidHash[DM_MAX_DEVICE_ID_LEN] = {0}; + if (Crypto::GetUdidHash(udid, reinterpret_cast(udidHash)) != DM_OK) { + LOGE("get udidhash by udid: %{public}s failed.", GetAnonyString(udid).c_str()); + return false; + } + if (memcpy_s(deviceInfo.deviceId, sizeof(deviceInfo.deviceId), udidHash, + std::min(sizeof(deviceInfo.deviceId), sizeof(udidHash))) != DM_OK) { + LOGE("SaveDeviceInfo copy deviceId failed."); + return false; + } + return true; +} + +void SoftbusListener::SoftbusEventQueueHandle(std::string deviceId) +{ + std::queue eventQueue; + { + std::lock_guard lock(g_dmSoftbusEventQueueLock); + auto it = g_dmSoftbusEventQueueMap.find(deviceId); + if (it == g_dmSoftbusEventQueueMap.end()) { + return; + } + if (g_dmSoftbusEventQueueMap[deviceId].empty()) { + g_dmSoftbusEventQueueMap.erase(it); + LOGI("queue empty, deviceIdHash:%{public}s.", GetAnonyString(deviceId).c_str()); + return; + } + g_dmSoftbusEventQueueMap[deviceId].swap(eventQueue); + } + while (!eventQueue.empty()) { + DmSoftbusEvent dmSoftbusEventInfo = eventQueue.front(); + eventQueue.pop(); + LOGI("eventType:%{public}d, deviceIdHash:%{public}s.", dmSoftbusEventInfo.eventType, + GetAnonyString(deviceId).c_str()); + if (dmSoftbusEventInfo.eventType == EVENT_TYPE_ONLINE) { + DeviceOnLine(dmSoftbusEventInfo.dmDeviceInfo); + } else if (dmSoftbusEventInfo.eventType == EVENT_TYPE_OFFLINE) { + DeviceOffLine(dmSoftbusEventInfo.dmDeviceInfo); + } else if (dmSoftbusEventInfo.eventType == EVENT_TYPE_CHANGED) { + DeviceNameChange(dmSoftbusEventInfo.dmDeviceInfo); + } else if (dmSoftbusEventInfo.eventType == EVENT_TYPE_SCREEN) { + DeviceScreenStatusChange(dmSoftbusEventInfo.dmDeviceInfo); + } else { + LOGI("unknown eventType, deviceIdHash:%{public}s.", GetAnonyString(deviceId).c_str()); + } + } + { + std::lock_guard lock(g_dmSoftbusEventQueueLock); + auto it = g_dmSoftbusEventQueueMap.find(deviceId); + if (it == g_dmSoftbusEventQueueMap.end()) { + return; + } + if (g_dmSoftbusEventQueueMap[deviceId].empty()) { + g_dmSoftbusEventQueueMap.erase(it); + LOGI("queue empty, deviceIdHash:%{public}s.", GetAnonyString(deviceId).c_str()); + return; + } else { + ffrt::submit([=]() { SoftbusEventQueueHandle(deviceId); }); + } + } +} + +int32_t SoftbusListener::SoftbusEventQueueAdd(DmSoftbusEvent &dmSoftbusEventInfo) +{ + if (!SaveDeviceIdHash(dmSoftbusEventInfo.dmDeviceInfo)) { + LOGE("get device Id fail."); + return ERR_DM_FAILED; + } + std::string deviceId(dmSoftbusEventInfo.dmDeviceInfo.deviceId); + LOGI("deviceIdHash:%{public}s.", GetAnonyString(deviceId).c_str()); + { + std::lock_guard lock(g_dmSoftbusEventQueueLock); + auto it = g_dmSoftbusEventQueueMap.find(deviceId); + if (it == g_dmSoftbusEventQueueMap.end()) { + std::queue eventQueue; + eventQueue.push(dmSoftbusEventInfo); + g_dmSoftbusEventQueueMap[deviceId] = eventQueue; + ffrt::submit([=]() { SoftbusEventQueueHandle(deviceId); }); + } else { + g_dmSoftbusEventQueueMap[deviceId].push(dmSoftbusEventInfo); + } + } + return DM_OK; +} +#endif + void SoftbusListener::OnDeviceScreenStatusChanged(NodeStatusType type, NodeStatus *status) { if (status == nullptr) { @@ -248,51 +348,53 @@ void SoftbusListener::OnDeviceScreenStatusChanged(NodeStatusType type, NodeStatu LOGE("type is not matching."); return; } - DmDeviceInfo dmDeviceInfo; + DmSoftbusEvent dmSoftbusEventInfo; + dmSoftbusEventInfo.eventType = EVENT_TYPE_SCREEN; int32_t devScreenStatus = static_cast(status->reserved[0]); - ConvertScreenStatusToDmDevice(status->basicInfo, devScreenStatus, dmDeviceInfo); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - ffrt::submit([=]() { DeviceScreenStatusChange(dmDeviceInfo); }); - #else - std::thread devScreenStatusChange([=]() { DeviceScreenStatusChange(dmDeviceInfo); }); - if (pthread_setname_np(devScreenStatusChange.native_handle(), DEVICE_SCREEN_STATUS_CHANGE) != DM_OK) { - LOGE("devScreenStatusChange setname failed."); - } - devScreenStatusChange.detach(); - #endif + ConvertScreenStatusToDmDevice(status->basicInfo, devScreenStatus, dmSoftbusEventInfo.dmDeviceInfo); +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + SoftbusEventQueueAdd(dmSoftbusEventInfo); +#else + std::thread devScreenStatusChange([=]() { DeviceScreenStatusChange(dmSoftbusEventInfo.dmDeviceInfo); }); + if (pthread_setname_np(devScreenStatusChange.native_handle(), DEVICE_SCREEN_STATUS_CHANGE) != DM_OK) { + LOGE("devScreenStatusChange setname failed."); + } + devScreenStatusChange.detach(); +#endif } void SoftbusListener::OnSoftbusDeviceOnline(NodeBasicInfo *info) { LOGI("received device online callback from softbus."); - if (info == nullptr) { - LOGE("NodeBasicInfo is nullptr."); - return; - } - DmDeviceInfo dmDeviceInfo; - ConvertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); - LOGI("device online networkId: %{public}s.", GetAnonyString(dmDeviceInfo.networkId).c_str()); - SoftbusCache::GetInstance().SaveDeviceInfo(dmDeviceInfo); - SoftbusCache::GetInstance().SaveDeviceSecurityLevel(dmDeviceInfo.networkId); + CHECK_NULL_VOID(info); + DmSoftbusEvent dmSoftbusEventInfo; + dmSoftbusEventInfo.eventType = EVENT_TYPE_ONLINE; + ConvertNodeBasicInfoToDmDevice(*info, dmSoftbusEventInfo.dmDeviceInfo); + LOGI("device online networkId: %{public}s.", GetAnonyString(dmSoftbusEventInfo.dmDeviceInfo.networkId).c_str()); + SoftbusCache::GetInstance().SaveDeviceInfo(dmSoftbusEventInfo.dmDeviceInfo); + SoftbusCache::GetInstance().SaveDeviceSecurityLevel(dmSoftbusEventInfo.dmDeviceInfo.networkId); SoftbusCache::GetInstance().SaveLocalDeviceInfo(); UpdateDeviceName(info); { std::lock_guard lock(g_onlineDeviceNumLock); g_onlineDeviceNum++; } + std::string peerUdid; + GetUdidByNetworkId(info->networkId, peerUdid); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - ffrt::submit([=]() { DeviceOnLine(dmDeviceInfo); }); ffrt::submit([=]() { DeviceManagerService::GetInstance().StartDetectDeviceRisk(); }); + if (SoftbusEventQueueAdd(dmSoftbusEventInfo) != DM_OK) { + return; + } + PutOstypeData(peerUdid, info->osType); #else - std::thread deviceOnLine([=]() { DeviceOnLine(dmDeviceInfo); }); + std::thread deviceOnLine([=]() { DeviceOnLine(dmSoftbusEventInfo.dmDeviceInfo); }); int32_t ret = pthread_setname_np(deviceOnLine.native_handle(), DEVICE_ONLINE); if (ret != DM_OK) { LOGE("deviceOnLine setname failed."); } deviceOnLine.detach(); #endif - std::string peerUdid; - GetUdidByNetworkId(info->networkId, peerUdid); { struct RadarInfo radarInfo = { .funcName = "OnSoftbusDeviceOnline", @@ -308,22 +410,17 @@ void SoftbusListener::OnSoftbusDeviceOnline(NodeBasicInfo *info) } } } -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - PutOstypeData(peerUdid, info->osType); -#endif } void SoftbusListener::OnSoftbusDeviceOffline(NodeBasicInfo *info) { LOGI("received device offline callback from softbus."); - if (info == nullptr) { - LOGE("NodeBasicInfo is nullptr."); - return; - } - DmDeviceInfo dmDeviceInfo; - ConvertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); - SoftbusCache::GetInstance().DeleteDeviceInfo(dmDeviceInfo); - SoftbusCache::GetInstance().DeleteDeviceSecurityLevel(dmDeviceInfo.networkId); + CHECK_NULL_VOID(info); + DmSoftbusEvent dmSoftbusEventInfo; + dmSoftbusEventInfo.eventType = EVENT_TYPE_OFFLINE; + ConvertNodeBasicInfoToDmDevice(*info, dmSoftbusEventInfo.dmDeviceInfo); + SoftbusCache::GetInstance().DeleteDeviceInfo(dmSoftbusEventInfo.dmDeviceInfo); + SoftbusCache::GetInstance().DeleteDeviceSecurityLevel(dmSoftbusEventInfo.dmDeviceInfo.networkId); { std::lock_guard lock(g_onlineDeviceNumLock); g_onlineDeviceNum--; @@ -331,19 +428,24 @@ void SoftbusListener::OnSoftbusDeviceOffline(NodeBasicInfo *info) SoftbusCache::GetInstance().DeleteLocalDeviceInfo(); } } - LOGI("device offline networkId: %{public}s.", GetAnonyString(dmDeviceInfo.networkId).c_str()); + LOGI("device offline networkId: %{public}s.", GetAnonyString(dmSoftbusEventInfo.dmDeviceInfo.networkId).c_str()); + std::string peerUdid; + GetUdidByNetworkId(info->networkId, peerUdid); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - ffrt::submit([=]() { DeviceOffLine(dmDeviceInfo); }); + if (SoftbusEventQueueAdd(dmSoftbusEventInfo) != DM_OK) { + return; + } + if (!CheckPeerUdidTrusted(peerUdid)) { + KVAdapterManager::GetInstance().DeleteOstypeData(peerUdid); + } #else - std::thread deviceOffLine([=]() { DeviceOffLine(dmDeviceInfo); }); + std::thread deviceOffLine([=]() { DeviceOffLine(dmSoftbusEventInfo.dmDeviceInfo); }); int32_t ret = pthread_setname_np(deviceOffLine.native_handle(), DEVICE_OFFLINE); if (ret != DM_OK) { LOGE("deviceOffLine setname failed."); } deviceOffLine.detach(); #endif - std::string peerUdid; - GetUdidByNetworkId(info->networkId, peerUdid); { struct RadarInfo radarInfo = { .funcName = "OnSoftbusDeviceOffline", @@ -358,11 +460,6 @@ void SoftbusListener::OnSoftbusDeviceOffline(NodeBasicInfo *info) } } } -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - if (!CheckPeerUdidTrusted(peerUdid)) { - KVAdapterManager::GetInstance().DeleteOstypeData(peerUdid); - } -#endif } void SoftbusListener::UpdateDeviceName(NodeBasicInfo *info) @@ -390,7 +487,6 @@ void SoftbusListener::OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBas return; } if (type == NodeBasicInfoType::TYPE_DEVICE_NAME || type == NodeBasicInfoType::TYPE_NETWORK_INFO) { - DmDeviceInfo dmDeviceInfo; int32_t networkType = -1; if (type == NodeBasicInfoType::TYPE_NETWORK_INFO) { if (GetNodeKeyInfo(DM_PKG_NAME, info->networkId, NodeDeviceInfoKey::NODE_KEY_NETWORK_TYPE, @@ -403,14 +499,16 @@ void SoftbusListener::OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBas if (type == NodeBasicInfoType::TYPE_DEVICE_NAME) { UpdateDeviceName(info); } - ConvertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); - LOGI("device changed networkId: %{public}s.", GetAnonyString(dmDeviceInfo.networkId).c_str()); - dmDeviceInfo.networkType = networkType; - SoftbusCache::GetInstance().ChangeDeviceInfo(dmDeviceInfo); + DmSoftbusEvent dmSoftbusEventInfo; + dmSoftbusEventInfo.eventType = EVENT_TYPE_CHANGED; + ConvertNodeBasicInfoToDmDevice(*info, dmSoftbusEventInfo.dmDeviceInfo); + LOGI("networkId: %{public}s.", GetAnonyString(dmSoftbusEventInfo.dmDeviceInfo.networkId).c_str()); + dmSoftbusEventInfo.dmDeviceInfo.networkType = networkType; + SoftbusCache::GetInstance().ChangeDeviceInfo(dmSoftbusEventInfo.dmDeviceInfo); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - ffrt::submit([=]() { DeviceNameChange(dmDeviceInfo); }); + SoftbusEventQueueAdd(dmSoftbusEventInfo); #else - std::thread deviceInfoChange([=]() { DeviceNameChange(dmDeviceInfo); }); + std::thread deviceInfoChange([=]() { DeviceNameChange(dmSoftbusEventInfo.dmDeviceInfo); }); if (pthread_setname_np(deviceInfoChange.native_handle(), DEVICE_NAME_CHANGE) != DM_OK) { LOGE("DeviceNameChange setname failed."); } diff --git a/test/commonunittest/UTTest_dm_device_state_manager_two.cpp b/test/commonunittest/UTTest_dm_device_state_manager_two.cpp index 0755e6a4b..237427daa 100644 --- a/test/commonunittest/UTTest_dm_device_state_manager_two.cpp +++ b/test/commonunittest/UTTest_dm_device_state_manager_two.cpp @@ -127,12 +127,13 @@ HWTEST_F(DmDeviceStateManagerTestTwo, HandleDeviceStatusChange_001, testing::ext .deviceName = "asda", .deviceTypeId = 1, }; + std::vector processInfoVec; auto softbusConnector = dmDeviceStateManager->softbusConnector_; dmDeviceStateManager->softbusConnector_ = nullptr; - dmDeviceStateManager->HandleDeviceStatusChange(DmDeviceState::DEVICE_STATE_OFFLINE, info); + dmDeviceStateManager->HandleDeviceStatusChange(DmDeviceState::DEVICE_STATE_OFFLINE, info, processInfoVec); dmDeviceStateManager->softbusConnector_ = softbusConnector; EXPECT_CALL(*softbusConnectorMock_, GetUdidByNetworkId(_, _)).WillOnce(Return(ERR_DM_FAILED)); - dmDeviceStateManager->HandleDeviceStatusChange(DmDeviceState::DEVICE_STATE_OFFLINE, info); + dmDeviceStateManager->HandleDeviceStatusChange(DmDeviceState::DEVICE_STATE_OFFLINE, info, processInfoVec); EXPECT_NE(dmDeviceStateManager->softbusConnector_, nullptr); } @@ -142,8 +143,7 @@ HWTEST_F(DmDeviceStateManagerTestTwo, ProcessDeviceStateChange_001, testing::ext DmDeviceInfo devInfo; std::vector processInfoVec; processInfoVec.push_back(info); - EXPECT_CALL(*softbusConnectorMock_, GetProcessInfo()).WillOnce(Return(processInfoVec)); - dmDeviceStateManager->ProcessDeviceStateChange(DmDeviceState::DEVICE_STATE_OFFLINE, devInfo); + dmDeviceStateManager->ProcessDeviceStateChange(DmDeviceState::DEVICE_STATE_OFFLINE, devInfo, processInfoVec); EXPECT_NE(dmDeviceStateManager->softbusConnector_, nullptr); } diff --git a/test/unittest/UTTest_device_manager_service_impl_first.cpp b/test/unittest/UTTest_device_manager_service_impl_first.cpp index d778f7436..29df3a5a8 100644 --- a/test/unittest/UTTest_device_manager_service_impl_first.cpp +++ b/test/unittest/UTTest_device_manager_service_impl_first.cpp @@ -462,7 +462,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_001, testing::e DmDeviceState devState = DEVICE_STATE_ONLINE; EXPECT_CALL(*softbusConnectorMock_, SetProcessInfo(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); @@ -480,7 +480,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_002, testing::e DmDeviceState devState = DEVICE_STATE_ONLINE; EXPECT_CALL(*softbusConnectorMock_, SetProcessInfo(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); @@ -498,7 +498,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_003, testing::e DmDeviceState devState = DEVICE_STATE_ONLINE; EXPECT_CALL(*softbusConnectorMock_, SetProcessInfo(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); @@ -519,7 +519,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_004, testing::e EXPECT_CALL(*deviceProfileConnectorMock_, GetProcessInfoFromAclByUserId(_, _, _)) .WillOnce(Return(processInfoVec)); EXPECT_CALL(*softbusConnectorMock_, SetProcessInfoVec(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); @@ -540,7 +540,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_005, testing::e EXPECT_CALL(*deviceProfileConnectorMock_, GetProcessInfoFromAclByUserId(_, _, _)) .WillOnce(Return(processInfoVec)); EXPECT_CALL(*softbusConnectorMock_, SetProcessInfoVec(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); @@ -562,7 +562,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_006, testing::e EXPECT_CALL(*deviceManagerServiceImplMock_, CheckSharePeerSrc(_, _)).WillOnce(Return(false)); EXPECT_CALL(*softbusConnectorMock_, SetProcessInfo(_)).Times(1); - EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _)).Times(1); + EXPECT_CALL(*dmDeviceStateManagerMock_, HandleDeviceStatusChange(_, _, _)).Times(1); deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); diff --git a/test/unittest/mock/dm_device_state_manager_mock.cpp b/test/unittest/mock/dm_device_state_manager_mock.cpp index 0f8fa194d..0949fb195 100644 --- a/test/unittest/mock/dm_device_state_manager_mock.cpp +++ b/test/unittest/mock/dm_device_state_manager_mock.cpp @@ -29,9 +29,10 @@ int32_t DmDeviceStateManager::ProcNotifyEvent(const int32_t eventId, const std:: { return DmDmDeviceStateManager::dmDeviceStateManager->ProcNotifyEvent(eventId, deviceId); } -void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) +void DmDeviceStateManager::HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo, + std::vector &processInfoVec) { - DmDmDeviceStateManager::dmDeviceStateManager->HandleDeviceStatusChange(devState, devInfo); + DmDmDeviceStateManager::dmDeviceStateManager->HandleDeviceStatusChange(devState, devInfo, processInfoVec); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/mock/dm_device_state_manager_mock.h b/test/unittest/mock/dm_device_state_manager_mock.h index 98c5ab207..e92b04d8f 100644 --- a/test/unittest/mock/dm_device_state_manager_mock.h +++ b/test/unittest/mock/dm_device_state_manager_mock.h @@ -28,7 +28,8 @@ public: public: virtual std::string GetUdidByNetWorkId(std::string networkId) = 0; virtual int32_t ProcNotifyEvent(const int32_t eventId, const std::string &deviceId) = 0; - virtual void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) = 0; + virtual void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo, + std::vector &processInfoVec) = 0; public: static inline std::shared_ptr dmDeviceStateManager = nullptr; }; @@ -37,7 +38,8 @@ class DmDeviceStateManagerMock : public DmDmDeviceStateManager { public: MOCK_METHOD(std::string, GetUdidByNetWorkId, (std::string)); MOCK_METHOD(int32_t, ProcNotifyEvent, (const int32_t, const std::string &)); - MOCK_METHOD(void, HandleDeviceStatusChange, (DmDeviceState devState, DmDeviceInfo &devInfo)); + MOCK_METHOD(void, HandleDeviceStatusChange, (DmDeviceState devState, DmDeviceInfo &devInfo, + std::vector &processInfoVec)); }; } } diff --git a/utils/src/jsonstr_handle/dm_jsonstr_handle.cpp b/utils/src/jsonstr_handle/dm_jsonstr_handle.cpp index c4c33da76..a2945c7bc 100644 --- a/utils/src/jsonstr_handle/dm_jsonstr_handle.cpp +++ b/utils/src/jsonstr_handle/dm_jsonstr_handle.cpp @@ -36,12 +36,12 @@ DM_EXPORT void JsonStrHandle::GetPeerAppInfoParseExtra(const std::string &extra, LOGE("ParseExtra extraInfoJson error"); return; } - if (!IsString(extraInfoJson, TAG_PEER_BUNDLE_NAME) || !IsUint64(extraInfoJson, TAG_PEER_TOKENID)) { - LOGE("ParseExtra TAG_PEER_BUNDLE_NAME or TAG_PEER_TOKENID error"); - return; + if (IsString(extraInfoJson, TAG_PEER_BUNDLE_NAME)) { + peerBundleName = extraInfoJson[TAG_PEER_BUNDLE_NAME].Get(); + } + if (IsUint64(extraInfoJson, TAG_PEER_TOKENID)) { + peerTokenId = extraInfoJson[TAG_PEER_TOKENID].Get(); } - peerTokenId = extraInfoJson[TAG_PEER_TOKENID].Get(); - peerBundleName = extraInfoJson[TAG_PEER_BUNDLE_NAME].Get(); } DM_EXPORT std::vector JsonStrHandle::GetProxyTokenIdByExtra(const std::string &extraInfo) -- Gitee