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 /** 17 * @addtogroup TransientTask 18 * @{ 19 20 * @brief Provide C interface for the transient task management. 21 * @since 13 22 * @version 1.0 23 */ 24 25 /** 26 * @file transient_task_type.h 27 * 28 * @brief Defines the data structures for the C APIs of transient task. 29 * 30 * @library libtransient_task.so 31 * @kit BackgroundTasksKit 32 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 33 * @since 11 34 */ 35 36 #ifndef OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H 37 #define OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H 38 39 #include <stdint.h> 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /** 46 * @brief max number for transient task. 47 * 48 * @since 20 49 */ 50 #define TRANSIENT_TASK_MAX_NUM 3 51 52 /** 53 * @brief Enum for transient task error code. 54 * @since 13 55 */ 56 typedef enum TransientTask_ErrorCode { 57 /** 58 * @error result is ok. 59 */ 60 ERR_TRANSIENT_TASK_OK = 0, 61 /** 62 * @error Parameter error. Possible causes: 63 * 1. Mandatory parameters are left unspecified; 64 * 2. Incorrect parameters types. 65 */ 66 ERR_TRANSIENT_TASK_INVALID_PARAM = 401, 67 /** 68 * @error Parcel operation failed. 69 */ 70 ERR_TRANSIENT_TASK_PARCEL_FAILED = 9800002, 71 /** 72 * @error Internal transaction failed. 73 */ 74 ERR_TRANSIENT_TASK_TRANSACTION_FAILED = 9800003, 75 /** 76 * @error System service operation failed. 77 */ 78 ERR_TRANSIENT_TASK_SYS_NOT_READY = 9800004, 79 /** 80 * Caller information verification failed for a transient task. 81 */ 82 ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED = 9900001, 83 /** 84 * Transient task verification failed. 85 */ 86 ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED = 9900002, 87 /** 88 * @error Failed to write data into parcel. Possible reasons: 89 * 1. Invalid parameters; 90 * 2. Failed to apply for memory. 91 */ 92 ERR_TRANSIENT_TASK_PARCELABLE_FAILED = 9900003, 93 /** 94 * @error System service operation failed. 95 */ 96 ERR_TRANSIENT_TASK_SERVICE_NOT_READY = 9900004, 97 } TransientTask_ErrorCode; 98 99 /** 100 * @brief Define DelaySuspendInfo for TransientTask. 101 * 102 * @since 13 103 * @version 1.0 104 */ 105 typedef struct TransientTask_DelaySuspendInfo { 106 /** The unique identifier of the delay request */ 107 int32_t requestId; 108 /** The actual delay duration (ms) */ 109 int32_t actualDelayTime; 110 } TransientTask_DelaySuspendInfo; 111 112 /** 113 * @brief Define TransientTaskInfo for an application. 114 * 115 * @since 20 116 * @version 1.0 117 */ 118 typedef struct TransientTask_TransientTaskInfo { 119 /** The remaining quota of the delay request */ 120 int32_t remainingQuota; 121 /** The info of delay suspend */ 122 TransientTask_DelaySuspendInfo transientTasks[TRANSIENT_TASK_MAX_NUM]; 123 } TransientTask_TransientTaskInfo; 124 125 /** 126 * @brief Define a callback function when delay time expired. 127 * @since 13 128 */ 129 typedef void (*TransientTask_Callback)(void); 130 131 #ifdef __cplusplus 132 } 133 #endif 134 /** @} */ 135 #endif 136