1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * miscservices under the License is miscservices on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "screenlocksendscreenlockevent_fuzzer.h"
17 
18 #include <cstddef>
19 #include <cstdint>
20 #include <string_ex.h>
21 
22 #include "screenlock_server_ipc_interface_code.h"
23 #include "screenlock_service_fuzz_utils.h"
24 #include "screenlock_system_ability.h"
25 
26 using namespace OHOS::ScreenLock;
27 
28 namespace OHOS {
29 constexpr int32_t THRESHOLD = 4;
30 } // namespace OHOS
31 
32 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)33 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
34 {
35     if (size < OHOS::THRESHOLD) {
36         return 0;
37     }
38 
39     /* Run your code on data */
40     OHOS::ScreenlockServiceFuzzUtils::OnRemoteRequestTest(
41         static_cast<uint32_t>(ScreenLockServerIpcInterfaceCode::SEND_SCREENLOCK_EVENT), data, size);
42     ScreenLockSystemAbility::GetInstance()->ResetFfrtQueue();
43     return 0;
44 }