From 882faa42294242654628d988ce7b288d80cdcb42 Mon Sep 17 00:00:00 2001 From: luojingsong Date: Wed, 5 Feb 2025 15:19:13 +0800 Subject: [PATCH] =?UTF-8?q?voip=E5=90=88=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luojingsong Change-Id: If5b90dbe070aa28091583a5faf2623be4674d690 --- .../include/advanced_notification_service.h | 1 + .../ans/src/advanced_notification_service.cpp | 22 +++++++++++++++++++ .../advanced_notification_slot_service.cpp | 4 ++++ .../smart_reminder_center.cpp | 8 +++++++ 4 files changed, 35 insertions(+) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 31ba34776..c914d9a93 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1439,6 +1439,7 @@ private: ErrCode OnRecoverLiveView(const std::vector &keys); void HandleUpdateLiveViewNotificationTimer(const int32_t uid, const bool isPaused); + void SetClassificationWithVoip(const sptr &request); private: static sptr instance_; static std::mutex instanceMutex_; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index ec23436b7..d756bd909 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -91,8 +91,10 @@ constexpr int32_t BUNDLE_OPTION_UID_DEFAULT_VALUE = 0; constexpr int32_t MAX_SOUND_ITEM_LENGTH = 2048; constexpr int32_t RSS_UID = 3051; constexpr int32_t RESSCHED_UID = 1096; +constexpr int32_t TYPE_CODE_VOIP = 0; const std::string DO_NOT_DISTURB_MODE = "1"; +const std::string ANS_CALL = "ANS_VOIP"; constexpr const char *KEY_UNIFIED_GROUP_ENABLE = "unified_group_enable"; } // namespace @@ -455,6 +457,7 @@ ErrCode AdvancedNotificationService::PrepareNotificationInfo( if (bundleOption == nullptr) { return ERR_ANS_INVALID_BUNDLE; } + SetClassificationWithVoip(request); ANS_LOGI( "bundleName=%{public}s, uid=%{public}d", (bundleOption->GetBundleName()).c_str(), bundleOption->GetUid()); @@ -2271,6 +2274,25 @@ void AdvancedNotificationService::RemoveNotificationList(const std::shared_ptr &request) +{ + ANS_LOGI("classification:%{public}s", request->GetClassification().c_str()); + if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER)) { + ANS_LOGI("set classification empty"); + request->SetClassification(""); + return; + } + auto requestContent = request->GetContent(); + if (request->IsSystemLiveView() && requestContent != nullptr && + requestContent->GetNotificationContent() != nullptr) { + auto localLiveViewContent = std::static_pointer_cast( + requestContent->GetNotificationContent()); + if (localLiveViewContent->GetType() == TYPE_CODE_VOIP) { + request->SetClassification(ANS_CALL); + } + } +} + PushCallbackRecipient::PushCallbackRecipient() {} PushCallbackRecipient::~PushCallbackRecipient() {} diff --git a/services/ans/src/advanced_notification_slot_service.cpp b/services/ans/src/advanced_notification_slot_service.cpp index 453a65859..f4fc6dd3a 100644 --- a/services/ans/src/advanced_notification_slot_service.cpp +++ b/services/ans/src/advanced_notification_slot_service.cpp @@ -628,6 +628,10 @@ void AdvancedNotificationService::SetRequestBySlotType(const sptr::GetInstance()->ReminderDecisionProcess(request); #endif + if (!request->IsSystemLiveView() && request->GetClassification() == "ANS_VOIP") { + request->SetClassification(""); + } + ANS_LOGI("classification:%{public}s", request->GetClassification().c_str()); } ErrCode AdvancedNotificationService::GetSlotByType( diff --git a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp index 8e4b8c8c0..db0efe8dd 100644 --- a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp +++ b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp @@ -28,6 +28,9 @@ namespace OHOS { namespace Notification { using namespace std; +namespace { + const std::string ANS_VOIP = "ANS_VOIP"; +} SmartReminderCenter::SmartReminderCenter() { if (!DelayedSingleton::GetInstance()->GetCurrentSlotReminder(currentReminderMethods_)) { @@ -261,6 +264,11 @@ void SmartReminderCenter::HandleReminderMethods( set &validDevices, shared_ptr>> notificationFlagsOfDevices) const { + if (deviceType.compare(NotificationConstant::CURRENT_DEVICE_TYPE) == 0 && + (request->GetClassification() == ANS_VOIP)) { + ANS_LOGI("VOIP or CALL is not affected with SmartReminder"); + return; + } vector> reminderAffecteds; GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds); if (reminderAffecteds.size() <= 0) { -- Gitee