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_API_H 17 #define OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_API_H 18 19 #include <stdint.h> 20 21 #include "transient_task_type.h" 22 23 /** 24 * @addtogroup TransientTask 25 * @{ 26 * 27 * @brief Provide C interface for the Transient task management. 28 * 29 * @since 13 30 * @version 1.0 31 */ 32 33 /** 34 * @file transient_task_api.h 35 * 36 * @brief Declares the APIs for Transient task management. 37 * 38 * @library libtransient_task.so 39 * @kit BackgroundTasksKit 40 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 41 * @since 13 42 */ 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** 49 * @brief Requests delayed transition to the suspended state. 50 * 51 * @param reason Indicates the reason for delayed transition to the suspended state. 52 * @param callback Indicates the callback delay time expired. 53 * @param delaySuspendInfo Indicates the info of delay request. 54 * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. 55 * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. 56 * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. 57 * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. 58 * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. 59 * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. 60 * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. 61 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 62 * @since 13 63 * @version 1.0 64 */ 65 int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason, 66 TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info); 67 68 /** 69 * @brief Obtains the remaining time before an application enters the suspended state. 70 * 71 * @param requestId Indicates the identifier of the delay request. 72 * @param time Indicates the remaining Time. 73 * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. 74 * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. 75 * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. 76 * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. 77 * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. 78 * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. 79 * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. 80 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 81 * @since 13 82 * @version 1.0 83 */ 84 int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime); 85 86 /** 87 * @brief Cancels delayed transition to the suspended state. 88 * 89 * @param requestId Indicates the identifier of the delay request. 90 * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. 91 * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. 92 * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. 93 * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. 94 * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. 95 * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. 96 * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. 97 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 98 * @since 13 99 * @version 1.0 100 */ 101 int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId); 102 103 #ifdef __cplusplus 104 } 105 #endif 106 /** @} */ 107 #endif 108