mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 09:36:05 -04:00
Description:fix reviewBot
Match-id-7c6c419690dc6489e00476859cb2f18229a73721
This commit is contained in:
@@ -352,8 +352,6 @@ std::vector<InputDevice> InputHub::GetAllInputDevices()
|
||||
|
||||
void InputHub::ScanInputDevices(const std::string& dirname)
|
||||
{
|
||||
char devname[PATH_MAX];
|
||||
char *filename;
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
dir = opendir(dirname.c_str());
|
||||
@@ -362,22 +360,14 @@ void InputHub::ScanInputDevices(const std::string& dirname)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcpy_s(devname, PATH_MAX, dirname.c_str()) != 0) {
|
||||
DHLOGE("error strcpy_s :%{public}s\n", strerror(errno));
|
||||
}
|
||||
filename = devname + strlen(devname);
|
||||
*filename++ = '/';
|
||||
while ((de = readdir(dir))) {
|
||||
if (de->d_name[0] == '.' &&
|
||||
(de->d_name[1] == '\0' ||
|
||||
(de->d_name[1] == '.' && de->d_name[DIR_FILE_NAME_SECOND] == '\0'))) {
|
||||
continue;
|
||||
}
|
||||
if (strcpy_s(filename, sizeof(de->d_name), de->d_name) != 0) {
|
||||
DHLOGE("error strcpy_s second :%{public}s\n", strerror(errno));
|
||||
}
|
||||
DHLOGE("scan dir failed for %{public}s", filename);
|
||||
OpenInputDeviceLocked(devname);
|
||||
std::string devName = dirname + "/" + std::string(de->d_name);
|
||||
OpenInputDeviceLocked(devName);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const char* WHITE_LIST_FILE_PATH = "/etc/dinput_business_event_whitelist.cfg";
|
||||
const char* SPLIT_LINE = "|";
|
||||
const char* SPLIT_COMMA = ",";
|
||||
}
|
||||
@@ -50,6 +49,7 @@ int32_t WhiteListUtil::Init(const std::string &deviceId)
|
||||
{
|
||||
DHLOGI("start, deviceId=%s", GetAnonyString(deviceId).c_str());
|
||||
ClearWhiteList();
|
||||
const char* whiteListFilePath = "/etc/dinput_business_event_whitelist.cfg";
|
||||
|
||||
if (deviceId.empty()) {
|
||||
// device id error
|
||||
@@ -57,10 +57,10 @@ int32_t WhiteListUtil::Init(const std::string &deviceId)
|
||||
return ERR_DH_INPUT_WHILTELIST_INIT_FAIL;
|
||||
}
|
||||
|
||||
std::ifstream inFile(WHITE_LIST_FILE_PATH, std::ios::in | std::ios::binary);
|
||||
std::ifstream inFile(whiteListFilePath, std::ios::in | std::ios::binary);
|
||||
if (!inFile.is_open()) {
|
||||
// file open error
|
||||
DHLOGE("%s error, file open fail path=%s", __func__, WHITE_LIST_FILE_PATH);
|
||||
DHLOGE("%s error, file open fail path=%s", __func__, whiteListFilePath);
|
||||
return ERR_DH_INPUT_WHILTELIST_INIT_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,8 @@ void DistributedInputInnerTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DistributedInputInnerTest::TestPrepareDInputCallback::OnResult(
|
||||
const std::string& deviceId, const int32_t& status)
|
||||
|
||||
{
|
||||
(void)deviceId;
|
||||
(void)status;
|
||||
@@ -69,6 +67,9 @@ void DistributedInputInnerTest::TestStartDInputCallback::OnResult(
|
||||
void DistributedInputInnerTest::TestStopDInputCallback::OnResult(
|
||||
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
|
||||
{
|
||||
(void)deviceId;
|
||||
(void)inputTypes;
|
||||
(void)status;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
int32_t HandleInitDistributedHardware(MessageParcel &reply);
|
||||
int32_t HandleReleaseDistributedHardware(MessageParcel &reply);
|
||||
int32_t HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -27,6 +27,24 @@ DistributedInputSourceStub::DistributedInputSourceStub()
|
||||
DistributedInputSourceStub::~DistributedInputSourceStub()
|
||||
{}
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply)
|
||||
{
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL;
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply)
|
||||
{
|
||||
int32_t ret = Release();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL;
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string devId = data.ReadString();
|
||||
@@ -120,21 +138,11 @@ int32_t DistributedInputSourceStub::OnRemoteRequest(uint32_t code, MessageParcel
|
||||
{
|
||||
switch (code) {
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::INIT): {
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL;
|
||||
} else {
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
return HandleInitDistributedHardware(reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::RELEASE): {
|
||||
int32_t ret = Release();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL;
|
||||
} else {
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
return HandleReleaseDistributedHardware(reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::REGISTER_REMOTE_INPUT): {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DISTRIBUTED_INPUT_KIT_FUZZER_H
|
||||
#define DISTRIBUTED_INPUT_KIT_FUZZER_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user