modify touchpad error, improve log

Signed-off-by: hwzhangchuang <zhangchuang.zhang@huawei.com>
This commit is contained in:
hwzhangchuang
2023-10-30 19:51:24 +08:00
parent 93b53275dd
commit e98103f10a
3 changed files with 20 additions and 49 deletions
+10 -8
View File
@@ -171,9 +171,12 @@ size_t InputHub::GetEvents(RawEvent *buffer, size_t bufferSize)
size_t count = ReadInputEvent(readSize, *GetDeviceByFdLocked(eventItem.data.fd));
Device* device = GetSupportDeviceByFd(eventItem.data.fd);
if (!device) {
DHLOGE("Can not find device by fd: %d", eventItem.data.fd);
continue;
}
if (!sharedDHIds_[device->identifier.descriptor]) {
DHLOGE("Not in sharing stat, device descriptor: %s",
GetAnonyString(device->identifier.descriptor).c_str());
continue;
}
DHLOGD("shared device dhId: %s, name: %s", GetAnonyString(device->identifier.descriptor).c_str(),
@@ -434,6 +437,7 @@ bool InputHub::IsDeviceRegistered(const std::string &devicePath)
std::lock_guard<std::mutex> deviceLock(devicesMutex_);
for (const auto &[deviceId, device] : devices_) {
if (device->path == devicePath) {
DHLOGI("Device node already registered, node path: %s", device->path.c_str());
return true; // device was already registered
}
}
@@ -447,7 +451,7 @@ int32_t InputHub::OpenInputDeviceLocked(const std::string &devicePath)
}
std::lock_guard<std::mutex> my_lock(operationMutex_);
DHLOGI("Opening device: %s", devicePath.c_str());
DHLOGI("Opening device start: %s", devicePath.c_str());
int fd = OpenInputDeviceFdByPath(devicePath);
if (fd == UN_INIT_FD_VALUE) {
DHLOGE("The fd open failed, devicePath %s.", devicePath.c_str());
@@ -468,9 +472,11 @@ int32_t InputHub::OpenInputDeviceLocked(const std::string &devicePath)
if (MakeDevice(fd, std::move(device)) < 0) {
CloseFd(fd);
DHLOGI("Opening device error: %s", devicePath.c_str());
return ERR_DH_INPUT_HUB_MAKE_DEVICE_FAIL;
}
DHLOGI("Opening device finish: %s", devicePath.c_str());
return DH_SUCCESS;
}
@@ -714,12 +720,12 @@ int32_t InputHub::MakeDevice(int fd, std::unique_ptr<Device> device)
if (TestBit(BTN_TOUCH, device->keyBitmask) &&
TestBit(ABS_MT_POSITION_X, device->absBitmask) &&
TestBit(ABS_MT_POSITION_Y, device->absBitmask)) {
QueryLocalTouchScreenInfo(fd);
QueryLocalTouchScreenInfo(fd, device);
device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
} else if (TestBit(BTN_TOUCH, device->keyBitmask) &&
TestBit(ABS_X, device->absBitmask) &&
TestBit(ABS_Y, device->absBitmask)) {
QueryLocalTouchScreenInfo(fd);
QueryLocalTouchScreenInfo(fd, device);
device->classes |= INPUT_DEVICE_CLASS_TOUCH;
}
@@ -760,13 +766,9 @@ int32_t InputHub::MakeDevice(int fd, std::unique_ptr<Device> device)
return DH_SUCCESS;
}
int32_t InputHub::QueryLocalTouchScreenInfo(int fd)
int32_t InputHub::QueryLocalTouchScreenInfo(int fd, std::unique_ptr<Device> &device)
{
LocalTouchScreenInfo info = DInputContext::GetInstance().GetLocalTouchScreenInfo();
std::unique_ptr<Device> device = std::make_unique<Device>(fd, 0, "");
if (QueryInputDeviceInfo(fd, device) < 0) {
return ERR_DH_INPUT_HUB_QUERY_INPUT_DEVICE_INFO_FAIL;
}
device->identifier.classes |= INPUT_DEVICE_CLASS_TOUCH_MT;
info.localAbsInfo.deviceInfo = device->identifier;
+1 -1
View File
@@ -158,7 +158,7 @@ private:
void RecordEventLog(const RawEvent *event);
void RecordDeviceLog(const int32_t deviceId, const std::string &devicePath, const InputDevice &identifier);
void HandleTouchScreenEvent(struct input_event readBuffer[], const size_t count, std::vector<bool> &needFilted);
int32_t QueryLocalTouchScreenInfo(int fd);
int32_t QueryLocalTouchScreenInfo(int fd, std::unique_ptr<Device> &device);
bool CheckTouchPointRegion(struct input_event readBuffer[], const AbsInfo &absInfo);
size_t CollectEvent(RawEvent *buffer, size_t &capacity, Device *device, struct input_event readBuffer[],
const size_t count);
+9 -40
View File
@@ -139,76 +139,44 @@ std::string SetAnonyId(const std::string &message)
bool IsBoolean(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_boolean();
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_boolean();
}
bool IsString(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_string();
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_string();
}
bool IsInt32(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_number_integer() && INT32_MIN <= jsonObj[key] &&
return jsonObj.contains(key) && jsonObj[key].is_number_integer() && INT32_MIN <= jsonObj[key] &&
jsonObj[key] <= INT32_MAX;
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
}
bool IsInt64(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_number_integer() && INT64_MIN <= jsonObj[key] &&
return jsonObj.contains(key) && jsonObj[key].is_number_integer() && INT64_MIN <= jsonObj[key] &&
jsonObj[key] <= INT64_MAX;
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
}
bool IsUInt16(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT16_MAX;
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT16_MAX;
}
bool IsUInt32(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT32_MAX;
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT32_MAX;
}
bool IsUInt64(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT64_MAX;
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_number_unsigned() && jsonObj[key] <= UINT64_MAX;
}
bool IsArray(const nlohmann::json &jsonObj, const std::string &key)
{
bool res = jsonObj.contains(key) && jsonObj[key].is_array();
if (!res) {
DHLOGE("The key %s in jsonObj is invalid.", key.c_str());
}
return res;
return jsonObj.contains(key) && jsonObj[key].is_array();
}
std::string GetNodeDesc(std::string parameters)
@@ -380,6 +348,7 @@ void ScanInputDevicesPath(const std::string &dirName, std::vector<std::string> &
continue;
}
std::string tmpDevName = dirName + "/" + std::string(de->d_name);
DHLOGI("Find input node path: %s", tmpDevName.c_str());
vecInputDevPath.push_back(tmpDevName);
}
closedir(dir);