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 OHOS_MEDIALIBRARY_ERRNO_H 17#define OHOS_MEDIALIBRARY_ERRNO_H 18 19#include <errno.h> 20#include <stdint.h> 21 22namespace OHOS { 23namespace Media { 24#define MEDIA_LIBRARY_ERR(offset, errCode) (-((offset) + (errCode))) 25 26// common error code 27// linux standard ERROR { 0, 200 } 28constexpr int32_t E_OK = 0; 29constexpr int32_t E_SUCCESS = 0; 30#ifdef MEDIALIBRARY_MTP_ENABLE 31constexpr int32_t MTP_SUCCESS = 0; 32#endif 33constexpr int32_t E_ERR = -1; 34constexpr int32_t E_PERMISSION_DENIED = -EACCES; 35constexpr int32_t E_NO_SUCH_FILE = -ENOENT; 36constexpr int32_t E_FILE_EXIST = -EEXIST; 37constexpr int32_t E_NO_MEMORY = -ENOMEM; 38constexpr int32_t E_NO_SPACE = -ENOSPC; 39constexpr int32_t E_CHECK_SYSTEMAPP_FAIL = 202; 40 41// medialibary inner common err { 200, 1999 } 42constexpr int32_t E_COMMON_OFFSET = 200; 43constexpr int32_t E_COMMON_START = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 0); 44constexpr int32_t E_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 0); 45constexpr int32_t E_FILE_OPER_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 1); 46constexpr int32_t E_HAS_FS_ERROR = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 3); 47constexpr int32_t E_CHECK_DIR_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 4); 48constexpr int32_t E_MODIFY_DATA_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 5); 49constexpr int32_t E_INVALID_VALUES = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 6); 50constexpr int32_t E_INVALID_URI = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 7); 51constexpr int32_t E_INVALID_FILEID = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 8); 52constexpr int32_t E_INVALID_PATH = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 9); 53constexpr int32_t E_VIOLATION_PARAMETERS = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 10); 54constexpr int32_t E_RENAME_DIR_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 11); 55constexpr int32_t E_GET_VALUEBUCKET_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 12); 56constexpr int32_t E_GET_ASSET_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 13); 57constexpr int32_t E_GET_HASH_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 14); 58constexpr int32_t E_GET_CLIENTBUNDLE_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 15); 59constexpr int32_t E_EXIST_IN_DB = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 16); 60constexpr int32_t E_INVALID_MODE = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 17); 61constexpr int32_t E_INVALID_BUNDLENAME = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 18); 62constexpr int32_t E_RENAME_FILE_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 19); 63constexpr int32_t E_DB_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 20); 64constexpr int32_t E_DELETE_DENIED = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 21); 65constexpr int32_t E_HAS_DB_ERROR = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 22); 66constexpr int32_t E_INVALID_ARGUMENTS = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 23); 67constexpr int32_t E_SQL_CHECK_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 24); 68constexpr int32_t E_IS_PENDING_ERROR = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 25); 69constexpr int32_t E_NEED_FURTHER_CHECK = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 26); 70constexpr int32_t E_CHECK_NATIVE_SA_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 27); 71constexpr int32_t E_INVALID_TIMESTAMP = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 28); 72constexpr int32_t E_GRANT_URI_PERM_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 29); 73constexpr int32_t E_IS_IN_COMMIT = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 30); 74constexpr int32_t E_IS_IN_REVERT = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 31); 75constexpr int32_t E_GET_PRAMS_FAIL = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 32); 76constexpr int32_t E_INVALID_MOVING_PHOTO = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 33); 77constexpr int32_t E_INVALID_LIVE_PHOTO = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 34); 78constexpr int32_t E_COMMON_END = MEDIA_LIBRARY_ERR(E_COMMON_OFFSET, 1799); 79 80// medialibary directory and file type control { 2000, 2099 } 81constexpr int32_t E_DIR_CTRL_OFFSET = 2000; 82constexpr int32_t E_CHECK_EXTENSION_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 0); 83constexpr int32_t E_DELETE_DIR_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 1); 84constexpr int32_t E_CHECK_MEDIATYPE_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 2); 85constexpr int32_t E_CHECK_ROOT_DIR_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 3); 86constexpr int32_t E_CHECK_MEDIATYPE_MATCH_EXTENSION_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 4); 87constexpr int32_t E_FILE_NAME_INVALID = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 5); 88constexpr int32_t E_ALBUM_OPER_ERR = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 6); 89constexpr int32_t E_DIR_OPER_ERR = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 7); 90constexpr int32_t E_SAME_PATH = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 8); 91constexpr int32_t E_DIR_CHECK_DIR_FAIL = MEDIA_LIBRARY_ERR(E_DIR_CTRL_OFFSET, 9); 92 93// medialibary recycle, trash { 2100, 2199 } 94constexpr int32_t E_TRASH_OFFSET = 2100; 95constexpr int32_t E_RECYCLE_FILE_IS_NULL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 0); 96constexpr int32_t E_IS_RECYCLED = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 1); 97constexpr int32_t E_RECYCLE_DIR_FAIL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 2); 98constexpr int32_t E_CREATE_TRASHDIR_FAIL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 3); 99constexpr int32_t E_MAKE_HASHNAME_FAIL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 4); 100constexpr int32_t E_GET_EXTENSION_FAIL = MEDIA_LIBRARY_ERR(E_TRASH_OFFSET, 5); 101 102 103// medialibary distributed { 2200, 2299 } 104constexpr int32_t E_DISTRIBUTED_OFFSET = 2200; 105constexpr int32_t E_DEVICE_OPER_ERR = MEDIA_LIBRARY_ERR(E_DISTRIBUTED_OFFSET, 0); 106 107// medialibary thumbanail { 2300, 2399 } 108constexpr int32_t E_THUMBNAIL_OFFSET = 2300; 109constexpr int32_t E_THUMBNAIL_CONNECT_TIMEOUT = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 0); 110constexpr int32_t E_THUMBNAIL_HAS_OPENED_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 1); 111constexpr int32_t E_THUMBNAIL_LOCAL_CREATE_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 2); 112constexpr int32_t E_THUMBNAIL_REMOTE_CREATE_FAIL = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 3); 113constexpr int32_t E_THUMBNAIL_SERVICE_NULLPTR = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 4); 114constexpr int32_t E_THUMBNAIL_INVALID_SIZE = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 5); 115constexpr int32_t E_THUMBNAIL_UNKNOWN = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 6); 116constexpr int32_t E_THUMBNAIL_ASTC_ALL_EXIST = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 7); 117constexpr int32_t E_THUMBNAIL_LCD_ALL_EXIST = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 8); 118constexpr int32_t E_CLOUD_THUMBNAIL_NOT_DOWNLOAD_FINISH = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 9); 119constexpr int32_t E_CLOUD_NOT_SUITABLE_FOR_TASK = MEDIA_LIBRARY_ERR(E_THUMBNAIL_OFFSET, 10); 120 121// medialibary scanner { 2400, 2499 } 122constexpr int32_t E_SCANNER_OFFSET = 2400; 123constexpr int32_t E_FILE_HIDDEN = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 0); 124constexpr int32_t E_DIR_HIDDEN = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 1); 125constexpr int32_t E_RDB = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 2); 126constexpr int32_t E_DATA = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 3); 127constexpr int32_t E_SYSCALL = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 4); 128constexpr int32_t E_SCANNED = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 5); 129constexpr int32_t E_AVMETADATA = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 6); 130constexpr int32_t E_IMAGE = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 7); 131constexpr int32_t E_NO_RESULT = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 8); 132constexpr int32_t E_STOP = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 9); 133constexpr int32_t E_IS_PENDING = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 10); 134constexpr int32_t E_MOVING_PHOTO = MEDIA_LIBRARY_ERR(E_SCANNER_OFFSET, 11); 135 136// media file extension module error code { 3000, 3099 } 137constexpr int32_t E_MEDIA_FILE_OFFSET = 3000; 138constexpr int32_t E_URI_INVALID = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 0); 139constexpr int32_t E_DISTIBUTED_URI_NO_SUPPORT = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 1); 140constexpr int32_t E_URI_IS_NOT_ALBUM = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 2); 141constexpr int32_t E_URI_IS_NOT_FILE = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 3); 142constexpr int32_t E_TWO_URI_ARE_THE_SAME = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 4); 143constexpr int32_t E_OPENFILE_INVALID_FLAG = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 5); 144constexpr int32_t E_INVALID_DISPLAY_NAME = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 6); 145constexpr int32_t E_DENIED_MOVE = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 7); 146constexpr int32_t E_UPDATE_DB_FAIL = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 8); 147constexpr int32_t E_DENIED_RENAME = MEDIA_LIBRARY_ERR(E_MEDIA_FILE_OFFSET, 9); 148 149#ifdef MEDIALIBRARY_MTP_ENABLE 150// common error {14000, 14099} 151constexpr int32_t E_MTP_COMMON_OFFSET = 14000; 152constexpr int32_t MTP_FAIL = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 0); 153constexpr int32_t MTP_ERROR_SESSION_ALREADY_OPEN = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 1); 154constexpr int32_t MTP_ERROR_CONTEXT_IS_NULL = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 2); 155constexpr int32_t MTP_ERROR_PACKET_INCORRECT = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 3); 156constexpr int32_t MTP_ERROR_NO_THIS_FILE = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 4); 157constexpr int32_t MTP_ERROR_INCOMPLETE_TRANSFER = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 5); 158constexpr int32_t MTP_ERROR_SESSION_NOT_OPEN = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 6); 159constexpr int32_t MTP_ERROR_INVALID_STORAGE_ID = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 7); 160constexpr int32_t MTP_ERROR_INVALID_OBJECTHANDLE = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 8); 161constexpr int32_t MTP_ERROR_DEVICEPROP_NOT_SUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 9); 162constexpr int32_t MTP_ERROR_DRIVER_OPEN_FAILED = MEDIA_LIBRARY_ERR(E_MTP_COMMON_OFFSET, 10); 163 164// medialibrary error { 15000, 15099 } 165constexpr int32_t E_MTP_MEDIALIBRARY_OFFSET = 15000; 166constexpr int32_t MTP_ERROR_STORE_NOT_AVAILABLE = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 0); 167constexpr int32_t MTP_ERROR_NO_THUMBNAIL_PRESENT = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 1); 168constexpr int32_t MTP_ERROR_INVALID_PARENTOBJECT = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 2); 169constexpr int32_t MTP_ERROR_PARAMETER_NOT_SUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 3); 170constexpr int32_t MTP_ERROR_INVALID_OBJECTPROP_VALUE = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 4); 171constexpr int32_t MTP_ERROR_INVALID_OBJECTPROP_FORMAT = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 5); 172constexpr int32_t MTP_ERROR_INVALID_OBJECTPROPCODE = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 6); 173constexpr int32_t MTP_ERROR_ACCESS_DENIED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 7); 174constexpr int32_t MTP_ERROR_SPECIFICATION_BY_GROUP_UNSUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 8); 175constexpr int32_t MTP_ERROR_SPECIFICATION_BY_DEPTH_UNSUPPORTED = MEDIA_LIBRARY_ERR(E_MTP_MEDIALIBRARY_OFFSET, 9); 176#endif 177 178// media smart album module error code { 4000, 4099 } 179constexpr int32_t E_MEDIA_SMART_OFFSET = 4000; 180constexpr int32_t E_PARENT_SMARTALBUM_IS_NOT_EXISTED = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 0); 181constexpr int32_t E_PARENT_SMARTALBUM_CAN_NOT_DELETE = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 1); 182constexpr int32_t E_DELETE_SMARTALBUM_MAP_FAIL = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 2); 183constexpr int32_t E_SMARTALBUM_IS_NOT_EXISTED = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 3); 184constexpr int32_t E_CHILD_CAN_NOT_ADD_SMARTALBUM = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 4); 185constexpr int32_t E_TRASHALBUM_CAN_NOT_DELETE = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 5); 186constexpr int32_t E_FAVORITEALBUM_CAN_NOT_DELETE = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 6); 187constexpr int32_t E_PARENT_CAN_NOT_ADDASSETS = MEDIA_LIBRARY_ERR(E_MEDIA_SMART_OFFSET, 7); 188 189 190// media on notify module error code { 16000, 16099 } 191constexpr int32_t E_MEDIA_NOTIFY_OFFSET = 16000; 192constexpr int32_t E_ASYNC_WORKER_IS_NULL = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 0); 193constexpr int32_t E_NOTIFY_TASK_DATA_IS_NULL = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 1); 194constexpr int32_t E_SOLVE_URIS_FAILED = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 2); 195constexpr int32_t E_NOTIFY_CHANGE_EXT_FAILED = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 3); 196constexpr int32_t E_PARCEL_GET_SIZE_FAILED = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 4); 197constexpr int32_t E_GET_ALBUM_ID_FAILED = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 5); 198constexpr int32_t E_DO_NOT_NEDD_SEND_NOTIFY = MEDIA_LIBRARY_ERR(E_MEDIA_NOTIFY_OFFSET, 6); 199} // namespace Media 200} // namespace OHOS 201#endif // OHOS_MEDIALIBRARY_ERRNO_H 202