1# transient_task_api.h 2 3## Overview 4 5The **transient_task_api.h** file declares the APIs for requesting, querying, and canceling transient tasks. 6 7**File to include**: <transient_task/transient_task_api.h> 8 9**Library**: libtransient_task.so 10 11**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 12 13**Since**: 13 14 15**Related module**: [TransientTask](capi-transienttask.md) 16 17## Summary 18 19### Functions 20 21| Name| Description| 22| -- | -- | 23| [int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason,TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info)](#oh_backgroundtaskmanager_requestsuspenddelay) | Requests a transient task.| 24| [int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime)](#oh_backgroundtaskmanager_getremainingdelaytime) | Obtains the remaining time of a transient task.| 25| [int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId)](#oh_backgroundtaskmanager_cancelsuspenddelay) | Cancels a transient task.| 26| [int32_t OH_BackgroundTaskManager_GetTransientTaskInfo(TransientTask_TransientTaskInfo *transientTaskInfo)](#oh_backgroundtaskmanager_gettransienttaskinfo) | Obtains all information about a transient task, including the remaining quota of the current day.| 27 28## Function Description 29 30### OH_BackgroundTaskManager_RequestSuspendDelay() 31 32``` 33int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason,TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info) 34``` 35 36**Description** 37 38Requests a transient task. 39 40**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 41 42**Since**: 13 43 44 45**Parameters** 46 47| Name | Description| 48|----------------------------------------------------------------------------------------------| -- | 49| const char* reason | Reason for requesting the transient task.| 50| [TransientTask_Callback](capi-transient-task-type-h.md#transienttask_callback) callback | Callback used to notify the application that the transient task is about to time out. Generally, the callback is invoked 6 seconds before the timeout.| 51| [TransientTask_DelaySuspendInfo](capi-transienttask-transienttask-delaysuspendinfo.md) *info | Information about the transient task.| 52 53**Return value** 54 55| Type| Description| 56| -- | -- | 57| int32_t | Returns 0 if the operation is successful.<br> Returns 401 if the input parameter is incorrect.<br> Returns 9800002 if the Parcel read/write operation fails.<br> Returns 9800003 if the IPC fails.<br> Returns 9800004 if the system service fails.<br> Returns 9900001 if the client information of the transient task fails to be verified.<br> Returns 9900002 if the server information of the transient task fails to be verified.<br> For details about the error codes, see [TransientTask_ErrorCode](capi-transient-task-type-h.md#transienttask_errorcode).| 58 59### OH_BackgroundTaskManager_GetRemainingDelayTime() 60 61``` 62int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime) 63``` 64 65**Description** 66 67Obtains the remaining time of a transient task. 68 69**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 70 71**Since**: 13 72 73 74**Parameters** 75 76| Name| Description| 77| -- | -- | 78| int32_t requestId | Request ID of the transient task.| 79| int32_t *delayTime | Pointer to the remaining time.| 80 81**Return value** 82 83| Type| Description| 84| -- | -- | 85| int32_t | Returns 0 if the operation is successful.<br> Returns 401 if the input parameter is incorrect.<br> Returns 9800002 if the Parcel read/write operation fails.<br> Returns 9800003 if the IPC fails.<br> Returns 9800004 if the system service fails.<br> Returns 9900001 if the client information of the transient task fails to be verified.<br> Returns 9900002 if the server information of the transient task fails to be verified.<br> For details about the error codes, see [TransientTask_ErrorCode](capi-transient-task-type-h.md#transienttask_errorcode).| 86 87### OH_BackgroundTaskManager_CancelSuspendDelay() 88 89``` 90int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId) 91``` 92 93**Description** 94 95Cancels a transient task. 96 97**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 98 99**Since**: 13 100 101 102**Parameters** 103 104| Name| Description| 105| -- | -- | 106| int32_t requestId | Request ID of the transient task.| 107 108**Return value** 109 110| Type| Description| 111| -- | -- | 112| int32_t | Returns 0 if the operation is successful.<br> Returns 401 if the input parameter is incorrect.<br> Returns 9800002 if the Parcel read/write operation fails.<br> Returns 9800003 if the IPC fails.<br> Returns 9800004 if the system service fails.<br> Returns 9900001 if the client information of the transient task fails to be verified.<br> Returns 9900002 if the server information of the transient task fails to be verified.<br> For details about the error codes, see [TransientTask_ErrorCode](capi-transient-task-type-h.md#transienttask_errorcode).| 113 114### OH_BackgroundTaskManager_GetTransientTaskInfo() 115 116``` 117int32_t OH_BackgroundTaskManager_GetTransientTaskInfo(TransientTask_TransientTaskInfo *transientTaskInfo) 118``` 119 120**Description** 121 122Obtains all information about a transient task, including the remaining quota of the current day. 123 124**Since**: 20 125 126 127**Parameters** 128 129| Name | Description | 130|--------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| 131| [TransientTask_TransientTaskInfo ](capi-transienttask-transienttask-transienttaskinfo.md) *transientTaskInfo | All information about a transient task. For details, see [TransientTask_TransientTaskInfo](capi-transienttask-transienttask-transienttaskinfo.md).| 132 133**Return value** 134 135| Type| Description| 136| -- | -- | 137| int32_t | Returns 0 if the operation is successful.<br> Returns 9900001 if the client information of the transient task fails to be verified.<br> Returns 9900003 if the Parcel read/write operation fails.<br> Returns 9900004 if the system service fails.<br> For details about the error codes, see [TransientTask_ErrorCode](capi-transient-task-type-h.md#transienttask_errorcode).| 138