1 /* 2 * Copyright (c) 2022 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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_COMMON_INCLUDE_BGTASKMGR_INNER_ERRORS_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_COMMON_INCLUDE_BGTASKMGR_INNER_ERRORS_H 18 19 #include "errors.h" 20 #include <map> 21 22 namespace OHOS { 23 namespace BackgroundTaskMgr { 24 /** 25 * ErrCode layout 26 * 27 * +--+--+--+--+--+--+--+--+---+---+ 28 * |09|08|07|06|05|04|03|02| 01| 00| 29 * +--+--+--+--+--+--+--+--+---+---+ 30 * | Syscap | Code |Subcode| 31 * +--+--+--+--+--+--+--+--+---+---+ 32 */ 33 const int OFFSET = 100; 34 const int THRESHOLD = 1000; 35 // Bgtask Common Error Code Defined. 36 enum : int32_t { 37 // errcode for common 38 ERR_BGTASK_PERMISSION_DENIED = 201, 39 ERR_BGTASK_NOT_SYSTEM_APP = 202, 40 ERR_BGTASK_INVALID_PARAM = 401, 41 // errcode for Continuous Task 42 ERR_BGTASK_NO_MEMORY = 980000101, 43 ERR_BGTASK_PARCELABLE_FAILED = 980000201, 44 ERR_BGTASK_TRANSACT_FAILED = 980000301, 45 ERR_BGTASK_SYS_NOT_READY = 980000401, 46 ERR_BGTASK_SERVICE_NOT_CONNECTED, 47 ERR_BGTASK_OBJECT_EXISTS = 980000501, 48 ERR_BGTASK_OBJECT_NOT_EXIST, 49 ERR_BGTASK_KEEPING_TASK_VERIFY_ERR, 50 ERR_BGTASK_INVALID_BGMODE, 51 ERR_BGTASK_NOTIFICATION_VERIFY_FAILED = 980000601, 52 ERR_BGTASK_NOTIFICATION_ERR, 53 ERR_BGTASK_CHECK_TASK_PARAM, 54 ERR_BGTASK_CREATE_FILE_ERR = 980000701, 55 ERR_BGTASK_GET_ACTUAL_FILE_ERR, 56 ERR_BGTASK_OPEN_FILE_ERR, 57 // errcode for Transient Task 58 ERR_BGTASK_INVALID_PID_OR_UID = 990000101, 59 ERR_BGTASK_INVALID_BUNDLE_NAME, 60 ERR_BGTASK_INVALID_REQUEST_ID, 61 ERR_BGTASK_INVALID_CALLBACK = 990000201, 62 ERR_BGTASK_CALLBACK_EXISTS, 63 ERR_BGTASK_CALLBACK_NOT_EXIST, 64 ERR_BGTASK_NOT_IN_PRESET_TIME, 65 ERR_BGTASK_EXCEEDS_THRESHOLD, 66 ERR_BGTASK_TIME_INSUFFICIENT, 67 // errcode for Efficiency Resource 68 ERR_BGTASK_RESOURCES_EXCEEDS_MAX = 1870000101, 69 ERR_BGTASK_RESOURCES_INVALID_PID_OR_UID, 70 // other inner errcode 71 ERR_BGTASK_METHOD_CALLED_FAILED, 72 ERR_BGTASK_DATA_STORAGE_ERR, 73 ERR_BGTASK_SERVICE_INNER_ERROR, 74 }; 75 76 enum ParamErr: int32_t { 77 ERR_PARAM_NUMBER_ERR = 9800401, 78 ERR_REASON_NULL_OR_TYPE_ERR, 79 ERR_CALLBACK_NULL_OR_TYPE_ERR, 80 ERR_REQUESTID_NULL_OR_ID_TYPE_ERR, 81 ERR_REQUESTID_ILLEGAL, 82 ERR_CONTEXT_NULL_OR_TYPE_ERR, 83 ERR_BGMODE_NULL_OR_TYPE_ERR, 84 ERR_WANTAGENT_NULL_OR_TYPE_ERR, 85 ERR_ABILITY_INFO_EMPTY, 86 ERR_GET_TOKEN_ERR, 87 ERR_BGMODE_RANGE_ERR, 88 ERR_APP_NAME_EMPTY, 89 ERR_RESOURCE_TYPES_INVALID, 90 ERR_ISAPPLY_NULL_OR_TYPE_ERR, 91 ERR_TIMEOUT_INVALID, 92 ERR_ISPERSIST_NULL_OR_TYPE_ERR, 93 ERR_ISPROCESS_NULL_OR_TYPE_ERR, 94 }; 95 96 const inline std::map<int32_t, std::string> saErrCodeMsgMap = { 97 {ERR_BGTASK_PERMISSION_DENIED, "Permission denied."}, 98 {ERR_BGTASK_NOT_SYSTEM_APP, 99 "System API verification failed. Only system application can apply."}, 100 {ERR_BGTASK_NO_MEMORY, "Memory operation failed. Failed to allocate the memory."}, 101 {ERR_BGTASK_SYS_NOT_READY, "System service operation failed. The system service is not ready."}, 102 {ERR_BGTASK_SERVICE_NOT_CONNECTED, "System service operation failed. The system service is not connected."}, 103 {ERR_BGTASK_PARCELABLE_FAILED, "Parcel operation failed."}, 104 {ERR_BGTASK_TRANSACT_FAILED, "IPC failed."}, 105 {ERR_BGTASK_OBJECT_EXISTS, 106 "Continuous Task verification failed. The application has applied for a continuous task."}, 107 {ERR_BGTASK_OBJECT_NOT_EXIST, 108 "Continuous Task verification failed. The application has not applied for a continuous task."}, 109 {ERR_BGTASK_KEEPING_TASK_VERIFY_ERR, 110 "Continuous Task verification failed. TASK_KEEPING background mode only supported in particular device."}, 111 {ERR_BGTASK_INVALID_BGMODE, "Continuous Task verification failed. The bgMode is invalid."}, 112 {ERR_BGTASK_NOTIFICATION_VERIFY_FAILED, 113 "Notification verification failed. The title or text of the notification cannot be empty."}, 114 {ERR_BGTASK_NOTIFICATION_ERR, "Notification verification failed. Failed to send or cancel the notification."}, 115 {ERR_BGTASK_CREATE_FILE_ERR, "Task storage failed. Failed to create the storage task file."}, 116 {ERR_BGTASK_GET_ACTUAL_FILE_ERR, "Task storage failed. Failed to get the actual storage task file."}, 117 {ERR_BGTASK_OPEN_FILE_ERR, "Task storage failed. Failed to open the file."}, 118 {ERR_BGTASK_INVALID_PID_OR_UID, 119 "Caller information verification failed for a transient task. Invalid pid or uid."}, 120 {ERR_BGTASK_INVALID_BUNDLE_NAME, 121 "Caller information verification failed for a transient task. The bundleName cannot be found."}, 122 {ERR_BGTASK_INVALID_REQUEST_ID, 123 "Caller information verification failed for a transient task. Invalid requestId."}, 124 {ERR_BGTASK_INVALID_CALLBACK, 125 "Transient task verification failed. The callback cannot be empty."}, 126 {ERR_BGTASK_CALLBACK_EXISTS, "Transient task verification failed. The callback already exists."}, 127 {ERR_BGTASK_CALLBACK_NOT_EXIST, "Transient task verification failed. The callback does not exist."}, 128 {ERR_BGTASK_NOT_IN_PRESET_TIME, 129 "Transient task verification failed. Request is not allow after the preset time of entering background."}, 130 {ERR_BGTASK_EXCEEDS_THRESHOLD, "Transient task verification failed. The number of request exceeds the threshold."}, 131 {ERR_BGTASK_TIME_INSUFFICIENT, 132 "Transient task verification failed. The remaining time to run transient task is insufficient."}, 133 {ERR_BGTASK_RESOURCES_EXCEEDS_MAX, "Caller information verification failed when applying for" 134 " efficiency resources. The number of resources applied exceeds maximun."}, 135 {ERR_BGTASK_SERVICE_INNER_ERROR, "Service inner error."}, 136 }; 137 138 const inline std::map<int32_t, std::string> paramErrCodeMsgMap = { 139 {ERR_PARAM_NUMBER_ERR, "The number of arguments is wrong."}, 140 {ERR_REASON_NULL_OR_TYPE_ERR, "The reason cannot be null and its type must be string."}, 141 {ERR_CALLBACK_NULL_OR_TYPE_ERR, "The callback cannot be null and its type must be function."}, 142 {ERR_REQUESTID_NULL_OR_ID_TYPE_ERR, "The requestId cannot be null and its type must be integer."}, 143 {ERR_REQUESTID_ILLEGAL, "The requestId must be greater than 0."}, 144 {ERR_CONTEXT_NULL_OR_TYPE_ERR, "The context cannot be null and its type must be Context."}, 145 {ERR_BGMODE_NULL_OR_TYPE_ERR, "The bgMode cannot be null and its type must be BackgroundMode object."}, 146 {ERR_WANTAGENT_NULL_OR_TYPE_ERR, "The wantAgent cannot be null and its type must be WantAgent object."}, 147 {ERR_ABILITY_INFO_EMPTY, "The abilityInfo of context cannot be null."}, 148 {ERR_GET_TOKEN_ERR, "The token of context cannot be null."}, 149 {ERR_BGMODE_RANGE_ERR, "The value of bgMode ranges from BG_MODE_ID_BEGIN to BG_MODE_ID_END."}, 150 {ERR_APP_NAME_EMPTY, "The app name of abilityInfo in context cannot be null."}, 151 {ERR_RESOURCE_TYPES_INVALID, "The resourcesType cannot be null and must be integer greater than 0."}, 152 {ERR_ISAPPLY_NULL_OR_TYPE_ERR, "The isApply cannot be null and its type must be boolean."}, 153 {ERR_TIMEOUT_INVALID, "The timeOut cannot be null and must be integer greater than 0."}, 154 {ERR_ISPERSIST_NULL_OR_TYPE_ERR, "The isPersist cannot be null and must be boolean."}, 155 {ERR_ISPROCESS_NULL_OR_TYPE_ERR, "The isProcess cannot be null and must be boolean."}, 156 {ERR_BGTASK_INVALID_PARAM, "The input param is invalid."} 157 }; 158 159 } // namespace BackgroundTaskMgr 160 } // namespace OHOS 161 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_COMMON_INCLUDE_BGTASKMGR_INNER_ERRORS_H