代码格式调整

Signed-off-by: liqiao49 <liqiao49@huawei.com>
This commit is contained in:
liqiao49
2023-07-24 17:01:08 +08:00
parent 0fa4a57a9f
commit 32067008d8
6 changed files with 20 additions and 19 deletions
+2 -2
View File
@@ -1140,8 +1140,8 @@ void InputHub::GetShareMousePathByDhId(std::vector<std::string> dhIds, std::stri
}
}
void InputHub::GetShareKeyboardPathByDhId(std::vector<std::string> dhIds,
std::vector<std::string> &shareDhidsPath, std::vector<std::string> &shareDhIds)
void InputHub::GetShareKeyboardPathByDhId(std::vector<std::string> dhIds, std::vector<std::string> &shareDhidsPath,
std::vector<std::string> &shareDhIds)
{
DHLOGI("GetShareKeyboardPathByDhId: devices_.size:%d,", devices_.size());
std::unique_lock<std::mutex> deviceLock(devicesMutex_);
+2 -2
View File
@@ -53,8 +53,8 @@ public:
void GetDevicesInfoByType(const uint32_t inputTypes, std::map<int32_t, std::string> &datas);
void GetDevicesInfoByDhId(std::vector<std::string> dhidsVec, std::map<int32_t, std::string> &datas);
void GetShareMousePathByDhId(std::vector<std::string> dhIds, std::string &path, std::string &dhId);
void GetShareKeyboardPathByDhId(std::vector<std::string> dhIds,
std::vector<std::string> &shareDhidsPath, std::vector<std::string> &shareDhIds);
void GetShareKeyboardPathByDhId(std::vector<std::string> dhIds, std::vector<std::string> &shareDhidsPath,
std::vector<std::string> &shareDhIds);
bool IsAllDevicesStoped();
void ScanInputDevices(const std::string& dirname);
@@ -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 */
@@ -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());
-7
View File
@@ -16,16 +16,9 @@
#ifndef DISTRIBUTED_INPUT_STATE_BASE_H
#define DISTRIBUTED_INPUT_STATE_BASE_H
#include <dirent.h>
#include <fcntl.h>
#include <linux/input.h>
#include <map>
#include <mutex>
#include <pthread.h>
#include <string>
#include <thread>
#include <unistd.h>
#include <vector>
namespace OHOS {
namespace DistributedHardware {
+8
View File
@@ -15,6 +15,14 @@
#include "dinput_state.h"
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <thread>
#include <unistd.h>
#include <vector>
#include <linux/input.h>
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"