diff --git a/frameworks/reminder/src/reminder_request.cpp b/frameworks/reminder/src/reminder_request.cpp index 29832cd80594a2104e18978405451fd74620c058..6254c33e4e85a5f3b684e1b0961a461533754e2a 100644 --- a/frameworks/reminder/src/reminder_request.cpp +++ b/frameworks/reminder/src/reminder_request.cpp @@ -954,6 +954,16 @@ ReminderRequest::RingChannel ReminderRequest::GetRingChannel() const return ringChannel_; } +void ReminderRequest::SetRingLoop(const bool isRingLoop) +{ + isRingLoop_ = isRingLoop; +} + +bool ReminderRequest::IsRingLoop() const +{ + return isRingLoop_; +} + int32_t ReminderRequest::GetUserId() const { return userId_; diff --git a/frameworks/reminder/test/unittest/reminder_request_test.cpp b/frameworks/reminder/test/unittest/reminder_request_test.cpp index 60b27de122c700b5468584625acc3e81c04f3ff9..ff0c017af883b91c26101274da3fadb91fb07a02 100644 --- a/frameworks/reminder/test/unittest/reminder_request_test.cpp +++ b/frameworks/reminder/test/unittest/reminder_request_test.cpp @@ -2409,5 +2409,20 @@ HWTEST_F(ReminderRequestTest, ReminderRequestTest_006, Function | SmallTest | Le child.SetRingChannel(ReminderRequest::RingChannel::MEDIA); EXPECT_EQ(child.GetRingChannel(), ReminderRequest::RingChannel::MEDIA); } + +/** + * @tc.name: ReminderRequestTest_007 + * @tc.desc: Test RingLoop parameters. + * @tc.type: FUNC + * @tc.require: issueI8CDH3 + */ +HWTEST_F(ReminderRequestTest, ReminderRequestTest_007, Function | SmallTest | Level1) +{ + ReminderRequestChild child; + child.SetRingLoop(true); + EXPECT_EQ(child.IsRingLoop(), true); + child.SetRingLoop(false); + EXPECT_EQ(child.IsRingLoop(), false); +} } } diff --git a/interfaces/inner_api/reminder_request.h b/interfaces/inner_api/reminder_request.h index e3e414ec45075742ab5a6e6e716f76b6598a9675..871350ba7361e02055c794e915a8f3d0ac6ce698 100644 --- a/interfaces/inner_api/reminder_request.h +++ b/interfaces/inner_api/reminder_request.h @@ -470,6 +470,12 @@ public: void SetRingChannel(const RingChannel channel); RingChannel GetRingChannel() const; + /** + * @brief Set/Get ring loop. + */ + void SetRingLoop(const bool isRingLoop); + bool IsRingLoop() const; + int32_t GetUserId() const; int32_t GetUid() const; @@ -1176,6 +1182,7 @@ private: int32_t uid_ {-1}; bool isSystemApp_ {false}; bool tapDismissed_ {true}; + bool isRingLoop_ {true}; int64_t autoDeletedTime_ {0}; std::string customButtonUri_ {}; std::string customRingUri_ {}; diff --git a/services/reminder/src/reminder_data_manager.cpp b/services/reminder/src/reminder_data_manager.cpp index d458c550cfa7c659a1f0cbd3366d332bd9b89810..dfdbdd2c20b07593972b99e8a109da67c7660948 100644 --- a/services/reminder/src/reminder_data_manager.cpp +++ b/services/reminder/src/reminder_data_manager.cpp @@ -1644,7 +1644,7 @@ void ReminderDataManager::PlaySoundAndVibration(const sptr &rem (void)format.PutIntValue(Media::PlayerKeys::STREAM_USAGE, STREAM_ALARM); (void)format.PutIntValue(Media::PlayerKeys::RENDERER_FLAG, DEFAULT_VALUE); soundPlayer_->SetParameter(format); - soundPlayer_->SetLooping(true); + soundPlayer_->SetLooping(reminder->IsRingLoop()); soundPlayer_->PrepareAsync(); soundPlayer_->Play(); #endif diff --git a/services/reminder/src/reminder_datashare_helper.cpp b/services/reminder/src/reminder_datashare_helper.cpp index f2b80e60557848808263e1bc87ba099d592cf7da..f3391be916348f3bf9ff421cbf4e233d9700507c 100644 --- a/services/reminder/src/reminder_datashare_helper.cpp +++ b/services/reminder/src/reminder_datashare_helper.cpp @@ -430,6 +430,7 @@ std::map> ReminderDataShareHelper::CreateRemi void ReminderDataShareHelper::InitNormalInfo(sptr& reminder) { reminder->SetRingDuration(0); + reminder->SetRingLoop(true); reminder->InitUserId(curUserId_); reminder->InitUid(uid_); reminder->InitCreatorUid(dataUid_); diff --git a/test/fuzztest/reminderdatamanagercancel_fuzzer/BUILD.gn b/test/fuzztest/reminderdatamanagercancel_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f02a8b996300d388b4576b363bb62bac718e1f4c --- /dev/null +++ b/test/fuzztest/reminderdatamanagercancel_fuzzer/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2024 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. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ReminderDataManagerCancelFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/reminderdatamanagercancel_fuzzer" + + include_dirs = [ + "${component_path}/test/fuzztest/fuzz_common_base", + "${component_path}/services/reminder/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + sources = [ "reminderdatamanagercancel_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_reminder_path}:reminder_innerkits", + "${services_path}/reminder:libreminder_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "data_share:datashare_common", + "ffrt:libffrt", + "hilog:libhilog", + "image_framework:image_native", + "kv_store:distributeddata_inner", + "relational_store:native_rdb", + "time_service:time_client", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ReminderDataManagerCancelFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/reminderdatamanagercancel_fuzzer/corpus/init b/test/fuzztest/reminderdatamanagercancel_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b8e924d6774de162212e1bb67a99520872917d5d --- /dev/null +++ b/test/fuzztest/reminderdatamanagercancel_fuzzer/corpus/init @@ -0,0 +1 @@ +com.test.test060000000100DDC528600000000300000002000000010000000 \ No newline at end of file diff --git a/test/fuzztest/reminderdatamanagercancel_fuzzer/project.xml b/test/fuzztest/reminderdatamanagercancel_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..7133b2b92440904a5ed04b838733acea0f97486a --- /dev/null +++ b/test/fuzztest/reminderdatamanagercancel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.cpp b/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9226800040b4aaa2ca69bc96071a365dae56ac55 --- /dev/null +++ b/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 "reminder_data_manager.h" +#include "reminder_request_timer.h" +#include "reminderdatamanagercancel_fuzzer.h" +#include + +namespace OHOS { + bool DoSomethingInteresting(FuzzedDataProvider* fdp) + { + Notification::ReminderDataManager::InitInstance(); + auto manager = Notification::ReminderDataManager::GetInstance(); + + int32_t userId = fdp->ConsumeIntegral(); + int32_t uid = fdp->ConsumeIntegral(); + int32_t reminderId = fdp->ConsumeIntegral(); + uint64_t date = fdp->ConsumeIntegral(); + uint8_t type = fdp->ConsumeIntegral() % 2; + int32_t callingUid = fdp->ConsumeIntegral(); + bool value = fdp->ConsumeBool(); + std::string bundleName = fdp->ConsumeRandomLengthString(); + manager->CancelAllReminders(bundleName, userId, uid); + manager->CancelReminder(reminderId, callingUid); + manager->CheckExcludeDateParam(reminderId, callingUid); + manager->AddExcludeDate(reminderId, date, callingUid); + manager->DelExcludeDates(reminderId, callingUid); + std::vector dates; + manager->GetExcludeDates(reminderId, callingUid, dates); + std::vector reminders; + manager->GetValidReminders(callingUid, reminders); + manager->OnUserRemove(userId); + manager->OnUserSwitch(userId); + manager->OnProcessDiedLocked(callingUid); + 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); + OHOS::DoSomethingInteresting(&fdp); + return 0; +} diff --git a/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.h b/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..6f667a2ebc1c91edba8f9ade84180aed7cd1bd83 --- /dev/null +++ b/test/fuzztest/reminderdatamanagercancel_fuzzer/reminderdatamanagercancel_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 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. + */ + +#ifndef TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGERCANCEL_FUZZER_H +#define TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGERCANCEL_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "reminderdatamanagercancel_fuzzer" + +#endif // TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGERCANCEL_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/reminderdatamanagerevent_fuzzer/BUILD.gn b/test/fuzztest/reminderdatamanagerevent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dff74f5df9346f9642a7a3c5edd892e12ca32e10 --- /dev/null +++ b/test/fuzztest/reminderdatamanagerevent_fuzzer/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2024 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. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ReminderDataManagerEventFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/reminderdatamanagerevent_fuzzer" + + include_dirs = [ + "${component_path}/test/fuzztest/fuzz_common_base", + "${component_path}/services/reminder/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + sources = [ "reminderdatamanagerevent_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_reminder_path}:reminder_innerkits", + "${services_path}/reminder:libreminder_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "data_share:datashare_common", + "ffrt:libffrt", + "hilog:libhilog", + "image_framework:image_native", + "kv_store:distributeddata_inner", + "relational_store:native_rdb", + "time_service:time_client", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ReminderDataManagerEventFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/reminderdatamanagerevent_fuzzer/corpus/init b/test/fuzztest/reminderdatamanagerevent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..c86439057e68d1829df795ff523dd44806d52780 --- /dev/null +++ b/test/fuzztest/reminderdatamanagerevent_fuzzer/corpus/init @@ -0,0 +1 @@ +6749326A54377050307053307552367A4F34704A060000000100DDC528600000000300000002000000010000000 \ No newline at end of file diff --git a/test/fuzztest/reminderdatamanagerevent_fuzzer/project.xml b/test/fuzztest/reminderdatamanagerevent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..7133b2b92440904a5ed04b838733acea0f97486a --- /dev/null +++ b/test/fuzztest/reminderdatamanagerevent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.cpp b/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..16cb60883727bf071649feb7f202c9b66d0e1e95 --- /dev/null +++ b/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.cpp @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2024 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 "reminder_data_manager.h" +#include "reminder_request_timer.h" +#include "reminderdatamanagerevent_fuzzer.h" +#include + +namespace OHOS { + bool DoSomethingInterestingWithManager(FuzzedDataProvider* fdp) + { + Notification::ReminderDataManager::InitInstance(); + auto manager = Notification::ReminderDataManager::GetInstance(); + + int32_t userId = fdp->ConsumeIntegral(); + int32_t uid = fdp->ConsumeIntegral(); + int32_t reminderId = fdp->ConsumeIntegral(); + uint64_t date = fdp->ConsumeIntegral(); + uint8_t type = fdp->ConsumeIntegral() % 2; + int32_t callingUid = fdp->ConsumeIntegral(); + bool value = fdp->ConsumeBool(); + std::string bundleName = fdp->ConsumeRandomLengthString(); + + EventFwk::Want want; + want.SetParam(Notification::ReminderRequest::PARAM_REMINDER_ID, reminderId); + manager->CloseReminder(want, value); + manager->RefreshRemindersDueToSysTimeChange(type); + manager->ShouldAlert(reminder); + manager->ShowActiveReminder(want); + manager->SnoozeReminder(want); + manager->HandleCustomButtonClick(want); + manager->ClickReminder(want); + manager->TerminateAlerting(want); + return true; + } + + bool DoSomethingInterestingWithReminder(FuzzedDataProvider* fdp) + { + std::string bundleName = fdp->ConsumeRandomLengthString(); + int32_t userId = fdp->ConsumeIntegral(); + int32_t uid = fdp->ConsumeIntegral(); + int32_t reminderId = fdp->ConsumeIntegral(); + bool value = fdp->ConsumeBool(); + int32_t callingUid = fdp->ConsumeIntegral(); + constexpr uint64_t seconds = 1200; + sptr reminder = new Notification::ReminderRequestTimer(seconds); + auto manager = Notification::ReminderDataManager::GetInstance(); + + manager->CancelAllReminders(userId); + manager->CheckUpdateConditions(reminder, Notification::ReminderRequest::ActionButtonType::INVALID, + reminder->GetActionButtons()); + manager->CancelRemindersImplLocked(bundleName, userId, uid, value); + manager->CloseRemindersByGroupId(reminderId, bundleName, bundleName); + manager->CancelNotification(reminder); + manager->CheckReminderLimitExceededLocked(callingUid, reminder); + std::vector> reminders; + manager->GetImmediatelyShowRemindersLocked(reminders); + manager->AddToShowedReminders(reminder); + + manager->IsAllowedNotify(reminder); + manager->PlaySoundAndVibrationLocked(reminder); + manager->PlaySoundAndVibration(reminder); + manager->StopSoundAndVibrationLocked(reminder); + manager->StopSoundAndVibration(reminder); + manager->RemoveFromShowedReminders(reminder); + manager->RemoveReminderLocked(reminderId, false); + manager->SetActiveReminder(reminder); + manager->SetAlertingReminder(reminder); + manager->ShowActiveReminderExtendLocked(reminder, reminders); + + std::vector> extensionReminders; + std::vector> immediatelyReminders; + manager->PublishReminder(reminder, callingUid); + manager->FindReminderRequestLocked(reminderId, false); + manager->HandleImmediatelyShow(immediatelyReminders, value); + int8_t type = fdp->ConsumeIntegral(); + manager->HandleExtensionReminder(extensionReminders, type); + manager->HandleSameNotificationIdShowing(reminder); + manager->IsBelongToSameApp(uid, uid); + manager->CheckIsSameApp(reminder, uid); + manager->ShowReminder(reminder, value, value, value, value); + return true; + } + + bool DoSomethingInteresting1(FuzzedDataProvider* fdp) + { + std::string bundleName = fdp->ConsumeRandomLengthString(); + int32_t id = fdp->ConsumeIntegral(); + int64_t ts = fdp->ConsumeIntegral(); + int32_t reminderId = fdp->ConsumeIntegral(); + bool value = fdp->ConsumeBool(); + int32_t callingUid = fdp->ConsumeIntegral(); + constexpr uint64_t seconds = 1200; + sptr reminder = new Notification::ReminderRequestTimer(seconds); + auto manager = Notification::ReminderDataManager::GetInstance(); + std::map> remindersMap; + manager->OnDataShareUpdate(remindersMap); + manager->HandleAutoDeleteReminder(id, id, ts); + + std::vector> reminders; + manager->UpdateReminderLanguageLocked(id, reminders); + manager->InitShareReminders(value); + manager->UpdateAppDatabase(reminder, Notification::ReminderRequest::ActionButtonType::CLOSE); + DataShare::DataSharePredicates predicates; + std::vector equalToVector; + manager->GenPredicates(predicates, equalToVector); + DataShare::DataShareValuesBucket valuesBucket; + manager->GenValuesBucket(valuesBucket, equalToVector); + manager->CloseReminder(reminder, value); + Notification::ReminderDataManager::TimerType t = Notification::ReminderDataManager::TimerType::ALERTING_TIMER; + manager->CreateTimerInfo(t, reminder); + auto sharedTimerInfo = std::make_shared(); + manager->InitTimerInfo(sharedTimerInfo, reminder, t); + manager->HandleSysTimeChange(reminder); + manager->IsMatched(reminder, id, id, value); + manager->ResetStates(t); + return true; + } + + bool DoSomethingInteresting2(FuzzedDataProvider* fdp) + { + constexpr uint16_t MAX_SECOND = 5; + std::string bundleName = fdp->ConsumeRandomLengthString(); + std::string uri = fdp->ConsumeRandomLengthString(); + int32_t id = fdp->ConsumeIntegral(); + int8_t val = fdp->ConsumeIntegral(); + uint16_t second = fdp->ConsumeIntegral() % MAX_SECOND + 1; + int64_t ts = fdp->ConsumeIntegral(); + int32_t reminderId = fdp->ConsumeIntegral(); + bool value = fdp->ConsumeBool(); + int32_t callingUid = fdp->ConsumeIntegral(); + constexpr uint64_t seconds = 1200; + sptr reminder = new Notification::ReminderRequestTimer(seconds); + auto manager = Notification::ReminderDataManager::GetInstance(); + manager->IsMatchedForGroupIdAndPkgName(reminder, bundleName, uri); + manager->StartExtensionAbility(reminder, 0); + int32_t count = 0; + manager->AsyncStartExtensionAbility(reminder, id, val, count); + manager->SnoozeReminderImpl(reminder); + Notification::ReminderDataManager::TimerType t = Notification::ReminderDataManager::TimerType::ALERTING_TIMER; + manager->StartTimerLocked(reminder, t); + manager->StartTimer(reminder, t); + manager->StopAlertingReminder(reminder); + manager->StopTimer(t); + manager->StopTimerLocked(t); + manager->TerminateAlerting(reminder, uri); + manager->TerminateAlerting(second, reminder); + manager->UpdateAndSaveReminderLocked(reminder); + Notification::ReminderDataManager::cmp(reminder, reminder); + manager->CheckNeedNotifyStatus(reminder, Notification::ReminderRequest::ActionButtonType::INVALID); + manager->GetFullPath(uri); + manager->IsActionButtonDataShareValid(reminder, static_cast(id)); + manager->GetResourceMgr(bundleName, id); + Global::Resource::ResourceManager::RawFileDescriptor desc; + manager->GetCustomRingFileDesc(reminder, desc); + manager->CloseCustomRingFileDesc(id, uri); + manager->ReportSysEvent(reminder); + std::map> reminders; + manager->UpdateShareReminders(reminders); + std::unordered_map limits; + int32_t totalCount = 0; + manager->CheckShowLimit(limits, totalCount, reminder); + 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); + OHOS::DoSomethingInterestingWithManager(&fdp); + OHOS::DoSomethingInterestingWithReminder(&fdp); + OHOS::DoSomethingInteresting1(&fdp); + OHOS::DoSomethingInteresting2(&fdp); + return 0; +} diff --git a/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.h b/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..91f91b6b67528ce9b503a88dd6e14f972dacdef6 --- /dev/null +++ b/test/fuzztest/reminderdatamanagerevent_fuzzer/reminderdatamanagerevent_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 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. + */ + +#ifndef TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGEREVENT_FUZZER_H +#define TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGEREVENT_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "reminderdatamanagerevent_fuzzer" + +#endif // TEST_FUZZTEST_REMINDERDATAMANAGER_FUZZER_REMINDERDATAMANAGEREVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/reminderstoreDeleteBase_fuzzer/BUILD.gn b/test/fuzztest/reminderstoreDeleteBase_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b0316c0cb5efdfaf17c223f365f00725e27e4019 --- /dev/null +++ b/test/fuzztest/reminderstoreDeleteBase_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# Copyright (c) 2022 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. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ReminderStoreDeleteBaseFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = "${component_path}/test/fuzztest/reminderstoredeletebase_fuzzer" + + include_dirs = [ + "${component_path}/test/fuzztest/fuzz_common_base", + "${component_path}/services/reminder/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + sources = [ "reminderstoredeletebase_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_reminder_path}:reminder_innerkits", + "${services_path}/reminder:libreminder_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hilog:libhilog", + "image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ReminderStoreDeleteBaseFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/reminderstoreDeleteBase_fuzzer/corpus/init b/test/fuzztest/reminderstoreDeleteBase_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..882c6f8d537024bb359abe242e7750ff22c3eb7f --- /dev/null +++ b/test/fuzztest/reminderstoreDeleteBase_fuzzer/corpus/init @@ -0,0 +1 @@ +100000006749326A54377050307053307552367A4F34704A \ No newline at end of file diff --git a/test/fuzztest/reminderstoreDeleteBase_fuzzer/project.xml b/test/fuzztest/reminderstoreDeleteBase_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/reminderstoreDeleteBase_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.cpp b/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f0868236dd291fbafe920ac1b200d9830cf99208 --- /dev/null +++ b/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 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 "reminder_store.h" +#include "reminderstoredeletebase_fuzzer.h" +#include "abs_shared_result_set.h" +#include "reminder_request_alarm.h" +#include "reminder_request_timer.h" +#include "reminder_store_strategy.h" +#include "reminder_request_calendar.h" +#include + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider* fdp) + { + Notification::ReminderStore reminderStore; + reminderStore.Init(); + std::string stringData = fdp->ConsumeRandomLengthString(); + int32_t oldVersion = fdp->ConsumeIntegral(); + reminderStore.DeleteUser(oldVersion); + reminderStore.DeleteBase(stringData); + 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); + OHOS::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.h b/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..17a4e0b3d97cfdcb72fd90da42f43ef0292050a4 --- /dev/null +++ b/test/fuzztest/reminderstoreDeleteBase_fuzzer/reminderstoredeletebase_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETEBASE_FUZZER_H +#define TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETEBASE_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "reminderstoredeletebase_fuzzer" + +#endif // TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETEBASE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/reminderstoreDelete_fuzzer/BUILD.gn b/test/fuzztest/reminderstoreDelete_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b92bb4601a5c8da1c1f2f717d7ed5bd17caafe35 --- /dev/null +++ b/test/fuzztest/reminderstoreDelete_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# Copyright (c) 2022 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. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ReminderStoreDeleteFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = "${component_path}/test/fuzztest/reminderstoredelete_fuzzer" + + include_dirs = [ + "${component_path}/test/fuzztest/fuzz_common_base", + "${component_path}/services/reminder/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + sources = [ "reminderstoredelete_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_reminder_path}:reminder_innerkits", + "${services_path}/reminder:libreminder_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hilog:libhilog", + "image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ReminderStoreDeleteFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/reminderstoreDelete_fuzzer/corpus/init b/test/fuzztest/reminderstoreDelete_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..0587b3c58cf01352ac5c39f51722cc16802745ca --- /dev/null +++ b/test/fuzztest/reminderstoreDelete_fuzzer/corpus/init @@ -0,0 +1 @@ +20000000100000006749326A54377050307053307552367A4F34704A \ No newline at end of file diff --git a/test/fuzztest/reminderstoreDelete_fuzzer/project.xml b/test/fuzztest/reminderstoreDelete_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/reminderstoreDelete_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.cpp b/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6dd8367ea6b15b66ed3678773e842eb2edd11a51 --- /dev/null +++ b/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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 "reminder_store.h" +#include "reminderstoredelete_fuzzer.h" +#include "abs_shared_result_set.h" +#include "reminder_request_alarm.h" +#include "reminder_request_timer.h" +#include "reminder_store_strategy.h" +#include "reminder_request_calendar.h" +#include + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider* fdp) + { + Notification::ReminderStore reminderStore; + reminderStore.Init(); + std::string stringData = fdp->ConsumeRandomLengthString(); + int32_t userId = fdp->ConsumeIntegral(); + int32_t uid = fdp->ConsumeIntegral(); + reminderStore.Delete(uid); + reminderStore.Delete(stringData, userId, uid); + 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); + OHOS::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.h b/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7cce03b284060d283ea28c02d12ee2436112c0df --- /dev/null +++ b/test/fuzztest/reminderstoreDelete_fuzzer/reminderstoredelete_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETE_FUZZER_H +#define TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETE_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "reminderstoredelete_fuzzer" + +#endif // TEST_FUZZTEST_REMINDERSTORE_FUZZER_REMINDERSTOREDELETE_FUZZER_H \ No newline at end of file