diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp index f831c24003ada502461dab24ddf78c490f02ec86..1adb750ef1e422ec39a9c1eef8697d7bba942c08 100644 --- a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + int32_t id = fuzzData->ConsumeIntegral(); + service->CancelContinuousTaskNotification(stringData, id); return true; } } @@ -33,6 +39,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp index ee5e5168e8a53e7b7a6aec9503bce3b874995a95..e15cb2dfe4d05c48be04dd80b647a8d8e61e4553 100644 --- a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp @@ -15,6 +15,7 @@ #include "service_canpopenablenotificationdialog_fuzzer.h" #include +#include "ans_dialog_callback_proxy.h" #include "advanced_notification_service.h" #include "ans_permission_def.h" #include "mock_notification_request.h" @@ -23,6 +24,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + bool enable = fuzzData->ConsumeBool(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + sptr callback = new AnsDialogCallbackProxy(nullptr); + service->CanPopEnableNotificationDialog(callback, enable, stringData); return true; } } @@ -33,6 +41,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp index f20581c84556e20722f789b15cd76a8a43bc39ee..6870c350406cf04e4a6ad6b789c45b473299090f 100644 --- a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + int32_t intData = fuzzData->ConsumeIntegral(); + service->Delete(stringData, intData); return true; } } @@ -33,6 +39,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp index 3c1e1beba36f69d16850c12e6d46c6ed4792a2f8..1682b7da1ccbfb15ee9d0746d811c4436d2ff0dd 100644 --- a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp @@ -23,6 +23,11 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + sptr bundle = ObjectBuilder::Build(fuzzData); + service->DeleteByBundle(bundle); return true; } } @@ -33,6 +38,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp index 9ce78257625c57a7d7dbd440415c332314377cf7..a4847117b5a818665a3cfaa24a607dfd7ca9f29d 100644 --- a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp @@ -23,6 +23,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + sptr request = ObjectBuilder::Build(fuzzData); + std::vector> notifications = { request }; + service->GetActiveNotifications(notifications, stringData); return true; } } @@ -33,6 +40,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp index 10f2c6df0373150628ac165a9e458be694ac4d02..f701790436ff4adf4867a9151262fd3ae3e289a0 100644 --- a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp @@ -23,6 +23,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + int32_t intData = fuzzData->ConsumeIntegral(); + sptr notification = ObjectBuilder::Build(fuzzData); + std::vector> notifications = { notification }; + service->GetAllNotificationsBySlotType(notifications, intData); return true; } } @@ -33,6 +40,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp index 2ba549f41d35d1dac6af32a87af0fe1c16097df2..b3650758cc1852a6db4545c3890d9f8a2a01d11f 100644 --- a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp @@ -23,6 +23,11 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + int32_t intData = fuzzData->ConsumeIntegral(); + service->GetDeviceRemindType(intData); return true; } } @@ -33,6 +38,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp index 55b275228d0ec58a968f3118383789409123f2db..56fe26b2ddf353fbf62a6ca6ce3cb0d204cfb837 100644 --- a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + sptr request = ObjectBuilder::Build(fuzzData); + service->PublishAsBundleWithMaxCapacity(request, stringData); return true; } } @@ -33,6 +39,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp index e4b02db214ec01c4c7deb3663ca62aaaffccc7ea..371e22ca8af74ceb87c8b7f3000b6271a09f2539 100644 --- a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp @@ -23,6 +23,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + sptr request = ObjectBuilder::Build(fuzzData); + std::vector> notifications = { request }; + service->PublishWithMaxCapacity(stringData, request); return true; } } @@ -33,6 +40,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp index 8be81f13c4b17068c5ada65fab67bf1e68078336..a9750140061bcc5577ef86ebcab151efcdefcf20 100644 --- a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp @@ -23,6 +23,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + int32_t intData = fuzzData->ConsumeIntegral(); + bool boolData = fuzzData->ConsumeBool(); + service->SetDistributedEnabledBySlot(intData, stringData, boolData); return true; } } @@ -33,6 +40,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp index 0f8c4f830395c2b977090097800aa6f214b47eb5..89b09e8a749d19e279b9640176ad498a82c9f322 100644 --- a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + int32_t intData = fuzzData->ConsumeIntegral(); + bool booData = fuzzData->ConsumeBool(); + service->SetNotificationsEnabledByUser(intData, booData); return true; } } @@ -33,6 +39,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp index e4feac67ec5072a41e50259139f5300141ec481f..7a2d77f040230a516a75848f253c3c5b2edcf11e 100644 --- a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + service->InitPublishProcess(); + service->CreateDialogManager(); + std::string stringData = fuzzData->ConsumeRandomLengthString(); + bool enabled = fuzzData->ConsumeBool(); + service->SetNotificationsEnabledForAllBundles(stringData, enabled); return true; } } @@ -33,6 +39,12 @@ 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 + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; }