mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
!114 虚拟驱动缓存信息中没有设备id,导致有两台或以上设备时,一台设备上下线影响另外一台设备的正常使用
Merge pull request !114 from zhangchuang/master
This commit is contained in:
@@ -53,7 +53,6 @@ private:
|
||||
DistributedInputHandler();
|
||||
~DistributedInputHandler();
|
||||
void StructTransJson(const InputDevice &pBuf, std::string &strDescriptor);
|
||||
int32_t GetDeviceInfo(std::string &deviceId);
|
||||
std::shared_ptr<PluginListener> m_listener;
|
||||
bool InitCollectEventsThread();
|
||||
void NotifyHardWare(int iCnt);
|
||||
@@ -62,7 +61,7 @@ private:
|
||||
bool isCollectingEvents_;
|
||||
bool isStartCollectEventThread;
|
||||
static void *CollectEventsThread(void *param);
|
||||
void StartInputMonitorDeviceThread(const std::string deviceId);
|
||||
void StartInputMonitorDeviceThread();
|
||||
void StopInputMonitorDeviceThread();
|
||||
|
||||
// The event queue.
|
||||
|
||||
@@ -149,21 +149,6 @@ void DistributedInputHandler::UnRegisterPluginListener()
|
||||
this->m_listener = nullptr;
|
||||
}
|
||||
|
||||
int32_t DistributedInputHandler::GetDeviceInfo(std::string &deviceId)
|
||||
{
|
||||
std::unique_lock<std::mutex> my_lock(operationMutex_);
|
||||
auto localNode = std::make_unique<NodeBasicInfo>();
|
||||
int32_t retCode = GetLocalNodeDeviceInfo("ohos.dhardware", localNode.get());
|
||||
if (retCode != 0) {
|
||||
DHLOGE("Could not get device id.");
|
||||
return ERR_DH_INPUT_HANDLER_GET_DEVICE_ID_FAIL;
|
||||
}
|
||||
|
||||
deviceId = localNode->networkId;
|
||||
DHLOGI("device id is %s", GetAnonyString(deviceId).c_str());
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
bool DistributedInputHandler::InitCollectEventsThread()
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
@@ -190,15 +175,12 @@ void *DistributedInputHandler::CollectEventsThread(void *param)
|
||||
DHLOGE("CollectEventsThread setname failed.");
|
||||
}
|
||||
DistributedInputHandler *pThis = reinterpret_cast<DistributedInputHandler *>(param);
|
||||
|
||||
std::string deviceId;
|
||||
pThis->GetDeviceInfo(deviceId);
|
||||
pThis->StartInputMonitorDeviceThread(deviceId);
|
||||
pThis->StartInputMonitorDeviceThread();
|
||||
DHLOGI("DistributedInputHandler::CollectEventsThread exist!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DistributedInputHandler::StartInputMonitorDeviceThread(const std::string deviceId)
|
||||
void DistributedInputHandler::StartInputMonitorDeviceThread()
|
||||
{
|
||||
if (inputHub_ == nullptr) {
|
||||
DHLOGE("inputHub_ not initialized");
|
||||
|
||||
@@ -58,11 +58,10 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le
|
||||
uint32_t inputTypes = static_cast<uint32_t>(DInputDeviceType::ALL);
|
||||
std::map<int32_t, std::string> datas;
|
||||
std::vector<std::string> dhidsVec;
|
||||
std::string deviceId = "deviceId_test";
|
||||
dInputHandler.FindDevicesInfoByType(inputTypes, datas);
|
||||
dInputHandler.FindDevicesInfoByDhId(dhidsVec, datas);
|
||||
dInputHandler.Query();
|
||||
dInputHandler.StartInputMonitorDeviceThread(deviceId);
|
||||
dInputHandler.StartInputMonitorDeviceThread();
|
||||
|
||||
InputDevice inputDevice;
|
||||
dInputHandler.mEventBuffer[0].type = DeviceType::DEVICE_ADDED;
|
||||
@@ -77,7 +76,7 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le
|
||||
std::map<std::string, std::string> ret = dInputHandler.QueryExtraInfo();
|
||||
EXPECT_EQ(0, ret.size());
|
||||
dInputHandler.inputHub_ = std::make_unique<InputHub>();
|
||||
dInputHandler.StartInputMonitorDeviceThread(deviceId);
|
||||
dInputHandler.StartInputMonitorDeviceThread();
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
Reference in New Issue
Block a user