mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
@@ -56,7 +56,7 @@ int32_t DistributedInputInject::RegisterDistributedHardware(const std::string& d
|
||||
DHLOGE("the DistributedInputNodeManager is null\n");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL;
|
||||
}
|
||||
if (inputNodeManager_->openDevicesNode(devId, dhId, parameters) < 0) {
|
||||
if (inputNodeManager_->OpenDevicesNode(devId, dhId, parameters) < 0) {
|
||||
DHLOGE("create virtual device error\n");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_INJECT_REGISTER_FAIL;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ bool DistributedInputNodeManager::GetDevDhIdByFd(int fd, std::string& dhId, std:
|
||||
{
|
||||
char buffer[256] = {0};
|
||||
if (ioctl(fd, EVIOCGPHYS(sizeof(buffer) - 1), &buffer) < 1) {
|
||||
DHLOGE("Could not get device name for %s", ConvertErrNo().c_str());
|
||||
DHLOGE("Could not get device physicalPath for %s", ConvertErrNo().c_str());
|
||||
return false;
|
||||
}
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
|
||||
+8
-8
@@ -421,41 +421,41 @@ HWTEST_F(DistributedInputSourceInjectTest, getDevice_001, testing::ext::TestSize
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_GET_DEVICE_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_001, testing::ext::TestSize.Level1)
|
||||
HWTEST_F(DistributedInputSourceInjectTest, OpenDevicesNode_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
std::string parameters = "";
|
||||
int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters);
|
||||
int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
|
||||
devId = "";
|
||||
parameters = "parameters_test";
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters);
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
|
||||
devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
dhId = "";
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters);
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_002, testing::ext::TestSize.Level1)
|
||||
HWTEST_F(DistributedInputSourceInjectTest, OpenDevicesNode_002, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId(DEV_ID_LENGTH_MAX + 1, 'a');
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
std::string parameters = "parameters_test";
|
||||
int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters);
|
||||
int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
|
||||
devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhIds(DH_ID_LENGTH_MAX + 1, 'a');
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIds, parameters);
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhIds, parameters);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
|
||||
std::string dhIdtest = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
std::string param(STRING_MAX_SIZE + 1, 'a');
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIdtest, param);
|
||||
ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhIdtest, param);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <linux/input.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -49,7 +50,7 @@ private:
|
||||
void CreateKeyUpInjectThread(const std::vector<std::string> &dhids);
|
||||
void CheckKeyState(std::string &dhid, std::string &keyboardNodePath);
|
||||
void UpInject(int fd, std::vector<uint32_t> &keyboardPressedKeys, std::string &dhid);
|
||||
void KeyUpInject(std::vector<std::string> &shareDhidsPaths, std::vector<std::string> &shareDhIds);
|
||||
void KeyUpInject(std::vector<std::string> shareDhidsPaths, std::vector<std::string> shareDhIds);
|
||||
bool IsExistDhid(const std::string &dhid);
|
||||
void RecordEventLog(const input_event& event);
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_log.h"
|
||||
@@ -153,7 +152,8 @@ int BitIsSet(const unsigned long *array, int bit)
|
||||
|
||||
void DInputState::CheckKeyState(std::string &dhid, std::string &keyboardNodePath)
|
||||
{
|
||||
DHLOGI("CheckKeyState enter, dhid :%s, keyboardNodePath :%s.", GetAnonyString(dhid).c_str(), keyboardNodePath.c_str());
|
||||
DHLOGI("CheckKeyState enter, dhid :%s, keyboardNodePath :%s.", GetAnonyString(dhid).c_str(),
|
||||
keyboardNodePath.c_str());
|
||||
char canonicalPath[PATH_MAX + 1] = {0x00};
|
||||
if (keyboardNodePath.length() == 0 || keyboardNodePath.length() > PATH_MAX ||
|
||||
realpath(keyboardNodePath.c_str(), canonicalPath) == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user