From 12efb2bc228643b380bfa6723ddfd9c61c8b1230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:17:22 +0000 Subject: [PATCH 01/11] update interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- .../src/bg_continuous_task_napi_module.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp b/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp index 1c90be19..317352e4 100644 --- a/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp +++ b/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp @@ -425,9 +425,6 @@ napi_value UpdateBackgroundRunningByRequestPromise(napi_env env, AsyncCallbackIn BGTASK_LOGE("param is nullptr"); return nullptr; } - if (!CheckBackgroundMode(env, asyncCallbackInfo, isThrow)) { - return nullptr; - } napi_value resourceName; NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); napi_deferred deferred; @@ -729,7 +726,20 @@ napi_value UpdateBackgroundRunning(napi_env env, napi_callback_info info, bool i } ret = UpdateBackgroundRunningPromise(env, asyncCallbackInfo, isThrow); } else { - BGTASK_LOGE("UpdateBackgroundRunningByRequestPromise"); + if (!StartBackgroundRunningCheckRequest(env, argv, isThrow, asyncCallbackInfo)) { + callbackPtr.release(); + if (asyncCallbackInfo != nullptr) { + delete asyncCallbackInfo; + asyncCallbackInfo = nullptr; + } + return WrapVoidToJS(env); + } + if (asyncCallbackInfo->request->GetContinuousTaskId() < 0) { + Common::HandleErrCode(env, ERR_BGTASK_CONTINUOUS_TASKID_INVALID, true); + asyncCallbackInfo->errCode = ERR_BGTASK_CONTINUOUS_TASKID_INVALID; + return WrapVoidToJS(env); + } + ret = UpdateBackgroundRunningByRequestPromise(env, asyncCallbackInfo, isThrow); } callbackPtr.release(); if (ret == nullptr) { -- Gitee From 818bf43656d59beffe1ff783b75b1ca8f63a25e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:18:57 +0000 Subject: [PATCH 02/11] update interfaces/innerkits/include/continuous_task_param.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- interfaces/innerkits/include/continuous_task_param.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/innerkits/include/continuous_task_param.h b/interfaces/innerkits/include/continuous_task_param.h index b0017bbe..11c2dff9 100644 --- a/interfaces/innerkits/include/continuous_task_param.h +++ b/interfaces/innerkits/include/continuous_task_param.h @@ -39,6 +39,7 @@ struct ContinuousTaskParam : public Parcelable { std::vector bgSubModeIds_ {}; bool isCombinedTaskNotification_ {false}; int32_t combinedNotificationTaskId_ {-1}; + int32_t updateTaskId_ {-1}; bool isByRequestObject_ {false}; int32_t notificationId_ {-1}; // out int32_t continuousTaskId_ {-1}; // out -- Gitee From 436586b5eb40dc926cae381ec14738b963f3f141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:19:58 +0000 Subject: [PATCH 03/11] update interfaces/innerkits/src/continuous_task_param.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- interfaces/innerkits/src/continuous_task_param.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interfaces/innerkits/src/continuous_task_param.cpp b/interfaces/innerkits/src/continuous_task_param.cpp index 2b43494b..7ce8de6b 100644 --- a/interfaces/innerkits/src/continuous_task_param.cpp +++ b/interfaces/innerkits/src/continuous_task_param.cpp @@ -102,6 +102,9 @@ bool ContinuousTaskParam::ReadFromParcel(Parcel &parcel) if (!parcel.ReadInt32(combinedNotificationTaskId_)) { return false; } + if (!parcel.ReadInt32(updateTaskId_)) { + return false; + } if (!parcel.ReadBool(isByRequestObject_)) { return false; } @@ -223,6 +226,9 @@ bool ContinuousTaskParam::Marshalling(Parcel &parcel) const if (!parcel.WriteInt32(combinedNotificationTaskId_)) { return false; } + if (!parcel.WriteInt32(updateTaskId_)) { + return false; + } if (!parcel.WriteBool(isByRequestObject_)) { return false; } -- Gitee From a7173d0ab8be87044de6fa6d4e83e48775d312d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:21:29 +0000 Subject: [PATCH 04/11] update services/continuous_task/src/notification_tools.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- .../src/notification_tools.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/services/continuous_task/src/notification_tools.cpp b/services/continuous_task/src/notification_tools.cpp index 11f9a147..340d1c4b 100644 --- a/services/continuous_task/src/notification_tools.cpp +++ b/services/continuous_task/src/notification_tools.cpp @@ -179,5 +179,35 @@ WEAK_FUNC void NotificationTools::RefreshContinuousNotifications( } #endif } + +WEAK_FUNC void NotificationTools::RefreshContinuousNotificationWantAndContext(int32_t serviceUid, + const std::map> &newPromptInfos, + const std::shared_ptr continuousTaskRecord, bool updateContent) +{ +#ifdef DISTRIBUTED_NOTIFICATION_ENABLE + std::vector> notificationRequests; + ErrCode ret = Notification::NotificationHelper::GetActiveNotifications(notificationRequests); + if (ret != ERR_OK) { + BGTASK_LOGE("get all active notification fail!"); + return; + } + for (Notification::NotificationRequest *var : notificationRequests) { + std::string label = var->GetLabel(); + if (newPromptInfos.count(label) == 0 || var->GetCreatorUid() != serviceUid) { + continue; + } + var->SetWantAgent(continuousTaskRecord->GetWantAgent()); + if (updateContent) { + auto &content = var->GetContent(); + auto const &normalContent = content->GetNotificationContent(); + normalContent->SetTitle(newPromptInfos.at(label).first); + normalContent->SetText(newPromptInfos.at(label).second); + } + if (Notification::NotificationHelper::PublishContinuousTaskNotification(*var) != ERR_OK) { + BGTASK_LOGE("refresh notification error"); + } + } +#endif +} } } -- Gitee From 51d6830f8db9dc5912b46bd026bfc2d4fdb7d241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:21:57 +0000 Subject: [PATCH 05/11] update services/continuous_task/include/notification_tools.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- services/continuous_task/include/notification_tools.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/continuous_task/include/notification_tools.h b/services/continuous_task/include/notification_tools.h index 529714ed..a445b922 100644 --- a/services/continuous_task/include/notification_tools.h +++ b/services/continuous_task/include/notification_tools.h @@ -31,6 +31,9 @@ public: void GetAllActiveNotificationsLabels(std::set ¬ificationLabels); void RefreshContinuousNotifications( const std::map> &newPromptInfos, int32_t serviceUid); + void RefreshContinuousNotificationWantAndContext(int32_t serviceUid, + const std::map> &newPromptInfos, + const std::shared_ptr continuousTaskRecord, bool updateContent = false); private: static int32_t notificationIdIndex_; -- Gitee From 450d495a38999ff984f7a5fc0c283e8b9d206d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:23:08 +0000 Subject: [PATCH 06/11] update services/continuous_task/include/bg_continuous_task_mgr.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- services/continuous_task/include/bg_continuous_task_mgr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/continuous_task/include/bg_continuous_task_mgr.h b/services/continuous_task/include/bg_continuous_task_mgr.h index d2e51506..bdc95480 100644 --- a/services/continuous_task/include/bg_continuous_task_mgr.h +++ b/services/continuous_task/include/bg_continuous_task_mgr.h @@ -116,6 +116,9 @@ private: ErrCode StartBackgroundRunningInner(std::shared_ptr &continuousTaskRecordPtr); ErrCode UpdateBackgroundRunningInner(const std::string &taskInfoMapKey, const sptr &taskParam); + ErrCode UpdateBackgroundRunningByTaskIdInner(int32_t uid, const sptr &taskParam); + ErrCode UpdateTaskAndNotificationByTaskIdInner(const sptr &taskParam, + std::shared_ptr record); ErrCode StartBackgroundRunningForInner(const sptr &taskParam); ErrCode StopBackgroundRunningInner(int32_t uid, const std::string &abilityName, int32_t abilityId, int32_t continuousTaskId = -1); -- Gitee From 258a925438fea9d23f72ce27794000e1cd13ff49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:33:23 +0000 Subject: [PATCH 07/11] update services/continuous_task/src/bg_continuous_task_mgr.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- .../src/bg_continuous_task_mgr.cpp | 139 ++++++++++++++++-- 1 file changed, 129 insertions(+), 10 deletions(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 8e1ef6f7..f0e72546 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -773,23 +773,142 @@ ErrCode BgContinuousTaskMgr::UpdateBackgroundRunning(const sptrabilityName_ + SEPARATOR + - std::to_string(taskParam->abilityId_); - auto self = shared_from_this(); - handler_->PostSyncTask([self, &taskInfoMapKey, &result, taskParam]() mutable { - if (!self) { - BGTASK_LOGE("self is null"); - result = ERR_BGTASK_SERVICE_INNER_ERROR; - return; - } + if (taskParam->isByRequestObject_) { + // 根据任务id更新 + handler_->PostSyncTask([this, callingUid, taskParam, &result]() { + result = this->UpdateBackgroundRunningByTaskIdInner(callingUid, taskParam); + }, AppExecFwk::EventQueue::Priority::HIGH); + } else { + std::string taskInfoMapKey = std::to_string(callingUid) + SEPARATOR + taskParam->abilityName_ + SEPARATOR + + std::to_string(taskParam->abilityId_); + auto self = shared_from_this(); + handler_->PostSyncTask([self, &taskInfoMapKey, &result, taskParam]() mutable { + if (!self) { + BGTASK_LOGE("self is null"); + result = ERR_BGTASK_SERVICE_INNER_ERROR; + return; + } result = self->UpdateBackgroundRunningInner(taskInfoMapKey, taskParam); }, AppExecFwk::EventQueue::Priority::HIGH); + } return result; } +ErrCode BgContinuousTaskMgr::UpdateBackgroundRunningByTaskIdInner(int32_t uid, + const sptr &taskParam) +{ + int32_t continuousTaskId = taskParam->updateTaskId_; + std::string abilityName = taskParam->abilityName_; + int32_t abilityId = taskParam->abilityId_; + if (continuousTaskId < 0) { + BGTASK_LOGE("update task fail, taskId: %{public}d", taskParam->updateTaskId_); + return ERR_BGTASK_CONTINUOUS_TASKID_INVALID; + } + auto findTask = [continuousTaskId, uid, abilityName, abilityId](const auto &target) { + return continuousTaskId == target.second->continuousTaskId_ && target.second->uid_ == uid && + target.second->abilityName_ == abilityName && target.second->abilityId_ == abilityId + && target.second->isByRequestObject_; + }; + auto findTaskIter = find_if(continuousTaskInfosMap_.begin(), continuousTaskInfosMap_.end(), + findTask); + if (findTaskIter == continuousTaskInfosMap_.end()) { + BGTASK_LOGE("uid: %{public}d not have task, taskId: %{public}d", uid, continuousTaskId); + return ERR_BGTASK_OBJECT_NOT_EXIST; + } + auto record = findTaskIter->second; + record->isByRequestObject_ = true; + uint32_t configuredBgMode = GetBackgroundModeInfo(uid, record->abilityName_); + ErrCode ret = ERR_OK; + for (auto it = taskParam->bgModeIds_.begin(); it != taskParam->bgModeIds_.end(); it++) { + ret = CheckBgmodeType(configuredBgMode, *it, true, record); + if (ret != ERR_OK) { + BGTASK_LOGE("CheckBgmodeType error, mode: %{public}u, apply mode: %{public}u.", configuredBgMode, *it); + return ret; + } + } + if (record->GetNotificationId() == -1) { + // task本身没有通知,则只更新内容。刷新缓存 + record->bgModeId_ = taskParam->bgModeId_; + record->bgModeIds_ = taskParam->bgModeIds_; + record->bgSubModeIds_ = taskParam->bgSubModeIds_; + record->wantAgent_ = taskParam->wantAgent_; + record->isCombinedTaskNotification_ = taskParam->isCombinedTaskNotification_; + if (record->suspendState_) { + std::string taskInfoMapKey = std::to_string(uid) + SEPARATOR + + record->abilityName_ + SEPARATOR + std::to_string(record->abilityId_) + + SEPARATOR + CommonUtils::ModesToString(record->bgModeIds_); + HandleActiveContinuousTask(record->uid_, record->pid_, taskInfoMapKey); + } + OnContinuousTaskChanged(record, ContinuousTaskEventTriggerType::TASK_UPDATE); + taskParam->notificationId_ = record->GetNotificationId(); + taskParam->continuousTaskId_ = record->GetContinuousTaskId(); + return RefreshTaskRecord(); + } else { + return UpdateTaskAndNotificationByTaskIdInner(taskParam, record); + } +} + +ErrCode BgContinuousTaskMgr::UpdateTaskAndNotificationByTaskIdInner(const sptr &taskParam, + std::shared_ptr record) +{ + auto oldModes = record->bgModeIds_; + record->bgModeId_ = taskParam->bgModeId_; + record->bgModeIds_ = taskParam->bgModeIds_; + record->bgSubModeIds_ = taskParam->bgSubModeIds_; + record->wantAgent_ = taskParam->wantAgent_; + if (record->wantAgent_ != nullptr && record->wantAgent_->GetPendingWant() != nullptr) { + auto target = record->wantAgent_->GetPendingWant()->GetTarget(); + auto want = record->wantAgent_->GetPendingWant()->GetWant(target); + if (want != nullptr) { + std::shared_ptr info = std::make_shared(); + info->bundleName_ = want->GetOperation().GetBundleName(); + info->abilityName_ = want->GetOperation().GetAbilityName(); + record->wantAgentInfo_ = info; + } + } + if (CommonUtils::CheckExistMode(oldModes, BackgroundMode::DATA_TRANSFER) && + CommonUtils::CheckExistMode(record->bgModeIds_, BackgroundMode::DATA_TRANSFER)) { + BGTASK_LOGI("uid: %{public}d, bundleName: %{public}s, abilityId: %{public}d have same mode: DATA_TRANSFER", + record->uid_, record->bundleName_.c_str(), record->abilityId_); + } else { + std::map> newPromptInfos; + std::string mainAbilityLabel = GetMainAbilityLabel(record->bundleName_, record->userId_); + std::string notificationText = GetNotificationText(record); + if (notificationText.empty() || mainAbilityLabel == "") { + NotificationTools::GetInstance()->CancelNotification(record->GetNotificationLabel(), + record->GetNotificationId()); + record->notificationId_ = -1; + return ERR_BGTASK_NOTIFICATION_VERIFY_FAILED; + } else { + newPromptInfos.emplace(record->notificationLabel_, std::make_pair(mainAbilityLabel, notificationText)); + } + if (!notificationText.empty()) { + if (record->isCombinedTaskNotification_) { + // 通知合并的任务,只更新want + NotificationTools::GetInstance()->RefreshContinuousNotificationWantAndContext(bgTaskUid_, + newPromptInfos, record); + } else { + // 刷新text,want + NotificationTools::GetInstance()->RefreshContinuousNotificationWantAndContext(bgTaskUid_, + newPromptInfos, record, true); + } + } + } + record->isCombinedTaskNotification_ = taskParam->isCombinedTaskNotification_; + if (record->suspendState_) { + std::string taskInfoMapKey = std::to_string(record->uid_) + SEPARATOR + + record->abilityName_ + SEPARATOR + std::to_string(record->abilityId_) + + SEPARATOR + CommonUtils::ModesToString(record->bgModeIds_); + HandleActiveContinuousTask(record->uid_, record->pid_, taskInfoMapKey); + } + OnContinuousTaskChanged(record, ContinuousTaskEventTriggerType::TASK_UPDATE); + taskParam->notificationId_ = record->GetNotificationId(); + taskParam->continuousTaskId_ = record->GetContinuousTaskId(); + return RefreshTaskRecord(); +} + ErrCode BgContinuousTaskMgr::UpdateBackgroundRunningInner(const std::string &taskInfoMapKey, const sptr &taskParam) { -- Gitee From 4fe7e2dea07dd84e7f985b82245b6075b7e21bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:34:44 +0000 Subject: [PATCH 08/11] update interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp b/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp index 317352e4..73e6782b 100644 --- a/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp +++ b/interfaces/kits/napi/src/bg_continuous_task_napi_module.cpp @@ -257,7 +257,7 @@ void UpdateBackgroundRunningByRequestExecuteCB(napi_env env, void *data) "", true, continuousTaskModes, asyncCallbackInfo->abilityContext->GetAbilityRecordId()); taskParam.isByRequestObject_ = true; taskParam.isCombinedTaskNotification_ = asyncCallbackInfo->request->IsCombinedTaskNotification(); - taskParam.combinedNotificationTaskId_ = asyncCallbackInfo->request->GetContinuousTaskId(); + taskParam.updateTaskId = asyncCallbackInfo->request->GetContinuousTaskId(); taskParam.bgSubModeIds_ = asyncCallbackInfo->request->GetContinuousTaskSubmodes(); asyncCallbackInfo->errCode = BackgroundTaskMgrHelper::RequestUpdateBackgroundRunning(taskParam); asyncCallbackInfo->bgModes = continuousTaskModes; -- Gitee From 7b382a7c7e35c4496eada65aa20f772618cd37bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:40:48 +0000 Subject: [PATCH 09/11] update interfaces/innerkits/include/continuous_task_param.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- interfaces/innerkits/include/continuous_task_param.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/include/continuous_task_param.h b/interfaces/innerkits/include/continuous_task_param.h index 11c2dff9..6d7f9b3c 100644 --- a/interfaces/innerkits/include/continuous_task_param.h +++ b/interfaces/innerkits/include/continuous_task_param.h @@ -48,7 +48,10 @@ struct ContinuousTaskParam : public Parcelable { ContinuousTaskParam(bool isNewApi, uint32_t bgModeId, const std::shared_ptr wantAgent, const std::string &abilityName, const sptr abilityToken, const std::string &appName, bool isBatchApi = false, - const std::vector &bgModeIds = {}, int32_t abilityId = -1); + const std::vector &bgModeIds = {}, int32_t abilityId = -1) + : isNewApi_(isNewApi), bgModeId_(bgModeId), wantAgent_(wantAgent), abilityName_(abilityName), + abilityToken_(abilityToken), appName_(appName), isBatchApi_(isBatchApi), bgModeIds_(bgModeIds), + abilityId_(abilityId) {} bool ReadFromParcel(Parcel &parcel); bool Marshalling(Parcel &parcel) const override; static ContinuousTaskParam *Unmarshalling(Parcel &parcel); -- Gitee From 6daad59957b3ea5ef6006aa9a92697a97e1f75f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 01:51:49 +0000 Subject: [PATCH 10/11] update services/test/unittest/bg_continuous_task_mgr_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- services/test/unittest/bg_continuous_task_mgr_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/test/unittest/bg_continuous_task_mgr_test.cpp b/services/test/unittest/bg_continuous_task_mgr_test.cpp index fcd082fe..57594dcb 100644 --- a/services/test/unittest/bg_continuous_task_mgr_test.cpp +++ b/services/test/unittest/bg_continuous_task_mgr_test.cpp @@ -243,7 +243,7 @@ HWTEST_F(BgContinuousTaskMgrTest, StartAndUpdateBackgroundRunning_001, TestSize. std::make_shared(), "ability1", nullptr, "Entry", true, {}); EXPECT_NE(taskParam1, nullptr); - EXPECT_EQ((int32_t)bgContinuousTaskMgr_->StartBackgroundRunning(taskParam1), (int32_t)ERR_BGTASK_INVALID_BGMODE); + EXPECT_EQ((int32_t)bgContinuousTaskMgr_->StartBackgroundRunning(taskParam1), (int32_t)ERR_BGTASK_CHECK_TASK_PARAM); // 2 set configure mode is CONFIGURE_ALL_MODES bgContinuousTaskMgr_->cachedBundleInfos_.clear(); -- Gitee From 0c185ca8461295aa2bdc81610d0c3f0acd0b3173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Fri, 5 Sep 2025 02:09:49 +0000 Subject: [PATCH 11/11] update interfaces/innerkits/src/continuous_task_param.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- .../innerkits/src/continuous_task_param.cpp | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/interfaces/innerkits/src/continuous_task_param.cpp b/interfaces/innerkits/src/continuous_task_param.cpp index 7ce8de6b..d0779fdb 100644 --- a/interfaces/innerkits/src/continuous_task_param.cpp +++ b/interfaces/innerkits/src/continuous_task_param.cpp @@ -21,28 +21,6 @@ namespace OHOS { namespace BackgroundTaskMgr { -ContinuousTaskParam::ContinuousTaskParam(bool isNewApi, uint32_t bgModeId, - const std::shared_ptr wantAgent, const std::string &abilityName, - const sptr abilityToken, const std::string &appName, bool isBatchApi, - const std::vector &bgModeIds, int32_t abilityId) - : isNewApi_(isNewApi), bgModeId_(bgModeId), wantAgent_(wantAgent), abilityName_(abilityName), - abilityToken_(abilityToken), appName_(appName), isBatchApi_(isBatchApi), bgModeIds_(bgModeIds), - abilityId_(abilityId) { - if (isBatchApi_ && bgModeIds_.size() > 0) { - auto findNonDataTransfer = [](const auto &target) { - return target != BackgroundMode::DATA_TRANSFER; - }; - auto iter = std::find_if(bgModeIds_.begin(), bgModeIds_.end(), findNonDataTransfer); - if (iter != bgModeIds_.end()) { - bgModeId_ = *iter; - } else { - bgModeId_ = bgModeIds_[0]; - } - } else { - bgModeIds_.push_back(bgModeId); - } -} - bool ContinuousTaskParam::ReadFromParcel(Parcel &parcel) { if (!parcel.ReadBool(isNewApi_)) { -- Gitee