/* * Copyright (c) 2023 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include "reminder_agent_service.h" #include "reminderservice_fuzzer.h" #include "ans_permission_def.h" constexpr uint8_t SLOT_TYPE_NUM = 5; namespace OHOS { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { auto service = std::make_shared(); std::string stringData = fuzzData->ConsumeRandomLengthString(); int32_t userId = fuzzData->ConsumeIntegral(); Notification::ReminderRequest reminder; int32_t reminderId2 = 0; service->PublishReminder(reminder, reminderId2); int32_t reminderId = fuzzData->ConsumeIntegral(); service->CancelReminder(reminderId); std::vector reminders; service->GetValidReminders(reminders); service->CancelAllReminders(); int64_t excludeDate = fuzzData->ConsumeIntegral(); service->AddExcludeDate(reminderId, excludeDate); service->DelExcludeDates(reminderId); std::vector excludeDates; service->GetExcludeDates(reminderId, excludeDates); return true; } } /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); std::vector requestPermission = { OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION }; SystemHapTokenGet(requestPermission); OHOS::DoSomethingInterestingWithMyAPI(&fdp); return 0; }