• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_IPC_DBINDER_ERROR_CODE_H
17 #define OHOS_IPC_DBINDER_ERROR_CODE_H
18 
19 #include<string>
20 #ifndef BUILD_PUBLIC_VERSION
21 #include "hiview.h"
22 #include "hievent.h"
23 #endif
24 
25 namespace OHOS {
26 class DbinderErrorCode {
27 public:
28     static const int SYSTEM_ENVIRONMENT_ERROR = 950000601;
29     static const int NETWORK_ERROR = 950000602;
30     static const int SKELETON_ERROR = 950000603;
31     static const int DBINDER_SERVICE_ERROR = 950000604;
32     static const int TRANSMISSION_ERROR = 950000605;
33     static const int COMMON_DRIVER_ERROR = 950000606;
34     static const int KERNEL_DRIVER_ERROR = 950000607;
35     static const int SOCKET_DRIVER_ERROR = 950000608;
36 
37     inline static const std::string ERROR_TYPE = "ErrType";
38     inline static const std::string ERROR_CODE = "ErrCode";
39 
40     // 601
41     enum SystemEnvironmentError {
42         CREATE_EPOLL = 1,
43         BIND_EPOLL,
44         REMOVE_EPOLL,
45     };
46 
47     // 602
48     enum NetworkError {
49         WRONG_DEVICE_ID = 1,
50         WRONG_SUBSCRIPTION,
51     };
52 
53     // 603
54     enum SkeletonError {
55         WRONG_KERNEL_DRIVER = 1,
56         WRONG_SOCKET_DRIVER,
57         WRONG_TYPE_PROXY,
58         UPDATE_SESSION_FAILURE,
59         RELEASE_FD_FAILURE,
60         RELEASE_SESSION_FAILURE,
61         UNKNOWN_CMD,
62     };
63 
64     // 604
65     enum DbinderServiceError {
66         START_DBS_FAILURE = 1,
67         CLOSE_DBS_FAILURE,
68         WRONG_INPUT_PARAMETER,
69         LOCAL_OBJECT_SEND_MESSAGE_FAILURE,
70         RECEIVE_MESSAGE_FAILURE,
71         INVOKE_LISTENER_FAILURE,
72         ALLOCATE_INDEX_FAILURE,
73         REMOTE_OBJECT_SEND_MESSAGE_FAILURE,
74         INITIATE_DATABUS_FAILURE,
75         DATABUS_SEND_FAILURE,
76         DATABUS_RECEIVE_FAILURE,
77         CLOSE_DATABUS_FAILURE,
78         OPERATE_MESSAGE_FAILURE,
79     };
80 
81     // 605
82     enum TransmissionError {
83         RECEIVE_PKT_LOSS = 1,
84         SEND_PKT_LOSS,
85         HANDLE_OVERMUCH_THREADS,
86         OVERSIZE_PKT,
87     };
88 
89     // 606
90     enum CommonDriverType {
91         IPC_DRIVER = 1,
92         RPC_DRIVER,
93     };
94     enum CommonDriverError {
95         TRANSACT_DATA_FAILURE = 1,
96         HANDLE_RECV_DATA_FAILURE,
97         SET_DEATH_RECIPIENT_FAILURE,
98         REMOVE_DEATH_RECIPIENT_FAILURE,
99         HANDLE_DEATH_RECIPIENT_FAILURE,
100         FLATTEN_OBJECT_FAILURE,
101         UNFLATTEN_OBJECT_FAILURE,
102     };
103 
104     // 607
105     enum KernelDriverError {
106         INITIATE_IPC_DRIVER_FAILURE = 1,
107         OPEN_IPC_DRIVER_FAILURE,
108         WRITE_IPC_DRIVER_FAILURE,
109     };
110 
111     // 608
112     enum SocketDriverError {
113         OPEN_RPC_DRIVER_FAILURE = 1,
114         CONNECT_RPC_REMOTE_FAILURE,
115         SEND_RPC_DATA_FAILURE,
116         RECEIVE_RPC_DATA_FAILURE,
117         INVOKE_RPC_THREAD_FAILURE,
118     };
119 };
120 
121 #ifndef BUILD_PUBLIC_VERSION
ReportEvent(int code,const std::string & type,int num)122 inline void ReportEvent(int code, const std::string &type, int num)
123 {
124     if (code == 0 || type.empty() || num == 0) {
125         return;
126     }
127     HiEvent hiEvent(code);
128     hiEvent.PutInt(type, num);
129     HiView::Report(hiEvent);
130 }
131 
ReportDriverEvent(int code,const std::string & type,int num,const std::string & errorType,int errorNum)132 inline void ReportDriverEvent(int code, const std::string &type, int num, const std::string &errorType, int errorNum)
133 {
134     if (code == 0 || type.empty() || num == 0 || errorType.empty() || errorNum == 0) {
135         return;
136     }
137     HiEvent hiEvent(code);
138     hiEvent.PutInt(type, num);
139     hiEvent.PutInt(errorType, errorNum);
140     HiView::Report(hiEvent);
141 }
142 #endif
143 } // namespace OHOS
144 #endif // OHOS_IPC_DBINDER_ERROR_CODE_H
145