diff --git a/zh-cn/native_sdk/backgroundtasks/transient/transient_task_api.h b/zh-cn/native_sdk/backgroundtasks/transient/transient_task_api.h index 4546bc055deb05b640b3dc7884e4c7349d62c4e9..43c7ca8b739619821682a5d70c2704aa131f9bd8 100644 --- a/zh-cn/native_sdk/backgroundtasks/transient/transient_task_api.h +++ b/zh-cn/native_sdk/backgroundtasks/transient/transient_task_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -103,6 +103,22 @@ int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_ */ int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId); +/** + * @brief 获取所有短时任务信息。 + * + * @param transientTaskInfo 短时任务信息 + * @return 返回0,表示取消成功。 + * 返回401,表示入参错误。 + * 返回9800001,表示申请内存失败。 + * 返回9800002,表示Parcel读写操作失败。 + * 返回9800004,表示系统服务失败。 + * 错误码的具体信息请参考{@link TransientTask_ErrorCode}。 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 20 + * @version 1.0 + */ +int32_t OH_BackgroundTaskManager_GetAllTransientTasks(TransientTask_TransientTaskInfo *transientTaskInfo); + #ifdef __cplusplus } #endif diff --git a/zh-cn/native_sdk/backgroundtasks/transient/transient_task_type.h b/zh-cn/native_sdk/backgroundtasks/transient/transient_task_type.h index 8b149a6f06dbfd3b16d4c93b39cdfb66525f660f..ce0a80b08295396b50c9ba5ce668a2f39478e4d6 100644 --- a/zh-cn/native_sdk/backgroundtasks/transient/transient_task_type.h +++ b/zh-cn/native_sdk/backgroundtasks/transient/transient_task_type.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -37,6 +37,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -54,6 +55,10 @@ typedef enum TransientTask_ErrorCode { * @error 参数检查失败。可能原因:1.必选参数没有传入。2.参数类型错误。 */ ERR_TRANSIENT_TASK_INVALID_PARAM = 401, + /** + * @error 申请内存操作失败。 + */ + ERR_TRANSIENT_TASK_MEMORYL_FAILED = 9800001, /** * @error Parcel读写操作失败。 */ @@ -89,6 +94,19 @@ typedef struct TransientTask_DelaySuspendInfo { int32_t actualDelayTime; } TransientTask_DelaySuspendInfo; +/** + * @brief 定义所有短时任务返回信息结构体。 + * + * @since 20 + * @version 1.0 + */ +typedef struct TransientTask_TransientTaskInfo { + /** 应用当日剩余总时间(单位:毫秒) */ + int32_t remainingQuota; + /** 已申请短时任务信息 */ + std::vector transientTasks; +} TransientTask_TransientTaskInfo; + /** * @brief 定义短时任务超时回调类型。 * @since 13