12d4d9a4dSopenharmony_ci/* 22d4d9a4dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 32d4d9a4dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 42d4d9a4dSopenharmony_ci * you may not use this file except in compliance with the License. 52d4d9a4dSopenharmony_ci * You may obtain a copy of the License at 62d4d9a4dSopenharmony_ci * 72d4d9a4dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 82d4d9a4dSopenharmony_ci * 92d4d9a4dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 102d4d9a4dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 112d4d9a4dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122d4d9a4dSopenharmony_ci * See the License for the specific language governing permissions and 132d4d9a4dSopenharmony_ci * limitations under the License. 142d4d9a4dSopenharmony_ci */ 152d4d9a4dSopenharmony_ci 162d4d9a4dSopenharmony_ci#include "dinputsubscribelocaldh_fuzzer.h" 172d4d9a4dSopenharmony_ci 182d4d9a4dSopenharmony_ci#include <cstddef> 192d4d9a4dSopenharmony_ci#include <cstdint> 202d4d9a4dSopenharmony_ci#include <functional> 212d4d9a4dSopenharmony_ci#include <iostream> 222d4d9a4dSopenharmony_ci#include <thread> 232d4d9a4dSopenharmony_ci 242d4d9a4dSopenharmony_ci#include <refbase.h> 252d4d9a4dSopenharmony_ci 262d4d9a4dSopenharmony_ci#include "constants_dinput.h" 272d4d9a4dSopenharmony_ci#include "distributed_input_handler.h" 282d4d9a4dSopenharmony_ci#include "distributed_input_kit.h" 292d4d9a4dSopenharmony_ci#include "distributed_input_sink_handler.h" 302d4d9a4dSopenharmony_ci#include "i_distributed_sink_input.h" 312d4d9a4dSopenharmony_ci 322d4d9a4dSopenharmony_cinamespace OHOS { 332d4d9a4dSopenharmony_cinamespace DistributedHardware { 342d4d9a4dSopenharmony_civoid SubscribeLocalHardwareFuzzTest(const uint8_t *data, size_t size) 352d4d9a4dSopenharmony_ci{ 362d4d9a4dSopenharmony_ci if ((data == nullptr) || (size == 0)) { 372d4d9a4dSopenharmony_ci return; 382d4d9a4dSopenharmony_ci } 392d4d9a4dSopenharmony_ci std::string dhId(reinterpret_cast<const char*>(data), size); 402d4d9a4dSopenharmony_ci std::string params(reinterpret_cast<const char*>(data), size); 412d4d9a4dSopenharmony_ci DistributedInput::DistributedInputSinkHandler::GetInstance().SubscribeLocalHardware(dhId, params); 422d4d9a4dSopenharmony_ci 432d4d9a4dSopenharmony_ci DistributedInput::DistributedInputSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); 442d4d9a4dSopenharmony_ci} 452d4d9a4dSopenharmony_ci} // namespace DistributedHardware 462d4d9a4dSopenharmony_ci} // namespace OHOS 472d4d9a4dSopenharmony_ci 482d4d9a4dSopenharmony_ci/* Fuzzer entry point */ 492d4d9a4dSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 502d4d9a4dSopenharmony_ci{ 512d4d9a4dSopenharmony_ci /* Run your code on data */ 522d4d9a4dSopenharmony_ci OHOS::DistributedHardware::SubscribeLocalHardwareFuzzTest(data, size); 532d4d9a4dSopenharmony_ci return 0; 542d4d9a4dSopenharmony_ci}