From c50526b21e1f679cd9d4f9a495dd78b6aeffbd50 Mon Sep 17 00:00:00 2001 From: wyuanchao Date: Mon, 30 May 2022 14:47:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BA=94=E7=94=A8=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E7=BB=9F=E8=AE=A1=E6=89=93=E6=A1=A9=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wyuanchao --- services/ans/BUILD.gn | 1 + services/ans/src/advanced_notification_service.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index 38c75911c..ce40019bc 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/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 2ebdcdd1e..10838c4ce 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,6 +478,10 @@ ErrCode AdvancedNotificationService::Publish(const std::string &label, const spt if (result != ERR_OK) { return result; } + int32_t userId = request->GetCreatorUserId(); + std::string bundleName = bundleOption->GetBundleName(); + DeviceUsageStats::BundleActiveEvent event(DeviceUsageStats::BundleActiveEvent::NOTIFICATION_SEEN, bundleName); + DeviceUsageStats::BundleActiveClient::GetInstance().ReportEvent(event, userId); return PublishPreparedNotification(request, bundleOption); } -- Gitee From da2f6fdba12889c45d85341ee231fcdbc23c7f1e Mon Sep 17 00:00:00 2001 From: wyuanchao Date: Mon, 30 May 2022 19:18:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=BA=94=E7=94=A8=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E7=BB=9F=E8=AE=A1=E6=89=93=E6=A1=A9=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wyuanchao --- services/ans/test/unittest/BUILD.gn | 1 + services/test/moduletest/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 694f0a71b..dfe7650eb 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 897b4f03b..73f8e937d 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", -- Gitee From de7ea67bac13882fee77669a857d5a6aabbc33dd Mon Sep 17 00:00:00 2001 From: wyuanchao Date: Mon, 30 May 2022 22:16:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wyuanchao --- services/ans/include/advanced_notification_service.h | 1 + services/ans/src/advanced_notification_service.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index a5dd2291e..855867a7a 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 10838c4ce..3d82e40b6 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -478,11 +478,14 @@ ErrCode AdvancedNotificationService::Publish(const std::string &label, const spt if (result != ERR_OK) { return result; } - int32_t userId = request->GetCreatorUserId(); - std::string bundleName = bundleOption->GetBundleName(); + 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); - return PublishPreparedNotification(request, bundleOption); } bool AdvancedNotificationService::IsNotificationExists(const std::string &key) -- Gitee