mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-25 06:15:33 -04:00
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2025 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
|
||||
@@ -329,7 +329,7 @@ int32_t DistributedInputClient::RegisterDistributedHardware(const std::string &d
|
||||
const std::string ¶meters, const std::shared_ptr<RegisterCallback> &callback)
|
||||
{
|
||||
DHLOGI("DinputRegister called, deviceId: %{public}s, dhId: %{public}s, parameters: %{public}s.",
|
||||
GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), SetAnonyId(parameters).c_str());
|
||||
GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
|
||||
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
|
||||
DHLOGE("DinputRegister client fail.");
|
||||
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
|
||||
|
||||
+9
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2025 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
|
||||
@@ -33,7 +33,10 @@ void RespPrepareRemoteInputFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
std::string smsg(reinterpret_cast<const char*>(data), size);
|
||||
nlohmann::json jsonStr;
|
||||
jsonStr["device_id"] = "123456";
|
||||
jsonStr["dh_id"] = "dinput_1";
|
||||
std::string smsg = jsonStr.dump();
|
||||
|
||||
DistributedInput::DistributedInputSinkTransport::GetInstance().RespPrepareRemoteInput(sessionId, smsg);
|
||||
DistributedInput::DistributedInputSinkTransport::GetInstance().RespUnprepareRemoteInput(sessionId, smsg);
|
||||
@@ -46,7 +49,10 @@ void RespStartRemoteInputFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
std::string smsg(reinterpret_cast<const char*>(data), size);
|
||||
nlohmann::json jsonStr;
|
||||
jsonStr["device_id"] = "123456";
|
||||
jsonStr["dh_id"] = "dinput_1";
|
||||
std::string smsg = jsonStr.dump();
|
||||
|
||||
DistributedInput::DistributedInputSinkTransport::GetInstance().RespStartRemoteInput(sessionId, smsg);
|
||||
DistributedInput::DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(sessionId, smsg);
|
||||
|
||||
+22
@@ -111,6 +111,26 @@ void InitFuzzTest(const uint8_t *data, size_t size)
|
||||
(void)size;
|
||||
DistributedInput::DistributedInputTransportBase::GetInstance().Init();
|
||||
}
|
||||
|
||||
void ReleaseFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
DistributedInput::DistributedInputTransportBase::GetInstance().Release();
|
||||
}
|
||||
|
||||
void CreateClientSocketFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return;
|
||||
}
|
||||
FuzzedDataProvider fdp(data, size);
|
||||
std::string remoteDevId = fdp.ConsumeRandomLengthString();
|
||||
DistributedInput::DistributedInputTransportBase::GetInstance().CreateClientSocket(remoteDevId);
|
||||
if (DistributedInput::DistributedInputTransportBase::GetInstance().sessionId_ > 0) {
|
||||
Shutdown(DistributedInput::DistributedInputTransportBase::GetInstance().sessionId_);
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -125,5 +145,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
OHOS::DistributedHardware::OnSessionClosedFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::EraseSessionIdFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::InitFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::ReleaseFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::CreateClientSocketFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user