diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index a2713ba..65483fe 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -79,13 +79,7 @@ int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string return ERR_DH_INPUT_SERVER_SOURCE_INJECT_UNREGISTER_FAIL; } - std::string srcDevId; - inputNodeManager_->GetDeviceInfo(srcDevId); - - DHLOGI("UnregisterDistributedHardware called, device = %s, dhId = %s, OnNodeOffLine", - GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); - SyncNodeOfflineInfo(srcDevId, devId, dhId); - + DHLOGI("UnregisterDistributedHardware success"); return DH_SUCCESS; } diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index 61b6945..f709759 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -225,9 +225,6 @@ public: void OnMessage(const DHTopic topic, const std::string &message) override; - private: - void DeleteNodeInfoAndNotify(const std::string &offlineDevId); - private: DistributedInputSourceManager *sourceManagerContext_; }; @@ -422,8 +419,6 @@ private: sptr deviceOfflineListener_ = nullptr; std::mutex valMutex_; - std::mutex syncNodeInfoMutex_; - std::map> syncNodeInfoMap_; int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, sptr callback); @@ -438,10 +433,7 @@ private: int32_t RelayStopRemoteInputByDhid(const std::string &srcId, const std::string &sinkId, const std::vector &dhIds, sptr callback); bool IsStringDataSame(const std::vector &oldDhIds, std::vector newDhIds); - void DeleteNodeInfoAndNotify(const std::string &offlineDevId); - std::set GetSyncNodeInfo(const std::string &devId); - void UpdateSyncNodeInfo(const std::string &devId, const std::string &dhId, const std::string &nodeDesc); - void DeleteSyncNodeInfo(const std::string &devId); + void UnregisterDHFwkPublisher(); }; } // namespace DistributedInput diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 1c1f293..a0fbb8a 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -1669,34 +1669,6 @@ void DistributedInputSourceManager::SetInputTypesMap(const std::string deviceId, InputTypesMap_[deviceId] = value; } -std::set DistributedInputSourceManager::GetSyncNodeInfo(const std::string &devId) -{ - std::lock_guard lock(syncNodeInfoMutex_); - if (syncNodeInfoMap_.find(devId) == syncNodeInfoMap_.end()) { - DHLOGI("syncNodeInfoMap find not the key: %s", GetAnonyString(devId).c_str()); - return {}; - } - return syncNodeInfoMap_[devId]; -} - -void DistributedInputSourceManager::UpdateSyncNodeInfo(const std::string &userDevId, const std::string &dhId, - const std::string &nodeDesc) -{ - std::lock_guard lock(syncNodeInfoMutex_); - if (syncNodeInfoMap_.find(userDevId) == syncNodeInfoMap_.end()) { - DHLOGI("syncNodeInfoMap has not the key: %s, So create this entry", GetAnonyString(userDevId).c_str()); - std::set syncNodeInfo; - syncNodeInfoMap_[userDevId] = syncNodeInfo; - } - syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); -} - -void DistributedInputSourceManager::DeleteSyncNodeInfo(const std::string &devId) -{ - std::lock_guard lock(syncNodeInfoMutex_); - syncNodeInfoMap_.erase(devId); -} - void DistributedInputSourceManager::StartDScreenListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("StartDScreenListener OnMessage!"); @@ -1887,26 +1859,6 @@ void DistributedInputSourceManager::DeviceOfflineListener::OnMessage(const DHTop DHLOGE("this message is empty"); return; } - DeleteNodeInfoAndNotify(message); -} - -void DistributedInputSourceManager::DeviceOfflineListener::DeleteNodeInfoAndNotify(const std::string &offlineDevId) -{ - DHLOGI("DeviceOfflineListener DeleteNodeInfoAndNotify!"); - if (sourceManagerContext_ == nullptr) { - DHLOGE("sourceManagerContext is nullptr!"); - return; - } - std::set nodeSet = sourceManagerContext_->GetSyncNodeInfo(offlineDevId); - std::string localNetWorkId = GetLocalNetworkId(); - for (const auto &node : nodeSet) { - DHLOGI("DeleteNodeInfoAndNotify device: %s, dhId: %s", GetAnonyString(offlineDevId).c_str(), - GetAnonyString(node.dhId).c_str()); - // Notify multimodal - DistributedInputInject::GetInstance().SyncNodeOfflineInfo(offlineDevId, localNetWorkId, node.dhId); - } - // Delete info - sourceManagerContext_->DeleteSyncNodeInfo(offlineDevId); } DistributedInputSourceManager::DScreenSourceSvrRecipient::DScreenSourceSvrRecipient(const std::string &srcDevId, diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index 9830edc..43ed88d 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -1632,47 +1632,6 @@ HWTEST_F(DistributedInputSourceManagerTest, SetInputTypesMap_01, testing::ext::T EXPECT_EQ(true, sourceManager_->InputTypesMap_.empty()); } -HWTEST_F(DistributedInputSourceManagerTest, GetSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - std::string devId = "sd6f4s6d5f46s5d4f654564sdfdfsdfsdfd55"; - sourceManager_->GetSyncNodeInfo(devId); - EXPECT_EQ(1, sourceManager_->GetSyncNodeInfo(userDevId).size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, UpdateSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - sourceManager_->UpdateSyncNodeInfo(userDevId, dhId, nodeDesc); - EXPECT_EQ(1, sourceManager_->syncNodeInfoMap_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, UpdateSyncNodeInfo_02, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_.clear(); - sourceManager_->UpdateSyncNodeInfo(userDevId, dhId, nodeDesc); - EXPECT_EQ(1, sourceManager_->syncNodeInfoMap_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, DeleteSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - sourceManager_->DeleteSyncNodeInfo(userDevId); - EXPECT_EQ(0, sourceManager_->syncNodeInfoMap_.size()); -} - HWTEST_F(DistributedInputSourceManagerTest, Dump_01, testing::ext::TestSize.Level1) { int32_t fd = 1;