• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 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 };
83 
84 enum ReminderErrorCode : uint32_t {
85     ERR_REMINDER_PERMISSION_DENIED = 201,
86     ERR_REMINDER_INVALID_PARAM = 401,
87     ERR_REMINDER_NOTIFICATION_NOT_ENABLE = 1700001,
88     ERR_REMINDER_NUMBER_OVERLOAD,
89     ERR_REMINDER_NOT_EXIST,
90     ERR_REMINDER_PACKAGE_NOT_EXIST,
91 };
92 
93 static std::map<uint32_t, std::string> reminderErrCodeMsgMap = {
94     { ERR_REMINDER_PERMISSION_DENIED, "BussinessError 201: Permission denied." },
95     { ERR_REMINDER_INVALID_PARAM, "BussinessError 401: Parameter error." },
96     { ERR_REMINDER_NOTIFICATION_NOT_ENABLE, "BussinessError 1700001: Notification not enable." },
97     { ERR_REMINDER_NUMBER_OVERLOAD, "BussinessError 1700002: The number of reminders exceeds the limit." },
98     { ERR_REMINDER_NOT_EXIST, "BussinessError 1700003: The reminder not exist." },
99     { ERR_REMINDER_PACKAGE_NOT_EXIST, "BussinessError 1700004: The package name not exist." }
100 };
101 // Common error code
102 const uint32_t ERROR_PERMISSION_DENIED = 201;          // No permission to call the interface.
103 const uint32_t ERROR_PARAM_INVALID     = 401;          // Invalid input parameter.
104 const uint32_t ERROR_SYSTEM_CAP_ERROR  = 801;          // The specified SystemCapability names was not found.
105 
106 // Notification error code
107 const int32_t ERROR_INTERNAL_ERROR               = 1600001;    // Internal error.
108 const int32_t ERROR_IPC_ERROR                    = 1600002;    // marshalling or unmarshalling error.
109 const int32_t ERROR_SERVICE_CONNECT_ERROR        = 1600003;    // Failed to connect service.
110 const int32_t ERROR_NOTIFICATION_CLOSED          = 1600004;    // Notification is not enabled.
111 const int32_t ERROR_SLOT_CLOSED                  = 1600005;    // Notification slot is not enabled.
112 const int32_t ERROR_NOTIFICATION_UNREMOVABLE     = 1600006;    // Notification is not allowed to remove.
113 const int32_t ERROR_NOTIFICATION_NOT_EXIST       = 1600007;    // The notification is not exist.
114 const int32_t ERROR_USER_NOT_EXIST               = 1600008;    // The user is not exist.
115 const int32_t ERROR_OVER_MAX_NUM_PER_SECOND      = 1600009;    // Over max number notifications per second.
116 const int32_t ERROR_DISTRIBUTED_OPERATION_FAILED = 1600010;    // Distributed operation failed.
117 const int32_t ERROR_READ_TEMPLATE_CONFIG_FAILED  = 1600011;    // Read template config failed.
118 const int32_t ERROR_BUNDLE_NOT_FOUND             = 17700001;   // The specified bundle name was not found.
119 }  // namespace Notification
120 }  // namespace OHOS
121 
122 #endif  // BASE_NOTIFICATION_ANS_STANDARD_INNERKITS_BASE_INCLUDE_ANS_INNER_ERRORS_H
123