From 19844bc3a0818455531cf0fccc58f2fc80439e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Thu, 14 Aug 2025 06:41:54 +0000 Subject: [PATCH 1/4] 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interfaces/innerkits/include/continuous_task_param.h b/interfaces/innerkits/include/continuous_task_param.h index 14ef0153..43d304f7 100644 --- a/interfaces/innerkits/include/continuous_task_param.h +++ b/interfaces/innerkits/include/continuous_task_param.h @@ -57,6 +57,7 @@ struct ContinuousTaskParamForInner : public Parcelable { bool isStart_ {false}; int32_t abilityId_ {-1}; uint64_t tokenId_ {0}; + int32_t pid_ {0}; ContinuousTaskParamForInner() = default; ContinuousTaskParamForInner(int32_t uid, uint32_t bgModeId, bool isStart, int32_t abilityId = -1, @@ -66,6 +67,8 @@ struct ContinuousTaskParamForInner : public Parcelable { bool ReadFromParcel(Parcel &parcel); bool Marshalling(Parcel &parcel) const override; static ContinuousTaskParamForInner *Unmarshalling(Parcel &parcel); + void SetPid(const int32_t pid); + int32_t GetPid() const; }; } // namespace BackgroundTaskMgr } // namespace OHOS -- Gitee From 95769715de100bfa4100b68f4c995653c70f8104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Thu, 14 Aug 2025 06:44:13 +0000 Subject: [PATCH 2/4] 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, 21 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/src/continuous_task_param.cpp b/interfaces/innerkits/src/continuous_task_param.cpp index e570eb71..2c8d2515 100644 --- a/interfaces/innerkits/src/continuous_task_param.cpp +++ b/interfaces/innerkits/src/continuous_task_param.cpp @@ -95,8 +95,14 @@ bool ContinuousTaskParamForInner::ReadFromParcel(Parcel &parcel) BGTASK_LOGE("Failed to read the abilityId"); return false; } + if (!parcel.ReadUint64(tokenId_)) { - BGTASK_LOGE("read parce tokenId error"); + BGTASK_LOGE("Failed to read the tokenId"); + return false; + } + + if (!parcel.ReadInt32(pid_)) { + BGTASK_LOGE("Failed to read the pid"); return false; } return true; @@ -203,7 +209,21 @@ bool ContinuousTaskParamForInner::Marshalling(Parcel &parcel) const BGTASK_LOGE("Failed to write tokenId_"); return false; } + if (!parcel.WriteInt32(pid_)) { + BGTASK_LOGE("Failed to write pid_"); + return false; + } return true; } + +void ContinuousTaskParamForInner::SetPid(const int32_t pid) +{ + pid_ = pid; +} + +int32_t ContinuousTaskParamForInner::GetPid() const +{ + return pid_; +} } // namespace BackgroundTaskMgr } // namespace OHOS \ No newline at end of file -- Gitee From 173907c5bc5f68225ba8ac83893d177b91a12698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Thu, 14 Aug 2025 06:45:39 +0000 Subject: [PATCH 3/4] update interfaces/test/unittest/bgtask_manager_client_test/bgtask_client_unit_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡伟 --- .../bgtask_manager_client_test/bgtask_client_unit_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/test/unittest/bgtask_manager_client_test/bgtask_client_unit_test.cpp b/interfaces/test/unittest/bgtask_manager_client_test/bgtask_client_unit_test.cpp index 54c98d29..4bb59215 100644 --- a/interfaces/test/unittest/bgtask_manager_client_test/bgtask_client_unit_test.cpp +++ b/interfaces/test/unittest/bgtask_manager_client_test/bgtask_client_unit_test.cpp @@ -554,6 +554,8 @@ HWTEST_F(BgTaskClientUnitTest, ContinuousTaskParamForInner_001, TestSize.Level1) sptr info1 = sptr(new ContinuousTaskParamForInner()); sptr info2 = sptr( new ContinuousTaskParamForInner(1, 1, true)); + info2->SetPid(1); + EXPECT_EQ(info2->GetPid(), 1); Parcel parcel1 = Parcel(); info2->Marshalling(parcel1); -- Gitee From 7f3a629b6cd6b1e59d2a2509509746daf732bc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BC=9F?= Date: Thu, 14 Aug 2025 06:50:33 +0000 Subject: [PATCH 4/4] 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: 胡伟 --- services/continuous_task/src/bg_continuous_task_mgr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/continuous_task/src/bg_continuous_task_mgr.cpp b/services/continuous_task/src/bg_continuous_task_mgr.cpp index 5b4e2ebe..156f9232 100644 --- a/services/continuous_task/src/bg_continuous_task_mgr.cpp +++ b/services/continuous_task/src/bg_continuous_task_mgr.cpp @@ -627,6 +627,9 @@ ErrCode BgContinuousTaskMgr::StartBackgroundRunningForInner(const sptruid_; pid_t callingPid = IPCSkeleton::GetCallingPid(); + if (taskParam->GetPid() != 0) { + callingPid = taskParam->GetPid(); + } uint64_t fullTokenId = IPCSkeleton::GetCallingFullTokenID(); std::string bundleName = BundleManagerHelper::GetInstance()->GetClientBundleName(uid); std::string abilityName = "Webview" + std::to_string(taskParam->bgModeId_); @@ -1036,7 +1039,6 @@ void BgContinuousTaskMgr::HandleStopContinuousTask(int32_t uid, int32_t pid, uin return; } if (continuousTaskInfosMap_.find(key) == continuousTaskInfosMap_.end()) { - BGTASK_LOGW("remove TaskInfo failure, no matched task: %{public}s", key.c_str()); return; } NotificationTools::GetInstance()->CancelNotification(continuousTaskInfosMap_[key]->GetNotificationLabel(), @@ -1053,7 +1055,6 @@ void BgContinuousTaskMgr::RemoveContinuousTaskRecordByUid(int32_t uid) ++iter; continue; } - BGTASK_LOGW("erase key %{public}s", iter->first.c_str()); iter->second->reason_ = FREEZE_CANCEL; OnContinuousTaskChanged(iter->second, ContinuousTaskEventTriggerType::TASK_CANCEL); NotificationTools::GetInstance()->CancelNotification(iter->second->GetNotificationLabel(), -- Gitee