From 93ee6c393fd376d7bba97b99d7b11c07e9b708ef Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 7 Apr 2025 15:48:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- frameworks/ans/src/notification_icon_button.cpp | 2 +- .../ans/src/notification_local_live_view_button.cpp | 2 +- .../ans/src/advanced_notification_publish_service.cpp | 8 ++++++++ services/ans/src/notification_preferences.cpp | 4 ++++ .../src/soft_bus/distributed_publish_service.cpp | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frameworks/ans/src/notification_icon_button.cpp b/frameworks/ans/src/notification_icon_button.cpp index 3a8a9db73..0c799fc43 100644 --- a/frameworks/ans/src/notification_icon_button.cpp +++ b/frameworks/ans/src/notification_icon_button.cpp @@ -311,7 +311,7 @@ bool NotificationIconButton::ReadResourceFromParcel(Parcel &parcel, ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); resourceObj = resource; return true; } diff --git a/frameworks/ans/src/notification_local_live_view_button.cpp b/frameworks/ans/src/notification_local_live_view_button.cpp index 2b96fc2b3..31fbce667 100644 --- a/frameworks/ans/src/notification_local_live_view_button.cpp +++ b/frameworks/ans/src/notification_local_live_view_button.cpp @@ -272,7 +272,7 @@ bool NotificationLocalLiveViewButton::ReadFromParcel(Parcel &parcel) ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); buttonIconsResource_.emplace_back(resource); } diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 40e3e6db0..dc555ec86 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -537,6 +537,14 @@ ErrCode AdvancedNotificationService::CancelAsBundle( { ANS_LOGD("%{public}s", __FUNCTION__); int32_t reason = NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE; + if (bundleOption == nullptr) { + std::string message = "bundleOption is invalid"; + OHOS::Notification::HaMetaMessage haMetaMessage = HaMetaMessage(2, 0) + .ErrorCode(ERR_ANS_INVALID_PARAM).NotificationId(notificationId); + ReportDeleteFailedEventPush(haMetaMessage, reason, message); + ANS_LOGE("%{public}s", message.c_str()); + return ERR_ANS_INVALID_PARAM; + } bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { std::string message = "not systemApp"; diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index d555303b4..7e9044d69 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -640,6 +640,10 @@ ErrCode NotificationPreferences::UpdateDoNotDisturbProfiles(int32_t userId, int6 } sptr profile = new (std::nothrow) NotificationDoNotDisturbProfile(); + if (profile == nullptr) { + ANS_LOGE("profile is nullptr"); + return ERR_ANS_INVALID_PARAM; + } std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (preferencesInfo.GetDoNotDisturbProfiles(profileId, userId, profile)) { diff --git a/services/distributed/src/soft_bus/distributed_publish_service.cpp b/services/distributed/src/soft_bus/distributed_publish_service.cpp index 474c99e09..e49122296 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -339,7 +339,7 @@ void DistributedService::RemoveNotifications(const std::shared_ptr& boxM std::string slotTypeString; while (slotTypesStream >> slotTypeString) { if (!slotTypeString.empty()) { - AnalyticsUtil::GetInstance().OperationalReporting(OPERATION_DELETE_BRANCH, std::stoi(slotTypeString)); + AnalyticsUtil::GetInstance().OperationalReporting(OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); } } } else { -- Gitee From 6e9c233f25d1a51945cf67d9d66af7a9e7057820 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 7 Apr 2025 16:26:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../distributed/src/soft_bus/distributed_publish_service.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/distributed/src/soft_bus/distributed_publish_service.cpp b/services/distributed/src/soft_bus/distributed_publish_service.cpp index e49122296..2bd443928 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -339,7 +339,8 @@ void DistributedService::RemoveNotifications(const std::shared_ptr& boxM std::string slotTypeString; while (slotTypesStream >> slotTypeString) { if (!slotTypeString.empty()) { - AnalyticsUtil::GetInstance().OperationalReporting(OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); + AnalyticsUtil::GetInstance().OperationalReporting( + OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); } } } else { -- Gitee