1 /* 2 * Copyright (c) 2021-2023 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 BASE_NOTIFICATION_ANS_STANDARD_INNERKITS_BASE_INCLUDE_ANS_INNER_ERRORS_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_INNERKITS_BASE_INCLUDE_ANS_INNER_ERRORS_H 18 19 #include <map> 20 #include <sstream> 21 #include "errors.h" 22 23 namespace OHOS { 24 namespace Notification { 25 /** 26 * ErrCode layout 27 * 28 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 * | Bit |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00| 30 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 31 * |Field|Reserved| Subsystem | Module | Code | 32 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 33 */ 34 35 constexpr uint32_t EVENT_SUB_MODULE_OFFSET = 8; // sub-module offset value 36 37 // ANS's module const defined. 38 enum AnsModule : uint32_t { 39 ANS_MODULE_COMMON = 0x00, 40 }; 41 42 // Offset of common event sub-system's errcode base. 43 constexpr ErrCode ANS_COMMON_ERR_OFFSET = ErrCodeOffset(SUBSYS_NOTIFICATION, ANS_MODULE_COMMON); 44 45 // Error code defined. 46 enum ErrorCode : uint32_t { 47 ERR_ANS_SERVICE_NOT_READY = ANS_COMMON_ERR_OFFSET + 1, 48 ERR_ANS_SERVICE_NOT_CONNECTED, 49 ERR_ANS_INVALID_PARAM, 50 ERR_ANS_INVALID_UID, 51 ERR_ANS_NOT_SYSTEM_SERVICE, 52 ERR_ANS_INVALID_PID, 53 ERR_ANS_INVALID_BUNDLE, 54 ERR_ANS_NOT_ALLOWED, 55 ERR_ANS_PARCELABLE_FAILED, 56 ERR_ANS_TRANSACT_FAILED, 57 ERR_ANS_REMOTE_DEAD, 58 ERR_ANS_NO_MEMORY, 59 ERR_ANS_TASK_ERR, 60 ERR_ANS_NON_SYSTEM_APP, 61 ERR_ANS_PERMISSION_DENIED, 62 ERR_ANS_NOTIFICATION_NOT_EXISTS, 63 ERR_ANS_NOTIFICATION_IS_UNREMOVABLE, 64 ERR_ANS_OVER_MAX_ACTIVE_PERSECOND, 65 ERR_ANS_ICON_OVER_SIZE, 66 ERR_ANS_PICTURE_OVER_SIZE, 67 ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED, 68 ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_NOT_EXIST, 69 ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST, 70 ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST, 71 ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST, 72 ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID, 73 ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_EXCEED_MAX_NUM, 74 ERR_ANS_PREFERENCES_NOTIFICATION_READ_TEMPLATE_CONFIG_FAILED, 75 ERR_ANS_DISTRIBUTED_OPERATION_FAILED, 76 ERR_ANS_DISTRIBUTED_GET_INFO_FAILED, 77 ERR_ANS_NOTIFICATION_IS_UNALLOWED_REMOVEALLOWED, 78 ERR_ANS_GET_ACTIVE_USER_FAILED, 79 ERR_ANS_SUBSCRIBER_IS_DELETING, 80 ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_ENABLED, 81 ERR_ANS_DLP_HAP, 82 ERR_ANS_PUSH_CHECK_FAILED, 83 ERR_ANS_DIALOG_POP_SUCCEEDED, 84 ERR_ANS_DIALOG_IS_POPPING, 85 ERR_ANS_PUSH_CHECK_UNREGISTERED, 86 ERR_ANS_REPEAT_CREATE, 87 ERR_ANS_END_NOTIFICATION, 88 ERR_ANS_EXPIRED_NOTIFICATION, 89 ERR_ANS_PUSH_CHECK_NETWORK_UNREACHABLE, 90 ERR_ANS_PUSH_CHECK_EXTRAINFO_INVALID, 91 ERR_ANS_OVER_MAX_UPDATE_PERSECOND, 92 ERR_ANS_DUPLICATE_MSG, 93 ERR_ANS_NO_AGENT_SETTING, 94 ERR_ANS_ENCRYPT_FAIL, 95 ERR_ANS_DECRYPT_FAIL, 96 ERR_ANS_NO_PROFILE_TEMPLATE 97 }; 98 99 enum ReminderErrorCode : uint32_t { 100 ERR_REMINDER_PERMISSION_DENIED = 201, 101 ERR_REMINDER_INVALID_PARAM = 401, 102 ERR_REMINDER_NOTIFICATION_NOT_ENABLE = 1700001, 103 ERR_REMINDER_NUMBER_OVERLOAD, 104 ERR_REMINDER_NOT_EXIST, 105 ERR_REMINDER_PACKAGE_NOT_EXIST, 106 ERR_REMINDER_CALLER_TOKEN_INVALID, 107 ERR_REMINDER_DATA_SHARE_PERMISSION_DENIED, 108 }; 109 110 static std::map<uint32_t, std::string> reminderErrCodeMsgMap = { 111 { ERR_REMINDER_PERMISSION_DENIED, "Permission denied." }, 112 { ERR_REMINDER_INVALID_PARAM, "Parameter error." }, 113 { ERR_REMINDER_NOTIFICATION_NOT_ENABLE, "Notification not enable." }, 114 { ERR_REMINDER_NUMBER_OVERLOAD, "The number of reminders exceeds the limit." }, 115 { ERR_REMINDER_NOT_EXIST, "The reminder not exist." }, 116 { ERR_REMINDER_PACKAGE_NOT_EXIST, "The package name not exist." }, 117 { ERR_REMINDER_CALLER_TOKEN_INVALID, "The caller token invalid." }, 118 { ERR_REMINDER_DATA_SHARE_PERMISSION_DENIED, "The data share permission denied." } 119 }; 120 121 // Notification error msg 122 static inline std::string MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED = "Mandatory parameters are left unspecified."; 123 static inline std::string INCORRECT_PARAMETER_TYPES = "Incorrect parameter types."; 124 static inline std::string PARAMETER_VERIFICATION_FAILED = "Parameter verification failed."; 125 126 // Common error code 127 const uint32_t ERROR_PERMISSION_DENIED = 201; // No permission to call the interface. 128 const uint32_t ERROR_NOT_SYSTEM_APP = 202; // Not system application to call the interface. 129 const uint32_t ERROR_PARAM_INVALID = 401; // Invalid input parameter. 130 const uint32_t ERROR_SYSTEM_CAP_ERROR = 801; // The specified SystemCapability names was not found. 131 132 // Notification error code 133 const int32_t ERROR_INTERNAL_ERROR = 1600001; // Internal error. 134 const int32_t ERROR_IPC_ERROR = 1600002; // Marshalling or unmarshalling error. 135 const int32_t ERROR_SERVICE_CONNECT_ERROR = 1600003; // Failed to connect to the service. 136 const int32_t ERROR_NOTIFICATION_CLOSED = 1600004; // Notification disabled. 137 const int32_t ERROR_SLOT_CLOSED = 1600005; // Notification slot disabled. 138 const int32_t ERROR_NOTIFICATION_UNREMOVABLE = 1600006; // Notification deletion disabled. 139 const int32_t ERROR_NOTIFICATION_NOT_EXIST = 1600007; // The notification does not exist. 140 const int32_t ERROR_USER_NOT_EXIST = 1600008; // The user does not exist. 141 // The notification sending frequency reaches the upper limit. 142 const int32_t ERROR_OVER_MAX_NUM_PER_SECOND = 1600009; 143 const int32_t ERROR_DISTRIBUTED_OPERATION_FAILED = 1600010; // Distributed operation failed. 144 const int32_t ERROR_READ_TEMPLATE_CONFIG_FAILED = 1600011; // Failed to read the template configuration. 145 const int32_t ERROR_NO_MEMORY = 1600012; // No memory space. 146 const int32_t ERROR_DIALOG_IS_POPPING = 1600013; // A notification dialog box is already displayed. 147 const int32_t ERROR_NO_RIGHT = 1600014; // No permission. 148 const int32_t ERROR_REPEAT_SET = 1600015; // Repeat create or end. 149 const int32_t ERROR_EXPIRED_NOTIFICATION = 1600016; // Low update version. 150 const int32_t ERROR_NO_AGENT_SETTING = 1600017; // No corresponding agent relationship configuration. 151 const int32_t ERROR_SETTING_WINDOW_EXIST = 1600018; // The notification settings window is already displayed. 152 const int32_t ERROR_NO_PROFILE_TEMPLATE = 1600019; // Not exit noNotDisturb profile template. 153 const int32_t ERROR_NETWORK_UNREACHABLE = 2300007; // Network unreachable. 154 const int32_t ERROR_BUNDLE_NOT_FOUND = 17700001; // The specified bundle name was not found. 155 } // namespace Notification 156 } // namespace OHOS 157 158 #endif // BASE_NOTIFICATION_ANS_STANDARD_INNERKITS_BASE_INCLUDE_ANS_INNER_ERRORS_H 159