From 4e81bb5e41f088f0456be14addb2ac06d1e12ac8 Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Fri, 17 Jun 2022 11:13:58 +0800 Subject: [PATCH] IssueNo: #I5CJ49:add COMMON_EVENT_PACKAGE_CACHE_CLEARED Description: add COMMON_EVENT_PACKAGE_CACHE_CLEARED Sig:SIG_ApplicaitonFramework Feature or Bugfix:Feature Binary Source:No Signed-off-by: wangtiantian --- services/ans/include/advanced_notification_service.h | 1 + services/ans/include/interface_system_event.h | 1 + services/ans/src/advanced_notification_service.cpp | 6 ++++++ services/ans/src/reminder_event_manager.cpp | 5 +++++ services/ans/src/system_event_observer.cpp | 8 ++++++++ 5 files changed, 21 insertions(+) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 2607a3056..233454e05 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 7be3c05d8..4cbf26123 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 77d4781dc..7eba3342c 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 ff0cdc5c4..656a44146 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 8ada7d50d..86d2d3ac1 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 -- Gitee