mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-21 05:45:23 -04:00
@@ -302,6 +302,9 @@ void InputHub::RecordDeviceChangeStates(Device *device, struct input_event readB
|
||||
size_t InputHub::CollectEvent(RawEvent *buffer, size_t &capacity, Device *device, struct input_event readBuffer[],
|
||||
const size_t count)
|
||||
{
|
||||
if (capacity < 1) {
|
||||
return 0;
|
||||
}
|
||||
std::vector<bool> needFilted(capacity, false);
|
||||
bool isTouchEvent = false;
|
||||
if ((device->classes & INPUT_DEVICE_CLASS_TOUCH_MT) || (device->classes & INPUT_DEVICE_CLASS_TOUCH)) {
|
||||
@@ -915,8 +918,8 @@ int32_t InputHub::QueryLocalTouchScreenInfo(int fd, std::unique_ptr<Device> &dev
|
||||
|
||||
std::string InputHub::StringPrintf(const char *format, ...) const
|
||||
{
|
||||
static const int kSpaceLength = 1024;
|
||||
char space[kSpaceLength];
|
||||
static const int spaceLength = 1024;
|
||||
char space[spaceLength] = {0};
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
@@ -123,8 +123,8 @@ int32_t DistributedInputSinkStub::NotifyStartDScreenInner(MessageParcel &data, M
|
||||
GetAnonyString(sourcePhyId).c_str(), sourcePhyFd, sourcePhyWidth, sourcePhyHeight);
|
||||
SrcScreenInfo srcScreenInfo = {
|
||||
.devId = devId,
|
||||
.sessionId = sessionId,
|
||||
.uuid = uuid,
|
||||
.sessionId = sessionId,
|
||||
.sourceWinId = sourceWinId,
|
||||
.sourceWinWidth = sourceWinWidth,
|
||||
.sourceWinHeight = sourceWinHeight,
|
||||
|
||||
+12
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -24,16 +24,22 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const int32_t PERMISSION_ENABLE_INDEX = 0;
|
||||
const int32_t PERMISSION_DATASYNC_INDEX = 1;
|
||||
const int32_t PERMISSION_ACCESS_INDEX = 2;
|
||||
const int32_t PERMISSION_NUMS = 3;
|
||||
}
|
||||
void AddWhiteListInfosCallbackTest::SetUp()
|
||||
{
|
||||
uint64_t tokenId;
|
||||
const char *perms[3];
|
||||
perms[0] = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE";
|
||||
perms[1] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
|
||||
perms[2] = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE";
|
||||
const char *perms[PERMISSION_NUMS];
|
||||
perms[PERMISSION_ENABLE_INDEX] = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE";
|
||||
perms[PERMISSION_DATASYNC_INDEX] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
|
||||
perms[PERMISSION_ACCESS_INDEX] = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE";
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = 3,
|
||||
.permsNum = PERMISSION_NUMS,
|
||||
.aclsNum = 0,
|
||||
.dcaps = NULL,
|
||||
.perms = perms,
|
||||
|
||||
+12
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -27,16 +27,22 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const int32_t PERMISSION_ENABLE_INDEX = 0;
|
||||
const int32_t PERMISSION_DATASYNC_INDEX = 1;
|
||||
const int32_t PERMISSION_ACCESS_INDEX = 2;
|
||||
const int32_t PERMISSION_NUMS = 3;
|
||||
}
|
||||
void DInputSourceCallBackTest::SetUp()
|
||||
{
|
||||
uint64_t tokenId;
|
||||
const char *perms[3];
|
||||
perms[0] = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE";
|
||||
perms[1] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
|
||||
perms[2] = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE";
|
||||
const char *perms[PERMISSION_NUMS];
|
||||
perms[PERMISSION_ENABLE_INDEX] = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE";
|
||||
perms[PERMISSION_DATASYNC_INDEX] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
|
||||
perms[PERMISSION_ACCESS_INDEX] = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE";
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = 3,
|
||||
.permsNum = PERMISSION_NUMS,
|
||||
.aclsNum = 0,
|
||||
.dcaps = NULL,
|
||||
.perms = perms,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -23,7 +23,7 @@ namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
void MockProcess::MockDinputProcess(const char* processName)
|
||||
{
|
||||
static const char *PERMS[] = {
|
||||
static const char *perms[] = {
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
};
|
||||
uint64_t tokenId;
|
||||
@@ -32,7 +32,7 @@ void MockProcess::MockDinputProcess(const char* processName)
|
||||
.permsNum = 1,
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = PERMS,
|
||||
.perms = perms,
|
||||
.acls = nullptr,
|
||||
.processName = processName,
|
||||
.aplStr = "system_core",
|
||||
|
||||
@@ -253,7 +253,7 @@ void DistributedInputSinkTransport::SendKeyStateNodeMsgBatch(const int32_t sessi
|
||||
|
||||
void DistributedInputSinkTransport::DoSendMsgBatch(const int32_t sessionId, const std::vector<struct RawEvent> &events)
|
||||
{
|
||||
int64_t currentTimeNs = GetCurrentTimeUs() * 1000LL;
|
||||
int64_t currentTimeNs = static_cast<int64_t>(GetCurrentTimeUs()) * 1000LL;
|
||||
std::shared_ptr<nlohmann::json> eventsJsonArr = std::make_shared<nlohmann::json>();
|
||||
for (const auto &ev : events) {
|
||||
nlohmann::json tmpJson;
|
||||
@@ -582,6 +582,12 @@ void DistributedInputSinkTransport::DInputSinkEventHandler::RecordEventLog(
|
||||
{
|
||||
for (nlohmann::json::const_iterator iter = events->cbegin(); iter != events->cend(); ++iter) {
|
||||
nlohmann::json event = *iter;
|
||||
if (!IsInt32(event, INPUT_KEY_TYPE) || !IsInt64(event, INPUT_KEY_WHEN) ||
|
||||
!IsUInt32(event, INPUT_KEY_CODE) || !IsInt32(event, INPUT_KEY_VALUE) ||
|
||||
!IsString(event, INPUT_KEY_PATH)) {
|
||||
DHLOGE("The key is invaild.");
|
||||
continue;
|
||||
}
|
||||
std::string eventType = "";
|
||||
int32_t evType = event[INPUT_KEY_TYPE];
|
||||
switch (evType) {
|
||||
|
||||
@@ -92,7 +92,7 @@ bool VirtualDevice::CreateKey(const InputDevice &inputDevice)
|
||||
void VirtualDevice::SetABSInfo(struct uinput_user_dev &inputUserDev, const InputDevice &inputDevice)
|
||||
{
|
||||
DHLOGI("SetABSInfo!");
|
||||
for (const auto item : inputDevice.absInfos) {
|
||||
for (auto item : inputDevice.absInfos) {
|
||||
int absCode = item.first;
|
||||
std::vector<int32_t> absInfo = item.second;
|
||||
DHLOGI("SetABSInfo nodeName: %{public}s, absCode: %{public}d, absMin: %{public}d, absMax: %{public}d, "
|
||||
|
||||
@@ -127,7 +127,9 @@ std::string SetAnonyId(const std::string &message)
|
||||
dhidStr = dhidStr.substr(pos + 1, dhidStr.size());
|
||||
pos = dhidStr.find(".");
|
||||
}
|
||||
jsonObj[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = anonyDhidStr.substr(0, anonyDhidStr.length() - 1);
|
||||
if (anonyDhidStr.length() >= 1) {
|
||||
jsonObj[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = anonyDhidStr.substr(0, anonyDhidStr.length() - 1);
|
||||
}
|
||||
}
|
||||
if (IsString(jsonObj, DINPUT_SOFTBUS_KEY_SRC_DEV_ID)) {
|
||||
jsonObj[DINPUT_SOFTBUS_KEY_SRC_DEV_ID] = GetAnonyString(jsonObj[DINPUT_SOFTBUS_KEY_SRC_DEV_ID]);
|
||||
@@ -232,6 +234,10 @@ std::string GetAnonyInt32(const int32_t value)
|
||||
return nullString;
|
||||
}
|
||||
size_t length = strlen(tempBuffer);
|
||||
if (length < 1) {
|
||||
DHLOGE("tempBuffer length error.");
|
||||
return "";
|
||||
}
|
||||
for (size_t i = 1; i <= length - 1; i++) {
|
||||
tempBuffer[i] = '*';
|
||||
}
|
||||
@@ -430,6 +436,10 @@ void ResetVirtualDevicePressedKeys(const std::vector<std::string> &nodePaths)
|
||||
std::string GetString(const std::vector<std::string> &vec)
|
||||
{
|
||||
std::string retStr = "[";
|
||||
if (vec.size() < 1) {
|
||||
DHLOGE("vec size error.");
|
||||
return "";
|
||||
}
|
||||
for (uint32_t i = 0; i < vec.size(); i++) {
|
||||
if (i != (vec.size() - 1)) {
|
||||
retStr += vec[i] + ", ";
|
||||
|
||||
Reference in New Issue
Block a user