长时任务回调信息添加tokenId

Signed-off-by: 胡伟 <huwei169@huawei.com>
This commit is contained in:
h30045808 2024-05-05 11:14:33 +08:00
parent a607c7afc3
commit c32cfd0810
3 changed files with 10 additions and 3 deletions

View File

@ -28,9 +28,10 @@ public:
ContinuousTaskCallbackInfo();
ContinuousTaskCallbackInfo(uint32_t typeId, int32_t creatorUid,
pid_t creatorPid, std::string abilityName, bool isFromWebview = false, bool isBatchApi = false,
const std::vector<uint32_t> &typeIds = {}, int32_t abilityId = -1)
const std::vector<uint32_t> &typeIds = {}, int32_t abilityId = -1, uint64_t tokenId = 0)
: typeId_(typeId), creatorUid_(creatorUid), creatorPid_(creatorPid), abilityName_(abilityName),
isFromWebview_(isFromWebview), isBatchApi_(isBatchApi), typeIds_(typeIds), abilityId_(abilityId) {}
isFromWebview_(isFromWebview), isBatchApi_(isBatchApi), typeIds_(typeIds), abilityId_(abilityId),
tokenId_(tokenId) {}
/**
* @brief Get the id of type.
@ -110,6 +111,7 @@ private:
bool isBatchApi_ {false};
std::vector<uint32_t> typeIds_ {};
int32_t abilityId_ {-1};
uint64_t tokenId_ {0};
};
} // namespace BackgroundTaskMgr
} // namespace OHOS

View File

@ -103,6 +103,10 @@ bool ContinuousTaskCallbackInfo::Marshalling(Parcel &parcel) const
BGTASK_LOGE("Failed to write abilityId_");
return false;
}
if (!parcel.WriteUint64(tokenId_)) {
BGTASK_LOGE("Failed to write tokenId_");
return false;
}
return true;
}
@ -145,6 +149,7 @@ bool ContinuousTaskCallbackInfo::ReadFromParcel(Parcel &parcel)
}
BGTASK_LOGD("read parce typeIds_ size %{public}u", static_cast<uint32_t>(typeIds_.size()));
abilityId_ = static_cast<int32_t>(parcel.ReadInt32());
tokenId_ = parcel.ReadUint64();
return true;
}
} // namespace BackgroundTaskMgr

View File

@ -1285,7 +1285,7 @@ void BgContinuousTaskMgr::OnContinuousTaskChanged(const std::shared_ptr<Continuo
= std::make_shared<ContinuousTaskCallbackInfo>(continuousTaskInfo->GetBgModeId(),
continuousTaskInfo->GetUid(), continuousTaskInfo->GetPid(), continuousTaskInfo->GetAbilityName(),
continuousTaskInfo->IsFromWebview(), continuousTaskInfo->isBatchApi_, continuousTaskInfo->bgModeIds_,
continuousTaskInfo->abilityId_);
continuousTaskInfo->abilityId_, continuousTaskInfo->fullTokenId_);
BGTASK_LOGD("mdoe %{public}d isBatch %{public}d modes size %{public}u",
continuousTaskCallbackInfo->GetTypeId(), continuousTaskCallbackInfo->IsBatchApi(),
static_cast<uint32_t>(continuousTaskCallbackInfo->GetTypeIds().size()));