1190978c3Sopenharmony_ci/*
2190978c3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3190978c3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4190978c3Sopenharmony_ci * you may not use this file except in compliance with the License.
5190978c3Sopenharmony_ci * You may obtain a copy of the License at
6190978c3Sopenharmony_ci *
7190978c3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8190978c3Sopenharmony_ci *
9190978c3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10190978c3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11190978c3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12190978c3Sopenharmony_ci * See the License for the specific language governing permissions and
13190978c3Sopenharmony_ci * limitations under the License.
14190978c3Sopenharmony_ci */
15190978c3Sopenharmony_ci
16190978c3Sopenharmony_ci#include "updateserviceunregisterupdatecallback_fuzzer.h"
17190978c3Sopenharmony_ci
18190978c3Sopenharmony_ciusing namespace OHOS::UpdateEngine;
19190978c3Sopenharmony_ci
20190978c3Sopenharmony_cinamespace OHOS {
21190978c3Sopenharmony_cibool FuzzUpdateServiceUnregisterUpdateCallback(const uint8_t* data, size_t size)
22190978c3Sopenharmony_ci{
23190978c3Sopenharmony_ci    if (size < FUZZ_DATA_LEN) {
24190978c3Sopenharmony_ci        return false;
25190978c3Sopenharmony_ci    }
26190978c3Sopenharmony_ci
27190978c3Sopenharmony_ci    if (!DelayedSingleton<FuzztestHelper>::GetInstance()->TrySetData(data, size)) {
28190978c3Sopenharmony_ci        return false;
29190978c3Sopenharmony_ci    }
30190978c3Sopenharmony_ci
31190978c3Sopenharmony_ci    return UpdateServiceKits::GetInstance().UnregisterUpdateCallback(
32190978c3Sopenharmony_ci        DelayedSingleton<FuzztestHelper>::GetInstance()->BuildUpgradeInfo()) == 0;
33190978c3Sopenharmony_ci}
34190978c3Sopenharmony_ci}
35190978c3Sopenharmony_ci
36190978c3Sopenharmony_ci/* Fuzzer entry point */
37190978c3Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
38190978c3Sopenharmony_ci{
39190978c3Sopenharmony_ci    /* Run your code on data */
40190978c3Sopenharmony_ci    OHOS::FuzzUpdateServiceUnregisterUpdateCallback(data, size);
41190978c3Sopenharmony_ci    return 0;
42190978c3Sopenharmony_ci}
43