diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 31c38db9a4bdd919abd2303d37cf2e853b32c6e5..d0a77e00a0620206fb7a2b0e285f743a4478411e 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1441,6 +1441,7 @@ private: void HandleUpdateLiveViewNotificationTimer(const int32_t uid, const bool isPaused); void CancelWantAgent(const sptr ¬ification); void CancelOnceWantAgent(const std::shared_ptr &wantAgent); + void SetClassificationWithVoip(const sptr &request); private: static sptr instance_; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index db5b16614148012d217ab7d904489a5af0bfe8a4..2ccb36621f34b29f514b23cb3d89b3fa915c3997 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -92,9 +92,11 @@ 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; constexpr int32_t CONTROL_BY_DO_NOT_DISTURB_MODE = 1 << 14; 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 @@ -458,6 +460,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()); @@ -2303,6 +2306,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 453a65859f18c61a284c06e9c1b16d0d7679e48a..f4fc6dd3a17e6a3ee1bee062325dacce7d6ea101 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 88b6ba66aedf838f20a5a31fbc60ae0589a003f3..38723993cce56ff385e816595bfc6c201a4bc2e2 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"; +} constexpr int32_t CONTROL_BY_SMART_REMINDER = 1 << 15; SmartReminderCenter::SmartReminderCenter() { @@ -262,6 +265,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) {