diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index 38c75911cbd9cc736365013703d91c943529538c..ce40019bc038ff5bd7a47f72f3597bba2294ea1e 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -79,6 +79,7 @@ ohos_shared_library("libans") { "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", + "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", "multimedia_image_standard:image_native", "multimedia_media_standard:media_client", diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index a5dd2291e6a432ac6ab4d8e05a6be904c61cabd6..855867a7aaa32f9a667a1d1067654244ce3818ca 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -810,6 +810,7 @@ private: sptr &targetBundle); bool PublishSlotChangeCommonEvent( const sptr &bundleOption, const NotificationConstant::SlotType &slotType); + void ReportHasSeenEvent(const int32_t userId, const std::string &bundleName); private: static sptr instance_; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 2ebdcdd1e96921fe01baedb63f34864ba4ad169f..3d82e40b62e42aee9417affda41ba25b7bf7a3cd 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -29,6 +29,7 @@ #include "ans_watchdog.h" #include "ans_permission_def.h" #include "bundle_manager_helper.h" +#include "bundle_active_client.h" #include "common_event_manager.h" #include "common_event_support.h" #include "display_manager.h" @@ -477,9 +478,16 @@ ErrCode AdvancedNotificationService::Publish(const std::string &label, const spt if (result != ERR_OK) { return result; } + ReportHasSeenEvent(request->GetCreatorUserId(), bundleOption->GetBundleName()); return PublishPreparedNotification(request, bundleOption); } +void AdvancedNotificationService::ReportHasSeenEvent(const int32_t userId, const std::string &bundleName) +{ + DeviceUsageStats::BundleActiveEvent event(DeviceUsageStats::BundleActiveEvent::NOTIFICATION_SEEN, bundleName); + DeviceUsageStats::BundleActiveClient::GetInstance().ReportEvent(event, userId); +} + bool AdvancedNotificationService::IsNotificationExists(const std::string &key) { bool isExists = false; diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 694f0a71b40d0de7b45f57d7713010f50b47bfde..dfe7650eb4f8316db8404a068fe8b30e847ff229 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -85,6 +85,7 @@ ohos_unittest("ans_unit_test") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "common_event_service:cesfwk_innerkits", + "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", "hitrace_native:libhitrace", diff --git a/services/test/moduletest/BUILD.gn b/services/test/moduletest/BUILD.gn index 897b4f03bbf38583f4a4ece0b2c415fc4e1cefcf..73f8e937de560e30dd6b74002af078302a96b94a 100644 --- a/services/test/moduletest/BUILD.gn +++ b/services/test/moduletest/BUILD.gn @@ -71,6 +71,7 @@ ohos_moduletest("ans_module_test") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "common_event_service:cesfwk_innerkits", + "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", "hitrace_native:libhitrace",