From 32067008d887ab83903606e5d84ce1fc3d751139 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Mon, 24 Jul 2023 17:01:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqiao49 --- common/include/input_hub.cpp | 4 ++-- common/include/input_hub.h | 4 ++-- .../include/distributed_input_node_manager.h | 4 ++-- .../src/distributed_input_node_manager.cpp | 12 ++++++------ services/state/include/dinput_state.h | 7 ------- services/state/src/dinput_state.cpp | 8 ++++++++ 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 0d3387b..c70c431 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -1140,8 +1140,8 @@ void InputHub::GetShareMousePathByDhId(std::vector dhIds, std::stri } } -void InputHub::GetShareKeyboardPathByDhId(std::vector dhIds, - std::vector &shareDhidsPath, std::vector &shareDhIds) +void InputHub::GetShareKeyboardPathByDhId(std::vector dhIds, std::vector &shareDhidsPath, + std::vector &shareDhIds) { DHLOGI("GetShareKeyboardPathByDhId: devices_.size:%d,", devices_.size()); std::unique_lock deviceLock(devicesMutex_); diff --git a/common/include/input_hub.h b/common/include/input_hub.h index 82d951f..408327a 100644 --- a/common/include/input_hub.h +++ b/common/include/input_hub.h @@ -53,8 +53,8 @@ public: void GetDevicesInfoByType(const uint32_t inputTypes, std::map &datas); void GetDevicesInfoByDhId(std::vector dhidsVec, std::map &datas); void GetShareMousePathByDhId(std::vector dhIds, std::string &path, std::string &dhId); - void GetShareKeyboardPathByDhId(std::vector dhIds, - std::vector &shareDhidsPath, std::vector &shareDhIds); + void GetShareKeyboardPathByDhId(std::vector dhIds, std::vector &shareDhidsPath, + std::vector &shareDhIds); bool IsAllDevicesStoped(); void ScanInputDevices(const std::string& dirname); diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 9608143..63e6dd7 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -38,7 +38,7 @@ public: DistributedInputNodeManager(); ~DistributedInputNodeManager(); - int32_t openDevicesNode(const std::string& devId, const std::string& dhId, + int32_t OpenDevicesNode(const std::string& devId, const std::string& dhId, const std::string& parameters); int32_t getDevice(const std::string& dhId, VirtualDevice*& device); @@ -69,7 +69,7 @@ private: void OpenInputDevice(const std::string& devicePath); int OpenInputDeviceFdByPath(std::string& canonicalDevicePath); bool IsVirtualDev(int fd); - bool GetDevDhIdFd(int fd, std::string& dhId, std::string& physicalPath); + bool GetDevDhIdByFd(int fd, std::string& dhId, std::string& physicalPath); void SetPathForDevMap(std::string& dhId, const std::string& devicePath); /* the key is dhId, and the value is virtualDevice */ diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 6a3d53d..145f460 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -58,7 +58,7 @@ DistributedInputNodeManager::~DistributedInputNodeManager() DHLOGI("destructor end"); } -int32_t DistributedInputNodeManager::openDevicesNode(const std::string& devId, const std::string& dhId, +int32_t DistributedInputNodeManager::OpenDevicesNode(const std::string& devId, const std::string& dhId, const std::string& parameters) { if (devId.size() > DEV_ID_LENGTH_MAX || devId.empty() || dhId.size() > DH_ID_LENGTH_MAX || dhId.empty() || @@ -181,7 +181,7 @@ bool DistributedInputNodeManager::IsVirtualDev(int fd) char buffer[256] = {0}; std::string deviceName; if (ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) { - DHLOGE("Could not get device name for %s", ConvertErrNo().c_str()); + DHLOGE("Could not get device name for %s.", ConvertErrNo().c_str()); return false; } buffer[sizeof(buffer) - 1] = '\0'; @@ -189,13 +189,13 @@ bool DistributedInputNodeManager::IsVirtualDev(int fd) DHLOGD("IsVirtualDev deviceName: %s", buffer); if (deviceName.find(VIRTUAL_DEVICE_NAME) == std::string::npos) { - DHLOGD("This is not a virtual device, fd %d, deviceName: %s", fd, deviceName.c_str()); + DHLOGD("This is not a virtual device, fd %d, deviceName: %s.", fd, deviceName.c_str()); return false; } return true; } -bool DistributedInputNodeManager::GetDevDhIdFd(int fd, std::string& dhId, std::string& physicalPath) +bool DistributedInputNodeManager::GetDevDhIdByFd(int fd, std::string& dhId, std::string& physicalPath) { char buffer[256] = {0}; if (ioctl(fd, EVIOCGPHYS(sizeof(buffer) - 1), &buffer) < 1) { @@ -269,7 +269,7 @@ void DistributedInputNodeManager::OpenInputDevice(const std::string& devicePath) DHLOGE("The dev not virtual, devicePath %s\n", devicePath.c_str()); return; } - if (GetDevDhIdFd(fd, dhId, physicalPath) == false) { + if (GetDevDhIdByFd(fd, dhId, physicalPath) == false) { DHLOGE("Get dev dhid failed, devicePath %s\n", devicePath.c_str()); return; } @@ -286,7 +286,7 @@ void DistributedInputNodeManager::GetVirtualKeyboardPathByDhId(const std::vector DHLOGE("device is nullptr"); continue; } - if ((iter->first.compare(dhId_) == 0) && + if ((iter->first.compare(dhId_) == 0) && ((iter->second->GetClasses() & INPUT_DEVICE_CLASS_KEYBOARD) != 0)) { DHLOGI("Found vir keyboard path %s, dhid %s", iter->second->GetPath().c_str(), GetAnonyString(dhId_).c_str()); diff --git a/services/state/include/dinput_state.h b/services/state/include/dinput_state.h index 6dc50a5..60a46b7 100644 --- a/services/state/include/dinput_state.h +++ b/services/state/include/dinput_state.h @@ -16,16 +16,9 @@ #ifndef DISTRIBUTED_INPUT_STATE_BASE_H #define DISTRIBUTED_INPUT_STATE_BASE_H -#include -#include -#include #include #include -#include #include -#include -#include -#include namespace OHOS { namespace DistributedHardware { diff --git a/services/state/src/dinput_state.cpp b/services/state/src/dinput_state.cpp index 7f989c0..f1e7c01 100644 --- a/services/state/src/dinput_state.cpp +++ b/services/state/src/dinput_state.cpp @@ -15,6 +15,14 @@ #include "dinput_state.h" +#include +#include +#include +#include +#include +#include +#include + #include "dinput_errcode.h" #include "dinput_log.h" #include "dinput_utils_tool.h"