From 2b19dc4954bbf8fb579d0c3265f0be0510426903 Mon Sep 17 00:00:00 2001 From: yangliu Date: Fri, 25 Apr 2025 17:30:28 +0800 Subject: [PATCH 1/2] update Signed-off-by: yangliu --- .../src/device_manager_adapter.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp index b9b0078f6..f609f159b 100644 --- a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp +++ b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp @@ -263,8 +263,9 @@ void DeviceManagerAdapter::OnChanged(const DmDeviceInfo &info) ZLOGE("get device info fail"); return; } - ZLOGI("[OnChanged] uuid:%{public}s, name:%{public}s, type:%{public}d", - KvStoreUtils::ToBeAnonymous(dvInfo.uuid).c_str(), dvInfo.deviceName.c_str(), dvInfo.deviceType); + ZLOGI("[OnChanged] uuid:%{public}s, name:%{public}s, type:%{public}d, authForm:%{public}d osType:%{public}d", + KvStoreUtils::ToBeAnonymous(dvInfo.uuid).c_str(), dvInfo.deviceName.c_str(), dvInfo.deviceType, + static_cast(dvInfo.authForm), dvInfo.osType); } void DeviceManagerAdapter::OnReady(const DmDeviceInfo &info) @@ -275,8 +276,9 @@ void DeviceManagerAdapter::OnReady(const DmDeviceInfo &info) return; } readyDevices_.InsertOrAssign(dvInfo.uuid, std::make_pair(DeviceState::DEVICE_ONREADY, dvInfo)); - ZLOGI("[OnReady] uuid:%{public}s, name:%{public}s, type:%{public}d", - KvStoreUtils::ToBeAnonymous(dvInfo.uuid).c_str(), dvInfo.deviceName.c_str(), dvInfo.deviceType); + ZLOGI("[OnReady] uuid:%{public}s, name:%{public}s, type:%{public}d, authForm:%{public}d, osType:%{public}d", + KvStoreUtils::ToBeAnonymous(dvInfo.uuid).c_str(), dvInfo.deviceName.c_str(), dvInfo.deviceType, + static_cast(dvInfo.authForm), dvInfo.osType); auto task = [this, dvInfo]() { observers_.ForEachCopies([&dvInfo](const auto &key, auto &value) { if (value != nullptr) { @@ -326,6 +328,12 @@ void DeviceManagerAdapter::SaveDeviceInfo(const DeviceInfo &dvInfo, const Device deviceInfos_.Set(dvInfo.uuid, dvInfo); deviceInfos_.Set(dvInfo.udid, dvInfo); readyDevices_.InsertOrAssign(dvInfo.uuid, std::make_pair(DeviceState::DEVICE_ONLINE, dvInfo)); + if (dvInfo.osType != OH_OS_TYPE) { + otherDeviceInfos_.Set(dvInfo.networkId, dvInfo); + + otherDeviceInfos_.Set(dvInfo.uuid, dvInfo); + otherDeviceInfos_.Set(dvInfo.udid, dvInfo); + } break; } case DeviceChangeType::DEVICE_OFFLINE: { @@ -333,6 +341,11 @@ void DeviceManagerAdapter::SaveDeviceInfo(const DeviceInfo &dvInfo, const Device deviceInfos_.Delete(dvInfo.uuid); deviceInfos_.Delete(dvInfo.udid); readyDevices_.Erase(dvInfo.uuid); + if (dvInfo.osType != OH_OS_TYPE) { + otherDeviceInfos_.Delete(dvInfo.networkId); + otherDeviceInfos_.Delete(dvInfo.uuid); + otherDeviceInfos_.Delete(dvInfo.udid); + } break; } default: { @@ -409,7 +422,7 @@ bool DeviceManagerAdapter::IsOHOSType(const std::string &id) int32_t DeviceManagerAdapter::GetAuthType(const std::string &id) { DeviceInfo dvInfo; - if (!deviceInfos_.Get(id, dvInfo)) { + if (!otherDeviceInfos_.Get(id, dvInfo) && !deviceInfos_.Get(id, dvInfo)) { InitDeviceInfo(); deviceInfos_.Get(id, dvInfo); } -- Gitee From 65ae8cbcb7012bed8b4c33556f3b1325af83a443 Mon Sep 17 00:00:00 2001 From: yangliu Date: Fri, 25 Apr 2025 18:45:04 +0800 Subject: [PATCH 2/2] up Signed-off-by: yangliu --- .../adapter/include/communicator/device_manager_adapter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h index a50783ae1..53135966b 100644 --- a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h +++ b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h @@ -103,6 +103,7 @@ private: const DmDeviceInfo cloudDmInfo; ConcurrentMap observers_ {}; LRUBucket deviceInfos_ {64}; + LRUBucket otherDeviceInfos_ {64}; static constexpr size_t TIME_TASK_CAPACITY = 50; static constexpr int32_t SYNC_TIMEOUT = 60 * 1000; // ms static constexpr int32_t OH_OS_TYPE = 10; -- Gitee