diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 2607a305663848ed3c5a4837767bb1dc869ee5d0..233454e05323dd6603b768aa626235dace696f52 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -722,6 +722,7 @@ public: #endif void OnResourceRemove(int32_t userId); void OnBundleDataCleared(const sptr &bundleOption); + void OnBundleChcheCleared(const sptr &bundleOption); // Distributed KvStore diff --git a/services/ans/include/interface_system_event.h b/services/ans/include/interface_system_event.h index 7be3c05d803e62da8270d4193224db202444aa18..4cbf26123aa1cd0b8787d05c2dff0155929cf021 100644 --- a/services/ans/include/interface_system_event.h +++ b/services/ans/include/interface_system_event.h @@ -31,6 +31,7 @@ struct ISystemEvent { #endif std::function onResourceRemove; std::function &)> onBundleDataCleared; + std::function &)> onBundleCacheCleared; }; } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc2e518c3e832150ea48f5dfbe5f74507..7eba3342ce268a6ae6ecb8f4672ad1ae7c12a598 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -281,6 +281,7 @@ AdvancedNotificationService::AdvancedNotificationService() #endif std::bind(&AdvancedNotificationService::OnResourceRemove, this, std::placeholders::_1), std::bind(&AdvancedNotificationService::OnBundleDataCleared, this, std::placeholders::_1), + std::bind(&AdvancedNotificationService::OnBundleCacheCleared, this, std::placeholders::_1), }; systemEventObserver_ = std::make_shared(iSystemEvent); @@ -3407,6 +3408,11 @@ void AdvancedNotificationService::OnBundleDataCleared(const sptr &bundleOption) +{ + OnBundleDataCleared(bundleOption); +} + void AdvancedNotificationService::GetDisplayPosition( int& offsetX, int& offsetY, int& width, int& height, bool& wideScreen) { diff --git a/services/ans/src/reminder_event_manager.cpp b/services/ans/src/reminder_event_manager.cpp index ff0cdc5c49bbf9d16a4cff0f31e3fc329df9821c..656a44146473ef0a75298b132301eeb89d148b0c 100644 --- a/services/ans/src/reminder_event_manager.cpp +++ b/services/ans/src/reminder_event_manager.cpp @@ -44,6 +44,7 @@ void ReminderEventManager::init(std::shared_ptr &reminderDa matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_BOOT_COMPLETED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED); + matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_CACHE_CLEARED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_RESTARTED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_TIMEZONE_CHANGED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_TIME_CHANGED); @@ -121,6 +122,10 @@ void ReminderEventManager::ReminderEventSubscriber::OnReceiveEvent(const EventFw HandlePackageRemove(want); return; } + if (action == CommonEventSupport::COMMON_EVENT_PACKAGE_CACHE_CLEARED) { + HandlePackageRemove(want); + return; + } if (action == CommonEventSupport::COMMON_EVENT_PACKAGE_RESTARTED) { HandleProcessDied(want); return; diff --git a/services/ans/src/system_event_observer.cpp b/services/ans/src/system_event_observer.cpp index 8ada7d50d94c1be5fa024df53fadb8ad52c624e7..86d2d3ac13041bc4277ac167045ac6c3486237f7 100644 --- a/services/ans/src/system_event_observer.cpp +++ b/services/ans/src/system_event_observer.cpp @@ -34,6 +34,7 @@ SystemEventObserver::SystemEventObserver(const ISystemEvent &callbacks) : callba matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_REMOVED); matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED); + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CACHE_CLEARED); EventFwk::CommonEventSubscribeInfo commonEventSubscribeInfo(matchingSkills); subscriber_ = std::make_shared( @@ -95,6 +96,13 @@ void SystemEventObserver::OnReceiveEvent(const EventFwk::CommonEventData &data) callbacks_.onBundleDataCleared(bundleOption); } } + } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CACHE_CLEARED) { + if (callbacks_.onBundleCacheCleared != nullptr) { + sptr bundleOption = GetBundleOption(want); + if (bundleOption != nullptr) { + callbacks_.onBundleCacheCleared(bundleOption); + } + } } } } // namespace Notification