mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-18 16:04:40 -04:00
@@ -1201,15 +1201,22 @@ void DistributedInputSourceManager::RunRelayPrepareCallback(const std::string &s
|
||||
{
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_PREPARE_START, DINPUT_PREPARE_TASK);
|
||||
std::lock_guard<std::mutex> lock(prepareMutex_);
|
||||
bool isCbRun = false;
|
||||
sptr<IPrepareDInputCallback> cb = nullptr;
|
||||
for (auto iter = relayPreCallbacks_.begin(); iter != relayPreCallbacks_.end(); ++iter) {
|
||||
if (iter->srcId == srcId && iter->sinkId == sinkId) {
|
||||
DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI");
|
||||
iter->preCallback->OnResult(sinkId, status);
|
||||
cb = iter->preCallback;
|
||||
relayPreCallbacks_.erase(iter);
|
||||
return;
|
||||
isCbRun = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI relayPreCallbacks_ is null.");
|
||||
if (isCbRun && cb != nullptr) {
|
||||
cb->OnResult(sinkId, status);
|
||||
} else {
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI relayPreCallbacks_ is null.");
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSourceManager::RunRelayUnprepareCallback(const std::string &srcId, const std::string &sinkId,
|
||||
@@ -1217,15 +1224,22 @@ void DistributedInputSourceManager::RunRelayUnprepareCallback(const std::string
|
||||
{
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_UNPREPARE_START, DINPUT_UNPREPARE_TASK);
|
||||
std::lock_guard<std::mutex> lock(prepareMutex_);
|
||||
bool isCbRun = false;
|
||||
sptr<IUnprepareDInputCallback> cb = nullptr;
|
||||
for (auto iter = relayUnpreCallbacks_.begin(); iter != relayUnpreCallbacks_.end(); ++iter) {
|
||||
if (iter->srcId == srcId && iter->sinkId == sinkId) {
|
||||
DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI");
|
||||
iter->unpreCallback->OnResult(sinkId, status);
|
||||
cb = iter->unpreCallback;
|
||||
relayUnpreCallbacks_.erase(iter);
|
||||
return;
|
||||
isCbRun = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI relayUnpreCallbacks_ is null.");
|
||||
if (isCbRun && cb != nullptr) {
|
||||
cb->OnResult(sinkId, status);
|
||||
} else {
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI relayUnpreCallbacks_ is null.");
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSourceManager::RunUnprepareCallback(const std::string &devId, const int32_t &status)
|
||||
@@ -1330,18 +1344,20 @@ void DistributedInputSourceManager::RunRelayStartDhidCallback(const std::string
|
||||
DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI dhIds:%s, vec-size:%d",
|
||||
dhids.c_str(), dhidsVec.size());
|
||||
bool isCbRun = false;
|
||||
for (std::vector<DInputClientStartDhidInfo>::iterator iter = relayStaDhidCallbacks_.begin();
|
||||
iter != relayStaDhidCallbacks_.end(); ++iter) {
|
||||
sptr<IStartStopDInputsCallback> cb = nullptr;
|
||||
for (auto iter = relayStaDhidCallbacks_.begin(); iter != relayStaDhidCallbacks_.end(); ++iter) {
|
||||
if (iter->srcId != srcId || iter->sinkId != sinkId || !IsStringDataSame(iter->dhIds, dhidsVec)) {
|
||||
continue;
|
||||
}
|
||||
DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI call OnResultDhids");
|
||||
iter->callback->OnResultDhids(sinkId, status);
|
||||
cb = iter->callback;
|
||||
relayStaDhidCallbacks_.erase(iter);
|
||||
isCbRun = true;
|
||||
break;
|
||||
}
|
||||
if (!isCbRun) {
|
||||
if (isCbRun && cb != nullptr) {
|
||||
cb->OnResultDhids(sinkId, status);
|
||||
} else {
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI relayStaDhidCallbacks_ is null.");
|
||||
}
|
||||
}
|
||||
@@ -1352,18 +1368,20 @@ void DistributedInputSourceManager::RunRelayStopDhidCallback(const std::string &
|
||||
std::vector<std::string> dhidsVec;
|
||||
SplitStringToVector(dhids, INPUT_STRING_SPLIT_POINT, dhidsVec);
|
||||
bool isCbRun = false;
|
||||
for (std::vector<DInputClientStopDhidInfo>::iterator iter = relayStpDhidCallbacks_.begin();
|
||||
iter != relayStpDhidCallbacks_.end(); ++iter) {
|
||||
sptr<IStartStopDInputsCallback> cb = nullptr;
|
||||
for (auto iter = relayStpDhidCallbacks_.begin(); iter != relayStpDhidCallbacks_.end(); ++iter) {
|
||||
if (iter->srcId != srcId || iter->sinkId != sinkId || !IsStringDataSame(iter->dhIds, dhidsVec)) {
|
||||
continue;
|
||||
}
|
||||
DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI call OnResultDhids");
|
||||
iter->callback->OnResultDhids(sinkId, status);
|
||||
cb = iter->callback;
|
||||
relayStpDhidCallbacks_.erase(iter);
|
||||
isCbRun = true;
|
||||
break;
|
||||
}
|
||||
if (!isCbRun) {
|
||||
if (isCbRun && cb != nullptr) {
|
||||
cb->OnResultDhids(sinkId, status);
|
||||
} else {
|
||||
DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI relayStpDhidCallbacks_ is null.");
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -1479,6 +1479,22 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_01, testin
|
||||
EXPECT_EQ(1, sourceManager_->relayStaDhidCallbacks_.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_02, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
int32_t status = 0;
|
||||
std::string dhId = "input_slkdiek3kddkeojfe";
|
||||
std::vector<std::string> dhIds;
|
||||
dhIds.push_back(dhId);
|
||||
sourceManager_->relayStaDhidCallbacks_.clear();
|
||||
sptr<TestStartStopDInputsCb> cb = nullptr;
|
||||
DistributedInputSourceManager::DInputClientStartDhidInfo startDhIdInfo {srcId, sinkId, dhIds, cb};
|
||||
sourceManager_->relayStaDhidCallbacks_.push_back(startDhIdInfo);
|
||||
sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
|
||||
EXPECT_EQ(0, sourceManager_->relayStaDhidCallbacks_.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
@@ -1509,6 +1525,22 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing
|
||||
EXPECT_EQ(1, sourceManager_->relayStpDhidCallbacks_.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_02, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
int32_t status = 0;
|
||||
std::string dhId = "input_slkdiek3kddkeojfe";
|
||||
std::vector<std::string> dhIds;
|
||||
dhIds.push_back(dhId);
|
||||
sourceManager_->relayStpDhidCallbacks_.clear();
|
||||
sptr<TestStartStopDInputsCb> cb = nullptr;
|
||||
DistributedInputSourceManager::DInputClientStopDhidInfo stopDhIdInfo {srcId, sinkId, dhIds, cb};
|
||||
sourceManager_->relayStpDhidCallbacks_.push_back(stopDhIdInfo);
|
||||
sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
|
||||
EXPECT_EQ(0, sourceManager_->relayStpDhidCallbacks_.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartTypeCallback_01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
|
||||
Reference in New Issue
Block a user