diff --git a/frameworks/ans/src/reminder_request.cpp b/frameworks/ans/src/reminder_request.cpp index f66e845f7033fe502e535549a145a12d04d941b5..7025971270128e539570dab456ade987a9e61ce3 100644 --- a/frameworks/ans/src/reminder_request.cpp +++ b/frameworks/ans/src/reminder_request.cpp @@ -1109,6 +1109,7 @@ bool ReminderRequest::Marshalling(Parcel &parcel) const WRITE_STRING_RETURN_FALSE_LOG(parcel, maxScreenWantAgentInfo_->abilityName, "maxScreenWantAgentInfo's abilityName"); WRITE_STRING_RETURN_FALSE_LOG(parcel, maxScreenWantAgentInfo_->pkgName, "maxScreenWantAgentInfo's pkgName"); WRITE_STRING_RETURN_FALSE_LOG(parcel, customButtonUri_, "customButtonUri"); + WRITE_STRING_RETURN_FALSE_LOG(parcel, groupId_, "groupId"); WRITE_STRING_RETURN_FALSE_LOG(parcel, customRingUri_, "customRingUri"); // write bool @@ -1121,7 +1122,6 @@ bool ReminderRequest::Marshalling(Parcel &parcel) const WRITE_INT32_RETURN_FALSE_LOG(parcel, reminderId_, "reminderId"); WRITE_INT32_RETURN_FALSE_LOG(parcel, notificationId_, "notificationId"); - WRITE_STRING_RETURN_FALSE_LOG(parcel, groupId_, "groupId"); WRITE_UINT64_RETURN_FALSE_LOG(parcel, triggerTimeInMilli_, "triggerTimeInMilli"); WRITE_UINT64_RETURN_FALSE_LOG(parcel, timeIntervalInMilli_, "timeIntervalInMilli"); WRITE_UINT64_RETURN_FALSE_LOG(parcel, ringDurationInMilli_, "ringDurationInMilli"); @@ -1205,6 +1205,7 @@ bool ReminderRequest::ReadFromParcel(Parcel &parcel) READ_STRING_RETURN_FALSE_LOG(parcel, maxScreenWantAgentInfo_->abilityName, "maxScreenWantAgentInfo's abilityName"); READ_STRING_RETURN_FALSE_LOG(parcel, maxScreenWantAgentInfo_->pkgName, "maxScreenWantAgentInfo's pkgName"); READ_STRING_RETURN_FALSE_LOG(parcel, customButtonUri_, "customButtonUri"); + READ_STRING_RETURN_FALSE_LOG(parcel, groupId_, "groupId"); READ_STRING_RETURN_FALSE_LOG(parcel, customRingUri_, "customRingUri"); READ_BOOL_RETURN_FALSE_LOG(parcel, isExpired_, "isExpired"); @@ -1219,7 +1220,6 @@ bool ReminderRequest::ReadFromParcel(Parcel &parcel) READ_INT32_RETURN_FALSE_LOG(parcel, notificationId_, "notificationId"); - READ_STRING_RETURN_FALSE_LOG(parcel, groupId_, "groupId"); READ_UINT64_RETURN_FALSE_LOG(parcel, triggerTimeInMilli_, "triggerTimeInMilli"); READ_UINT64_RETURN_FALSE_LOG(parcel, timeIntervalInMilli_, "timeIntervalInMilli"); READ_UINT64_RETURN_FALSE_LOG(parcel, ringDurationInMilli_, "ringDurationInMilli"); diff --git a/services/ans/src/reminder_data_manager.cpp b/services/ans/src/reminder_data_manager.cpp index b321471eef52bdc7c01f7fcd1bc572532614337c..a8badf6851695ee2510a89a637b9df0aab0d4b2a 100644 --- a/services/ans/src/reminder_data_manager.cpp +++ b/services/ans/src/reminder_data_manager.cpp @@ -181,12 +181,12 @@ void ReminderDataManager::CancelRemindersImplLocked(const std::string &packageNa bool ReminderDataManager::IsMatchedForGroupIdAndPkgName(const sptr &reminder, const std::string &packageName, const std::string &groupId) const { - sptr notification = reminder->GetNotificationRequest(); - if (notification == nullptr) { - ANSR_LOGW("IsMatchedForGroupIdAndPkgName not find the notification"); + std::string packageNameTemp = reminder->GetBundleName(); + if (packageNameTemp.empty()) { + ANS_LOGW("reminder package name is null!"); return false; } - if (notification->GetCreatorBundleName() == packageName && reminder->GetGroupId() == groupId) { + if (packageNameTemp == packageName && reminder->GetGroupId() == groupId) { return true; } return false; @@ -500,20 +500,15 @@ void ReminderDataManager::CloseReminder(const OHOS::EventFwk::Want &want, bool c ANSR_LOGW("Invalid reminder id: %{public}d", reminderId); return; } - sptr notificationRequest = reminder->GetNotificationRequest(); - if (notificationRequest == nullptr) { - ANSR_LOGW("notificationRequest is not find, this reminder can`t close by groupId"); + std::string packageName = reminder->GetBundleName(); + std::string groupId = reminder->GetGroupId(); + if (packageName.empty() || groupId.empty()) { + ANSR_LOGW("reminder package name is null or the group id is not set, this reminder can not close by group id!"); CloseReminder(reminder, cancelNotification); StartRecentReminder(); CheckNeedNotifyStatus(reminder, ReminderRequest::ActionButtonType::CLOSE); - return; - } - std::string bundleName = notificationRequest->GetCreatorBundleName(); - std::string groupId = reminder->GetGroupId(); - if (!groupId.empty()) { - ANSR_LOGD("close reminder, the group id is set."); - CloseRemindersByGroupId(reminderId, bundleName, groupId); } + CloseRemindersByGroupId(reminderId, packageName, groupId); CloseReminder(reminder, cancelNotification); StartRecentReminder(); CheckNeedNotifyStatus(reminder, ReminderRequest::ActionButtonType::CLOSE);