From c9eb2534cc0acc444ccbe293735b090a4d7b8299 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Wed, 6 Aug 2025 20:19:08 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- .../src/bg_continuous_task_mgr.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 5350634c..29cace91 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1425,14 +1425,23 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, } ErrCode result = ERR_OK; - if (isPublish && findUidIter->second->GetNotificationId() != -1) { - result = NotificationTools::GetInstance()->CancelNotification(findUidIter->second->GetNotificationLabel(), - findUidIter->second->GetNotificationId()); - findUidIter->second->notificationId_ = -1; - } else if (!isPublish) { + auto record = findUidIter->second; + // 只有播音类型长时任务,并且没有AVSession通知 + if (!isPublish && continuousTaskRecord->bgModeIds_.size() == 1 && + continuousTaskRecord->bgModeIds_[0] == BackgroundMode::AUDIO_PLAYBACK) { result = SendContinuousTaskNotification(findUidIter->second); - if (result != ERR_OK) { - BGTASK_LOGE("publish error"); + } + std::map> newPromptInfos; + if (!CommonUtils::CheckExistMode(record->bgModeIds_, BackgroundMode::DATA_TRANSFER)) { + std::string mainAbilityLabel = GetMainAbilityLabel(record->bundleName_, record->userId_); + std::string notificationText = GetNotificationText(record); + if (notificationText == "") { + result = NotificationTools::GetInstance()->CancelNotification( + findUidIter->second->GetNotificationLabel(), findUidIter->second->GetNotificationId()); + findUidIter->second->notificationId_ = -1; + } else { + newPromptInfos.emplace(record->notificationLabel_, std::make_pair(mainAbilityLabel, notificationText)); + result = NotificationTools::GetInstance()->RefreshContinuousNotifications(newPromptInfos, bgTaskUid_); } } return result; -- Gitee From 1fb3c5ffecec2d88194b828d0f5453b885458526 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Wed, 6 Aug 2025 20:21:09 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 29cace91..c29d501e 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1430,6 +1430,7 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, if (!isPublish && continuousTaskRecord->bgModeIds_.size() == 1 && continuousTaskRecord->bgModeIds_[0] == BackgroundMode::AUDIO_PLAYBACK) { result = SendContinuousTaskNotification(findUidIter->second); + return reault; } std::map> newPromptInfos; if (!CommonUtils::CheckExistMode(record->bgModeIds_, BackgroundMode::DATA_TRANSFER)) { -- Gitee From 4ac41f388a63e5d9ab255c6ffd99a3c59a301de9 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Thu, 7 Aug 2025 10:02:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index c29d501e..901b2e31 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1427,9 +1427,8 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, ErrCode result = ERR_OK; auto record = findUidIter->second; // 只有播音类型长时任务,并且没有AVSession通知 - if (!isPublish && continuousTaskRecord->bgModeIds_.size() == 1 && - continuousTaskRecord->bgModeIds_[0] == BackgroundMode::AUDIO_PLAYBACK) { - result = SendContinuousTaskNotification(findUidIter->second); + if (!isPublish && record->bgModeIds_.size() == 1 && record->bgModeIds_[0] == BackgroundMode::AUDIO_PLAYBACK) { + result = SendContinuousTaskNotification(record); return reault; } std::map> newPromptInfos; @@ -1438,8 +1437,8 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, std::string notificationText = GetNotificationText(record); if (notificationText == "") { result = NotificationTools::GetInstance()->CancelNotification( - findUidIter->second->GetNotificationLabel(), findUidIter->second->GetNotificationId()); - findUidIter->second->notificationId_ = -1; + record->GetNotificationLabel(), record->GetNotificationId()); + record->notificationId_ = -1; } else { newPromptInfos.emplace(record->notificationLabel_, std::make_pair(mainAbilityLabel, notificationText)); result = NotificationTools::GetInstance()->RefreshContinuousNotifications(newPromptInfos, bgTaskUid_); -- Gitee From f2980598bd1a311df69e76ed46a6f22dab5f93c6 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Thu, 7 Aug 2025 10:14:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 901b2e31..e2c7a7ec 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1429,7 +1429,7 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, // 只有播音类型长时任务,并且没有AVSession通知 if (!isPublish && record->bgModeIds_.size() == 1 && record->bgModeIds_[0] == BackgroundMode::AUDIO_PLAYBACK) { result = SendContinuousTaskNotification(record); - return reault; + return result; } std::map> newPromptInfos; if (!CommonUtils::CheckExistMode(record->bgModeIds_, BackgroundMode::DATA_TRANSFER)) { -- Gitee From 5538cd2fb7569feb5f1cbfead37001799ace8320 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Thu, 7 Aug 2025 10:45:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index e2c7a7ec..4f0add21 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1441,7 +1441,7 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, record->notificationId_ = -1; } else { newPromptInfos.emplace(record->notificationLabel_, std::make_pair(mainAbilityLabel, notificationText)); - result = NotificationTools::GetInstance()->RefreshContinuousNotifications(newPromptInfos, bgTaskUid_); + NotificationTools::GetInstance()->RefreshContinuousNotifications(newPromptInfos, bgTaskUid_); } } return result; -- Gitee From 5358844ba4ff5bb88f330682ba573066db5cd8a9 Mon Sep 17 00:00:00 2001 From: zhushuanghong Date: Thu, 7 Aug 2025 14:25:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushuanghong --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 4f0add21..6eefd02d 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -1435,7 +1435,7 @@ ErrCode BgContinuousTaskMgr::AVSessionNotifyUpdateNotificationInner(int32_t uid, if (!CommonUtils::CheckExistMode(record->bgModeIds_, BackgroundMode::DATA_TRANSFER)) { std::string mainAbilityLabel = GetMainAbilityLabel(record->bundleName_, record->userId_); std::string notificationText = GetNotificationText(record); - if (notificationText == "") { + if (notificationText.empty()) { result = NotificationTools::GetInstance()->CancelNotification( record->GetNotificationLabel(), record->GetNotificationId()); record->notificationId_ = -1; -- Gitee