From f31e7a077bd8a6e32bd504766e55263ad7471d18 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 20 Jun 2022 11:16:57 +0800 Subject: [PATCH 01/14] notification change publish common event Signed-off-by: fangJinliang1 Change-Id: I39196840b3c79e15ef9abe574c1b5b456901029d --- services/ans/src/advanced_notification_service.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc..f8ba47499 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1581,6 +1581,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( } if (result == ERR_OK) { NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); + PublishSlotChangeCommonEvent(bundle); } } else { // Remote revice -- Gitee From 6c43d49815807eb94ef50a7fadf12d57fa51cca4 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 20 Jun 2022 11:16:57 +0800 Subject: [PATCH 02/14] notification change publish common event Signed-off-by: fangJinliang1 Change-Id: I39196840b3c79e15ef9abe574c1b5b456901029d Signed-off-by: fangJinliang1 --- services/ans/src/advanced_notification_service.cpp | 1 + .../notification_services_test/notification_service_test.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc..f8ba47499 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1581,6 +1581,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( } if (result == ERR_OK) { NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); + PublishSlotChangeCommonEvent(bundle); } } else { // Remote revice diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 2cb35a80a..4968862a2 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -249,7 +249,6 @@ BENCHMARK_F(BenchmarkNotificationService, CancelNotificationTestCase001)(benchma state.SkipWithError("CancelNotificationTestCase001 publish failed."); } advancedNotificationService_->Cancel(id, label); - id++; } } -- Gitee From c34d7f09e25b294a548bbfba879a6ee2c6c70172 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 20 Jun 2022 11:16:57 +0800 Subject: [PATCH 03/14] notification change publish common event Signed-off-by: fangJinliang1 Change-Id: I39196840b3c79e15ef9abe574c1b5b456901029d Signed-off-by: fangJinliang1 --- services/ans/src/advanced_notification_service.cpp | 1 + .../test/unittest/mock/mock_distributed_kv_data_manager.cpp | 1 - .../notification_services_test/notification_service_test.cpp | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc..f8ba47499 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1581,6 +1581,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( } if (result == ERR_OK) { NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); + PublishSlotChangeCommonEvent(bundle); } } else { // Remote revice diff --git a/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp b/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp index 74d6b8dcf..bc6e2b82a 100644 --- a/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp +++ b/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp @@ -15,7 +15,6 @@ #include "distributed_kv_data_manager.h" -#include "mock_single_kv_store.h" namespace OHOS { namespace DistributedKv { diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 2cb35a80a..4968862a2 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -249,7 +249,6 @@ BENCHMARK_F(BenchmarkNotificationService, CancelNotificationTestCase001)(benchma state.SkipWithError("CancelNotificationTestCase001 publish failed."); } advancedNotificationService_->Cancel(id, label); - id++; } } -- Gitee From 4ca8c7c1a0c3d242f1465a58c663bd651f5db266 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 20 Jun 2022 11:16:57 +0800 Subject: [PATCH 04/14] notification change publish common event Signed-off-by: fangJinliang1 Change-Id: I39196840b3c79e15ef9abe574c1b5b456901029d Signed-off-by: fangJinliang1 --- services/ans/src/advanced_notification_service.cpp | 1 + .../notification_services_test/notification_service_test.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc..f8ba47499 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1581,6 +1581,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( } if (result == ERR_OK) { NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); + PublishSlotChangeCommonEvent(bundle); } } else { // Remote revice diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 2cb35a80a..4968862a2 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -249,7 +249,6 @@ BENCHMARK_F(BenchmarkNotificationService, CancelNotificationTestCase001)(benchma state.SkipWithError("CancelNotificationTestCase001 publish failed."); } advancedNotificationService_->Cancel(id, label); - id++; } } -- Gitee From 3e64473b723a18eb08dd0fe3d05cf914d92b78c5 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 20 Jun 2022 11:16:57 +0800 Subject: [PATCH 05/14] notification change publish common event Signed-off-by: fangJinliang1 Change-Id: I39196840b3c79e15ef9abe574c1b5b456901029d Signed-off-by: fangJinliang1 --- services/ans/src/advanced_notification_service.cpp | 5 ++++- .../notification_services_test/notification_service_test.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 77d4781dc..e8e0a4b55 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -460,7 +460,9 @@ ErrCode AdvancedNotificationService::PublishPreparedNotification( ReportInfoToResourceSchedule(request->GetCreatorUserId(), bundleOption->GetBundleName()); NotificationSubscriberManager::GetInstance()->NotifyConsumed(record->notification, sortingMap); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedPublish(bundleOption, record); + if (!request->IsAgentNotification()) { + DoDistributedPublish(bundleOption, record); + } #endif })); return result; @@ -1581,6 +1583,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( } if (result == ERR_OK) { NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); + PublishSlotChangeCommonEvent(bundle); } } else { // Remote revice diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 2cb35a80a..4968862a2 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -249,7 +249,6 @@ BENCHMARK_F(BenchmarkNotificationService, CancelNotificationTestCase001)(benchma state.SkipWithError("CancelNotificationTestCase001 publish failed."); } advancedNotificationService_->Cancel(id, label); - id++; } } -- Gitee From e43183218422a4b9b6c854215c5d48d5d4a2a528 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Sat, 2 Jul 2022 11:43:48 +0800 Subject: [PATCH 06/14] distributed remove notification Signed-off-by: fangJinliang1 Change-Id: I799f10893670d73c85557c5e32e593428695dd81 --- .../include/advanced_notification_service.h | 4 +- services/ans/include/notification_record.h | 1 + .../ans/src/advanced_notification_service.cpp | 62 ++++++++++++------- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 5d831e96d..5423d5f6e 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -812,8 +812,8 @@ private: NotificationConstant::RemindType GetRemindType(); ErrCode DoDistributedPublish( const sptr bundleOption, const std::shared_ptr record); - ErrCode DoDistributedDelete(const std::string deviceId, const sptr notification); - std::string GetNotificationDeviceId(const std::string &key); + ErrCode DoDistributedDelete(const std::string deviceId, const std::string bundleName, const sptr notification); + void GetDistributedInfo(const std::string &key, std::string &deviceId, std::string &bundleName); bool CheckDistributedNotificationType(const sptr &request); void OnDistributedPublish( const std::string &deviceId, const std::string &bundleName, sptr &request); diff --git a/services/ans/include/notification_record.h b/services/ans/include/notification_record.h index d14c3d36f..f80c6c703 100644 --- a/services/ans/include/notification_record.h +++ b/services/ans/include/notification_record.h @@ -34,6 +34,7 @@ struct NotificationRecord { sptr slot; #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED std::string deviceId; + std::string bundleName; #endif // DISTRIBUTED_NOTIFICATION_SUPPORTED }; } // namespace Notification diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index c05880924..3a5c900eb 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -411,7 +411,7 @@ ErrCode AdvancedNotificationService::CancelPreparedNotification( sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete("", notification); + DoDistributedDelete("", "", notification); #endif } })); @@ -644,7 +644,9 @@ ErrCode AdvancedNotificationService::CancelAll() std::vector keys = GetNotificationKeys(bundleOption); for (auto key : keys) { #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif result = RemoveFromNotificationList(key, notification, true); if (result != ERR_OK) { @@ -657,7 +659,7 @@ ErrCode AdvancedNotificationService::CancelAll() sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } } @@ -983,7 +985,9 @@ ErrCode AdvancedNotificationService::Delete(const std::string &key) handler_->PostSyncTask(std::bind([&]() { sptr notification = nullptr; #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif result = RemoveFromNotificationList(key, notification); if (result != ERR_OK) { @@ -996,7 +1000,7 @@ ErrCode AdvancedNotificationService::Delete(const std::string &key) sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } })); @@ -1026,7 +1030,9 @@ ErrCode AdvancedNotificationService::DeleteByBundle(const sptr keys = GetNotificationKeys(bundle); for (auto key : keys) { #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif sptr notification = nullptr; @@ -1041,7 +1047,7 @@ ErrCode AdvancedNotificationService::DeleteByBundle(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } } @@ -1071,7 +1077,9 @@ ErrCode AdvancedNotificationService::DeleteAll() std::vector keys = GetNotificationKeys(nullptr); for (auto key : keys) { #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif sptr notification = nullptr; @@ -1086,7 +1094,7 @@ ErrCode AdvancedNotificationService::DeleteAll() sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } } @@ -2240,7 +2248,7 @@ void AdvancedNotificationService::OnBundleRemoved(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete("", notification); + DoDistributedDelete("", "", notification); #endif } } @@ -2345,6 +2353,7 @@ ErrCode AdvancedNotificationService::RemoveNotification( #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED std::string deviceId; + std::string bundleName; #endif for (auto record : notificationList_) { if ((record->bundleOption->GetBundleName() == bundle->GetBundleName()) && @@ -2359,6 +2368,7 @@ ErrCode AdvancedNotificationService::RemoveNotification( } #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED deviceId = record->deviceId; + bundleName = record->bundleName; #endif notification = record->notification; notificationRequest = record->request; @@ -2374,7 +2384,7 @@ ErrCode AdvancedNotificationService::RemoveNotification( sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } @@ -2428,7 +2438,7 @@ ErrCode AdvancedNotificationService::RemoveAllNotifications(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(record->deviceId, record->notification); + DoDistributedDelete(record->deviceId, record->bundleName, record->notification); #endif } @@ -2505,7 +2515,7 @@ ErrCode AdvancedNotificationService::CancelGroup(const std::string &groupName) sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(record->deviceId, record->notification); + DoDistributedDelete(record->deviceId, record->bundleName, record->notification); #endif } } @@ -2561,7 +2571,7 @@ ErrCode AdvancedNotificationService::RemoveGroupByBundle( sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(record->deviceId, record->notification); + DoDistributedDelete(record->deviceId, record->bundleName, record->notification); #endif } } @@ -2927,14 +2937,16 @@ NotificationConstant::RemindType AdvancedNotificationService::GetRemindType() } } -std::string AdvancedNotificationService::GetNotificationDeviceId(const std::string &key) +std::string AdvancedNotificationService::GetDistributedInfo( + const std::string &key, std::string &deviceId, std::string &bundleName) { for (auto record : notificationList_) { if (record->notification->GetKey() == key) { - return record->deviceId; + deviceId = record->deviceId; + bundleName = record->bundleName; + break; } } - return std::string(); } ErrCode AdvancedNotificationService::DoDistributedPublish( @@ -2970,7 +2982,7 @@ ErrCode AdvancedNotificationService::DoDistributedPublish( } ErrCode AdvancedNotificationService::DoDistributedDelete( - const std::string deviceId, const sptr notification) + const std::string deviceId, const std::string bundleName, const sptr notification) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); if (!notification->GetNotificationRequest().GetNotificationDistributedOptions().IsDistributed()) { @@ -2981,7 +2993,7 @@ ErrCode AdvancedNotificationService::DoDistributedDelete( notification->GetBundleName(), notification->GetLabel(), notification->GetId()); } else { return DistributedNotificationManager::GetInstance()->DeleteRemoteNotification( - deviceId, notification->GetBundleName(), notification->GetLabel(), notification->GetId()); + deviceId, bundleName, notification->GetLabel(), notification->GetId()); } return ERR_OK; @@ -3327,7 +3339,9 @@ ErrCode AdvancedNotificationService::DeleteAllByUser(const int32_t &userId) std::vector keys = GetNotificationKeys(nullptr); for (auto key : keys) { #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif sptr notification = nullptr; @@ -3342,7 +3356,7 @@ ErrCode AdvancedNotificationService::DeleteAllByUser(const int32_t &userId) sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } } @@ -3525,7 +3539,9 @@ void AdvancedNotificationService::OnBundleDataCleared(const sptr keys = GetNotificationKeys(bundleOption); for (auto key : keys) { #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - std::string deviceId = GetNotificationDeviceId(key); + std::string deviceId; + std::string bundleName; + GetDistributedInfo(key, deviceId, bundleName); #endif sptr notification = nullptr; @@ -3540,7 +3556,7 @@ void AdvancedNotificationService::OnBundleDataCleared(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED - DoDistributedDelete(deviceId, notification); + DoDistributedDelete(deviceId, bundleName, notification); #endif } } -- Gitee From 6b6f2ff1256585c3dc1f3142c7c452c8c1c05a6b Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Sat, 2 Jul 2022 11:59:49 +0800 Subject: [PATCH 07/14] mock Signed-off-by: fangjinliang --- .../test/unittest/mock/mock_distributed_kv_data_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp b/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp index bc6e2b82a..74d6b8dcf 100644 --- a/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp +++ b/services/distributed/test/unittest/mock/mock_distributed_kv_data_manager.cpp @@ -15,6 +15,7 @@ #include "distributed_kv_data_manager.h" +#include "mock_single_kv_store.h" namespace OHOS { namespace DistributedKv { -- Gitee From c7c6718ebcb9783e92c591c9f743263f566a7fcd Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Sat, 2 Jul 2022 12:45:04 +0800 Subject: [PATCH 08/14] error modify Signed-off-by: fangjinliang --- services/ans/src/advanced_notification_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 3a5c900eb..aa3daa5bd 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -2937,7 +2937,7 @@ NotificationConstant::RemindType AdvancedNotificationService::GetRemindType() } } -std::string AdvancedNotificationService::GetDistributedInfo( +void AdvancedNotificationService::GetDistributedInfo( const std::string &key, std::string &deviceId, std::string &bundleName) { for (auto record : notificationList_) { -- Gitee From 327477028eb94633bff4f4c416e8d5880c44b34c Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Sat, 2 Jul 2022 14:01:36 +0800 Subject: [PATCH 09/14] warn modify Signed-off-by: fangjinliang --- services/ans/include/advanced_notification_service.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 5423d5f6e..4804e5949 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -812,7 +812,8 @@ private: NotificationConstant::RemindType GetRemindType(); ErrCode DoDistributedPublish( const sptr bundleOption, const std::shared_ptr record); - ErrCode DoDistributedDelete(const std::string deviceId, const std::string bundleName, const sptr notification); + ErrCode DoDistributedDelete( + const std::string deviceId, const std::string bundleName, const sptr notification); void GetDistributedInfo(const std::string &key, std::string &deviceId, std::string &bundleName); bool CheckDistributedNotificationType(const sptr &request); void OnDistributedPublish( -- Gitee From e81197921d45face595267164dfa5a540df7b559 Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Sat, 2 Jul 2022 16:13:04 +0800 Subject: [PATCH 10/14] compile warning Signed-off-by: fangjinliang --- frameworks/js/napi/src/common.cpp | 6 ++---- frameworks/js/napi/src/disturb_mode.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index 9348c56d0..94b291bc0 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -1339,15 +1339,13 @@ napi_value Common::SetDoNotDisturbDate( napi_set_named_property(env, result, "type", typeNapi); // begin:Date - double begind = double(date.GetBeginDate()); napi_value beginNapi = nullptr; - napi_create_date(env, begind, &beginNapi); + napi_create_int64(env, date.GetBeginDate(), &beginNapi); napi_set_named_property(env, result, "begin", beginNapi); // end:Date - double endd = double(date.GetEndDate()); napi_value endNapi = nullptr; - napi_create_date(env, endd, &endNapi); + napi_create_int64(env, date.GetEndDate(), &endNapi); napi_set_named_property(env, result, "end", endNapi); return NapiGetBoolean(env, true); diff --git a/frameworks/js/napi/src/disturb_mode.cpp b/frameworks/js/napi/src/disturb_mode.cpp index e901f0285..1fbd3605a 100644 --- a/frameworks/js/napi/src/disturb_mode.cpp +++ b/frameworks/js/napi/src/disturb_mode.cpp @@ -90,7 +90,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGW("Wrong argument type. Property type expected."); return nullptr; } - double begin = 0; + int64_t begin = 0; napi_get_named_property(env, argv, "begin", &value); bool isDate = false; napi_is_date(env, value, &isDate); @@ -98,8 +98,8 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGE("Wrong argument type. Date expected."); return nullptr; } - napi_get_date_value(env, value, &begin); - params.date.SetBeginDate(int64_t(begin)); + napi_get_value_int64(env, value, &begin); + params.date.SetBeginDate(begin); // argv[0]: date:end NAPI_CALL(env, napi_has_named_property(env, argv, "end", &hasProperty)); @@ -107,7 +107,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGW("Wrong argument type. Property type expected."); return nullptr; } - double end = 0; + int64_t end = 0; napi_get_named_property(env, argv, "end", &value); isDate = false; napi_is_date(env, value, &isDate); @@ -115,8 +115,8 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGE("Wrong argument type. Date expected."); return nullptr; } - napi_get_date_value(env, value, &end); - params.date.SetEndDate(int64_t(end)); + napi_get_value_int64(env, value, &end); + params.date.SetEndDate(end); return Common::NapiGetNull(env); } -- Gitee From 2e2630128c66c12ac456bb6e4ec2f9246a16f3d9 Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Sat, 2 Jul 2022 18:36:14 +0800 Subject: [PATCH 11/14] distributed Signed-off-by: fangjinliang --- services/ans/src/advanced_notification_service.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index aa3daa5bd..b956e3f79 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -3055,6 +3055,7 @@ void AdvancedNotificationService::OnDistributedPublish( record->notification = new Notification(deviceId, request); record->bundleOption = bundleOption; record->deviceId = deviceId; + record->bundleName = bundleName; SetNotificationRemindType(record->notification, false); ErrCode result = AssignValidNotificationSlot(record); @@ -3119,6 +3120,7 @@ void AdvancedNotificationService::OnDistributedUpdate( record->notification = new Notification(deviceId, request); record->bundleOption = bundleOption; record->deviceId = deviceId; + record->bundleName = bundleName; SetNotificationRemindType(record->notification, false); ErrCode result = AssignValidNotificationSlot(record); -- Gitee From 6689758fd2fa0eca85cf82564187420f4bb24100 Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Mon, 4 Jul 2022 09:17:51 +0800 Subject: [PATCH 12/14] cancel Signed-off-by: fangjinliang --- services/ans/src/advanced_notification_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index b956e3f79..91f83d5a5 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -3177,7 +3177,7 @@ void AdvancedNotificationService::OnDistributedDelete( sptr notification = nullptr; for (auto record : notificationList_) { if ((record->deviceId == recordDeviceId) && - ((record->bundleOption->GetBundleName() == bundleOption->GetBundleName()) && + ((record->bundleOption->GetBundleName() == bundleOption->GetBundleName()) || (FOUNDATION_BUNDLE_NAME == bundleOption->GetBundleName())) && (record->bundleOption->GetUid() == bundleOption->GetUid()) && (record->notification->GetLabel() == label) && (record->notification->GetId() == id)) { -- Gitee From c5137d161051783df433129d1ed3ebc17de4b2f9 Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Mon, 4 Jul 2022 10:37:18 +0800 Subject: [PATCH 13/14] cancel Signed-off-by: fangjinliang --- services/ans/src/advanced_notification_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 91f83d5a5..b0165c39d 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -3178,7 +3178,7 @@ void AdvancedNotificationService::OnDistributedDelete( for (auto record : notificationList_) { if ((record->deviceId == recordDeviceId) && ((record->bundleOption->GetBundleName() == bundleOption->GetBundleName()) || - (FOUNDATION_BUNDLE_NAME == bundleOption->GetBundleName())) && + (record->bundleName == bundleName)) && (record->bundleOption->GetUid() == bundleOption->GetUid()) && (record->notification->GetLabel() == label) && (record->notification->GetId() == id)) { notification = record->notification; -- Gitee From 37af495ef8c752ab3673e0f0d8fafcbf5d229d1f Mon Sep 17 00:00:00 2001 From: fangjinliang Date: Mon, 4 Jul 2022 11:37:03 +0800 Subject: [PATCH 14/14] napi Signed-off-by: fangjinliang --- frameworks/js/napi/src/common.cpp | 6 ++++-- frameworks/js/napi/src/disturb_mode.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index 94b291bc0..9348c56d0 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -1339,13 +1339,15 @@ napi_value Common::SetDoNotDisturbDate( napi_set_named_property(env, result, "type", typeNapi); // begin:Date + double begind = double(date.GetBeginDate()); napi_value beginNapi = nullptr; - napi_create_int64(env, date.GetBeginDate(), &beginNapi); + napi_create_date(env, begind, &beginNapi); napi_set_named_property(env, result, "begin", beginNapi); // end:Date + double endd = double(date.GetEndDate()); napi_value endNapi = nullptr; - napi_create_int64(env, date.GetEndDate(), &endNapi); + napi_create_date(env, endd, &endNapi); napi_set_named_property(env, result, "end", endNapi); return NapiGetBoolean(env, true); diff --git a/frameworks/js/napi/src/disturb_mode.cpp b/frameworks/js/napi/src/disturb_mode.cpp index 1fbd3605a..e901f0285 100644 --- a/frameworks/js/napi/src/disturb_mode.cpp +++ b/frameworks/js/napi/src/disturb_mode.cpp @@ -90,7 +90,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGW("Wrong argument type. Property type expected."); return nullptr; } - int64_t begin = 0; + double begin = 0; napi_get_named_property(env, argv, "begin", &value); bool isDate = false; napi_is_date(env, value, &isDate); @@ -98,8 +98,8 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGE("Wrong argument type. Date expected."); return nullptr; } - napi_get_value_int64(env, value, &begin); - params.date.SetBeginDate(begin); + napi_get_date_value(env, value, &begin); + params.date.SetBeginDate(int64_t(begin)); // argv[0]: date:end NAPI_CALL(env, napi_has_named_property(env, argv, "end", &hasProperty)); @@ -107,7 +107,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGW("Wrong argument type. Property type expected."); return nullptr; } - int64_t end = 0; + double end = 0; napi_get_named_property(env, argv, "end", &value); isDate = false; napi_is_date(env, value, &isDate); @@ -115,8 +115,8 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD ANS_LOGE("Wrong argument type. Date expected."); return nullptr; } - napi_get_value_int64(env, value, &end); - params.date.SetEndDate(end); + napi_get_date_value(env, value, &end); + params.date.SetEndDate(int64_t(end)); return Common::NapiGetNull(env); } -- Gitee