mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 21:41:02 -04:00
@@ -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> deviceOfflineListener_ = nullptr;
|
||||
|
||||
std::mutex valMutex_;
|
||||
std::mutex syncNodeInfoMutex_;
|
||||
std::map<std::string, std::set<BeRegNodeInfo>> syncNodeInfoMap_;
|
||||
|
||||
int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
|
||||
sptr<IStartDInputCallback> callback);
|
||||
@@ -438,10 +433,7 @@ private:
|
||||
int32_t RelayStopRemoteInputByDhid(const std::string &srcId, const std::string &sinkId,
|
||||
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback);
|
||||
bool IsStringDataSame(const std::vector<std::string> &oldDhIds, std::vector<std::string> newDhIds);
|
||||
void DeleteNodeInfoAndNotify(const std::string &offlineDevId);
|
||||
std::set<BeRegNodeInfo> 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
|
||||
|
||||
@@ -1669,34 +1669,6 @@ void DistributedInputSourceManager::SetInputTypesMap(const std::string deviceId,
|
||||
InputTypesMap_[deviceId] = value;
|
||||
}
|
||||
|
||||
std::set<BeRegNodeInfo> DistributedInputSourceManager::GetSyncNodeInfo(const std::string &devId)
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<std::mutex> 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<BeRegNodeInfo> syncNodeInfo;
|
||||
syncNodeInfoMap_[userDevId] = syncNodeInfo;
|
||||
}
|
||||
syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc});
|
||||
}
|
||||
|
||||
void DistributedInputSourceManager::DeleteSyncNodeInfo(const std::string &devId)
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<BeRegNodeInfo> 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,
|
||||
|
||||
-41
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user