diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h index 9e980d9cc426411cc176b982a96c36da369e026e..057ffa71f8e9154e3490d804a16f4643590fed42 100644 --- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h @@ -217,7 +217,6 @@ private: void DoRecover(DHType dhType); void ReStartSA(DHType dhType); void RecoverDistributedHardware(DHType dhType); - bool IsIdenticalAccount(const std::string &networkId); int32_t RetryGetEnableParam(const std::string &networkId, const std::string &uuid, const std::string &dhId, const DHType dhType, EnableParam ¶m); void StopPrivacy(); diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp index 7067acf5833021141e322188b4ddffff5576d90a..b29fc22bbaf042d69a2ffb9bb6f7aa7dd641186b 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp @@ -677,30 +677,6 @@ std::map ComponentManager::GetDHSinkInstance( return compSink_; } -bool ComponentManager::IsIdenticalAccount(const std::string &networkId) -{ - if (!IsIdLengthValid(networkId)) { - return false; - } - DmAuthForm authForm = DmAuthForm::INVALID_TYPE; - std::vector deviceList; - DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); - if (deviceList.size() == 0 || deviceList.size() > MAX_ONLINE_DEVICE_SIZE) { - DHLOGE("DeviceList size is invalid!"); - return false; - } - for (const auto &deviceInfo : deviceList) { - if (std::string(deviceInfo.networkId) == networkId) { - authForm = deviceInfo.authForm; - break; - } - } - if (authForm == DmAuthForm::IDENTICAL_ACCOUNT) { - return true; - } - return false; -} - void ComponentManager::UpdateBusinessState(const std::string &networkId, const std::string &dhId, BusinessState state) { if (!IsIdLengthValid(networkId) || !IsIdLengthValid(dhId)) { diff --git a/services/distributedhardwarefwkservice/src/task/online_task.cpp b/services/distributedhardwarefwkservice/src/task/online_task.cpp index f3f2e05da32a69b09f6f773e1d5bea463f3ffe27..62f686f89665133a5f68db5be7d63b9a3ffd2e5e 100644 --- a/services/distributedhardwarefwkservice/src/task/online_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/online_task.cpp @@ -54,6 +54,10 @@ OnLineTask::~OnLineTask() void OnLineTask::DoTask() { + if (!IsIdenticalAccount(GetNetworkId())) { + DHLOGE("Check identical account failed, networkId: %{public}s.", GetAnonyString(GetNetworkId()).c_str()); + return; + } DHLOGD("start online task, id = %{public}s, networkId: %{public}s, uuid: %{public}s, udid: %{public}s", GetId().c_str(), GetAnonyString(GetNetworkId()).c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetUDID()).c_str()); diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 4ffdda813305fa4a1ebd019f2380dadf515a09b2..962f8bc8b8611fdedcd8913a817d760c2793e71c 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -72,6 +72,10 @@ ohos_shared_library("distributedhardwareutils") { "-Wl,-z,now", ] + if (distributed_hardware_fwk_low_latency) { + defines += [ "DHARDWARE_CHECK_ACCCOUNT" ] + } + external_deps = [ "cJSON:cjson", "c_utils:utils", diff --git a/utils/include/dh_utils_tool.h b/utils/include/dh_utils_tool.h index 7c7f28523c40a284f5d9d556f3832e94899f9dac..baecef6b5b7707b5ebcca4b307cb8ef183611c8a 100644 --- a/utils/include/dh_utils_tool.h +++ b/utils/include/dh_utils_tool.h @@ -81,6 +81,8 @@ bool IsKeySizeValid(const std::string &key); bool IsHashSizeValid(const std::string &hashValue); int32_t GetDeviceSystemType(const std::string &extraData); + +bool IsIdenticalAccount(const std::string &networkId); } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index 31d456464b0c2e44cdb1d798c200af4a20eea075..5af780d3d4d84dc3bdba032fc6f0ddd7b39d824c 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -29,6 +29,7 @@ #include "parameter.h" #include "device_manager.h" +#include "device_type.h" #include "dm_device_info.h" #include "constants.h" @@ -367,5 +368,34 @@ int32_t GetDeviceSystemType(const std::string &extraData) cJSON_Delete(jsonObj); return osType; } + +bool IsIdenticalAccount(const std::string &networkId) +{ +#ifdef DHARDWARE_CHECK_ACCCOUNT + { + if (!IsIdLengthValid(networkId)) { + return false; + } + DmAuthForm authForm = DmAuthForm::INVALID_TYPE; + std::vector deviceList; + DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); + if (deviceList.size() == 0 || deviceList.size() > MAX_ONLINE_DEVICE_SIZE) { + DHLOGE("DeviceList size is invalid!"); + return false; + } + for (const auto &deviceInfo : deviceList) { + if (std::string(deviceInfo.networkId) == networkId) { + authForm = deviceInfo.authForm; + break; + } + } + if (authForm == DmAuthForm::IDENTICAL_ACCOUNT) { + return true; + } + return false; + } +#endif + return true; +} } // namespace DistributedHardware } // namespace OHOS