diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 44b909d0f5f417388c740813c6ac78e95dc988e7..7a7df2b1e2eecc34f0854524deddfccb4668c759 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -193,8 +193,10 @@ int32_t DistributedHardwareManagerFactory::SendOnLineEvent(const std::string &ne } if (DeviceParamMgr::GetInstance().IsDeviceE2ESync()) { - DHLOGI("e2e device, need initiative sync data."); - MetaInfoManager::GetInstance()->SyncDataByNetworkId(networkId); + if (osType != OLD_HO_DEVICE_TYPE && osType != NEW_HO_DEVICE_TYPE) { + DHLOGI("local device is e2e device and remote is single frame device, need initiative sync data."); + MetaInfoManager::GetInstance()->SyncDataByNetworkId(networkId); + } } if (osType == OLD_HO_DEVICE_TYPE || osType == NEW_HO_DEVICE_TYPE) { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp index 2aab85bfbb68f519bee95899fa779ccc234af7d2..4f9b653629edec7f0ac135502ffefdb73262ce84 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp @@ -19,9 +19,11 @@ #include "dm_device_info.h" +#include "device_param_mgr.h" #include "dh_context.h" #include "distributed_hardware_manager_factory.h" #include "distributed_hardware_errno.h" + using namespace testing::ext; namespace OHOS { @@ -34,6 +36,8 @@ enum class Status : uint32_t { constexpr uint16_t TEST_DEV_TYPE_PAD = 0x11; constexpr int32_t INVALID_OSTYPE = 10; +constexpr int32_t OLD_HO_DEVICE_TYPE = -1; +constexpr int32_t NEW_HO_DEVICE_TYPE = 11; const std::string TEST_NETWORKID = "111111"; const std::string TEST_UUID = "222222"; const std::string TEST_UDID = "333333"; @@ -238,5 +242,50 @@ HWTEST_F(AccessManagerTest, InitLocalDevInfo_001, TestSize.Level1) { ASSERT_TRUE(DistributedHardwareManagerFactory::GetInstance().InitLocalDevInfo()); } + +HWTEST_F(AccessManagerTest, SendOnLineEvent_002, TestSize.Level1) +{ + std::string networkId = "networkId_1"; + std::string uuid = "uuid_1"; + std::string udid = "udid_1"; + uint16_t deviceType = TEST_DEV_TYPE_PAD; + int32_t osType = OLD_HO_DEVICE_TYPE; + DistributedHardwareManagerFactory::GetInstance().flagUnInit_.store(false); + DistributedHardwareManagerFactory::GetInstance().isInit_.store(true); + DeviceParamMgr::GetInstance().isDeviceE2ESync_.store(true); + int32_t ret = + DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, udid, deviceType, osType); + EXPECT_EQ(ret, DH_FWK_SUCCESS); +} + +HWTEST_F(AccessManagerTest, SendOnLineEvent_003, TestSize.Level1) +{ + std::string networkId = "networkId_2"; + std::string uuid = "uuid_2"; + std::string udid = "udid_2"; + uint16_t deviceType = TEST_DEV_TYPE_PAD; + int32_t osType = NEW_HO_DEVICE_TYPE; + DistributedHardwareManagerFactory::GetInstance().flagUnInit_.store(false); + DistributedHardwareManagerFactory::GetInstance().isInit_.store(true); + DeviceParamMgr::GetInstance().isDeviceE2ESync_.store(true); + int32_t ret = + DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, udid, deviceType, osType); + EXPECT_EQ(ret, DH_FWK_SUCCESS); +} + +HWTEST_F(AccessManagerTest, SendOnLineEvent_004, TestSize.Level1) +{ + std::string networkId = "networkId_3"; + std::string uuid = "uuid_3"; + std::string udid = "udid_3"; + uint16_t deviceType = TEST_DEV_TYPE_PAD; + int32_t osType = INVALID_OSTYPE; + DistributedHardwareManagerFactory::GetInstance().flagUnInit_.store(false); + DistributedHardwareManagerFactory::GetInstance().isInit_.store(true); + DeviceParamMgr::GetInstance().isDeviceE2ESync_.store(true); + int32_t ret = + DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, udid, deviceType, osType); + EXPECT_EQ(ret, DH_FWK_SUCCESS); +} } // namespace DistributedHardware } // namespace OHOS