1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H
17 #define OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H
18 
19 /**
20  * @addtogroup TransientTask
21  * @{
22 
23  * @brief Provide C interface for the transient task management.
24  * @since 13
25  * @version 1.0
26  */
27 
28 /**
29  * @file transient_task_type.h
30  *
31  * @brief Defines the data structures for the C APIs of transient task.
32  *
33  * @library libtransient_task.so
34  * @kit BackgroundTasksKit
35  * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
36  * @since 11
37  */
38 
39 #include <stdint.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 /**
45  * @brief Enum for transient task error code.
46  * @since 13
47  */
48 typedef enum TransientTask_ErrorCode {
49     /**
50      * @error result is ok.
51      */
52     ERR_TRANSIENT_TASK_OK = 0,
53     /**
54      * @error Parameter error. Possible causes:
55      * 1. Mandatory parameters are left unspecified;
56      * 2. Incorrect parameters types.
57      */
58     ERR_TRANSIENT_TASK_INVALID_PARAM = 401,
59     /**
60      * @error Parcel operation failed.
61      */
62     ERR_TRANSIENT_TASK_PARCEL_FAILED = 9800002,
63     /**
64      * @error Internal transaction failed.
65      */
66     ERR_TRANSIENT_TASK_TRANSACTION_FAILED = 9800003,
67     /**
68      * @error System service operation failed.
69      */
70     ERR_TRANSIENT_TASK_SYS_NOT_READY = 9800004,
71     /**
72      * Caller information verification failed for a transient task.
73      */
74     ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED = 9900001,
75     /**
76      * Transient task verification failed.
77      */
78     ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED = 9900002,
79 } TransientTask_ErrorCode;
80 
81 /**
82  * @brief Define DelaySuspendInfo for TransientTask.
83  *
84  * @since 13
85  * @version 1.0
86  */
87 typedef struct TransientTask_DelaySuspendInfo {
88     /** The unique identifier of the delay request */
89     int32_t requestId;
90     /** The actual delay duration (ms) */
91     int32_t actualDelayTime;
92 } TransientTask_DelaySuspendInfo;
93 
94 /**
95  * @brief Define a callback function when delay time expired.
96  * @since 13
97  */
98 typedef void (*TransientTask_Callback)(void);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 /** @} */
104 #endif
105