• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "event_report.h"
17 
18 namespace OHOS {
19 namespace NetManagerStandard {
20 namespace {
21 // event name
22 constexpr const char *NET_CONN_SUPPLER_FAULT = "NET_CONN_SUPPLER_FAULT";
23 constexpr const char *NET_CONN_REQUEST_FAULT = "NET_CONN_REQUEST_FAULT";
24 constexpr const char *NET_CONN_MONITOR_FAULT = "NET_CONN_MONITOR_FAULT";
25 constexpr const char *NET_CONN_SUPPLER_STAT = "NET_CONN_SUPPLER_STAT";
26 constexpr const char *NET_CONN_REQUEST_STAT = "NET_CONN_REQUEST_STAT";
27 constexpr const char *NET_CONN_MONITOR_STAT = "NET_CONN_MONITOR_STAT";
28 // event params
29 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERID = "UPDATE_SUPPLIERID";
30 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO = "UPDATE_SUPPLIERINFO";
31 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID = "UPDATE_NETLINKID";
32 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO = "UPDATE_NETLINKINFO";
33 constexpr const char *EVENT_KEY_ERROR_TYPE = "ERROR_TYPE";
34 constexpr const char *EVENT_KEY_ERROR_MSG = "ERROR_MSG";
35 constexpr const char *EVENT_KEY_NET_REQUEST_CAPABILITY = "CAPABILITIES";
36 constexpr const char *EVENT_KEY_NET_MONITOR_SOCKETFD = "SOCKETFD";
37 constexpr const char *EVENT_KEY_NET_MONITOR_NETID = "NETID";
38 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_BEARERTYPE = "REGISTER_BEARERTYPE";
39 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_IDENT = "REGISTER_IDENT";
40 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_SUPPLIERID = "REGISTER_SUPPLIERID";
41 constexpr const char *EVENT_KEY_NET_REQUEST_CALLBACK_AVAILABLE = "CALLBACK_AVAILABLE";
42 constexpr const char *EVENT_KEY_NET_REQUEST_SUPPLIERIDENT = "SUPPLIERIDENT";
43 constexpr const char *EVENT_KEY_NET_MONITOR_STATUS = "STATUS";
44 } // namespace
45 
SendSupplierFaultEvent(const EventInfo & eventInfo)46 void EventReport::SendSupplierFaultEvent(const EventInfo &eventInfo)
47 {
48     HiSysEventWrite(
49         HiSysEvent::Domain::NETMANAGER_STANDARD,
50         NET_CONN_SUPPLER_FAULT,
51         HiSysEvent::EventType::FAULT,
52         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERID, eventInfo.updateSupplierId,
53         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO, eventInfo.supplierInfo,
54         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID, eventInfo.updateNetlinkId,
55         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO, eventInfo.netlinkInfo,
56         EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
57         EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
58 }
59 
SendSupplierBehaviorEvent(const EventInfo & eventInfo)60 void EventReport::SendSupplierBehaviorEvent(const EventInfo &eventInfo)
61 {
62     HiSysEventWrite(
63         HiSysEvent::Domain::NETMANAGER_STANDARD,
64         NET_CONN_SUPPLER_STAT,
65         HiSysEvent::EventType::BEHAVIOR,
66         EVENT_KEY_NET_SUPPLIER_REGISTER_BEARERTYPE, eventInfo.bearerType,
67         EVENT_KEY_NET_SUPPLIER_REGISTER_IDENT, eventInfo.ident,
68         EVENT_KEY_NET_SUPPLIER_REGISTER_SUPPLIERID, eventInfo.supplierId,
69         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERID, eventInfo.updateSupplierId,
70         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO, eventInfo.supplierInfo,
71         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID, eventInfo.updateNetlinkId,
72         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO, eventInfo.netlinkInfo);
73 }
74 
SendRequestFaultEvent(const EventInfo & eventInfo)75 void EventReport::SendRequestFaultEvent(const EventInfo &eventInfo)
76 {
77     HiSysEventWrite(
78         HiSysEvent::Domain::NETMANAGER_STANDARD,
79         NET_CONN_REQUEST_FAULT,
80         HiSysEvent::EventType::FAULT,
81         EVENT_KEY_NET_REQUEST_CAPABILITY, eventInfo.capabilities,
82         EVENT_KEY_NET_REQUEST_SUPPLIERIDENT, eventInfo.supplierIdent,
83         EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
84         EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
85 }
86 
SendRequestBehaviorEvent(const EventInfo & eventInfo)87 void EventReport::SendRequestBehaviorEvent(const EventInfo &eventInfo)
88 {
89     HiSysEventWrite(
90         HiSysEvent::Domain::NETMANAGER_STANDARD,
91         NET_CONN_REQUEST_STAT,
92         HiSysEvent::EventType::BEHAVIOR,
93         EVENT_KEY_NET_REQUEST_CAPABILITY, eventInfo.capabilities,
94         EVENT_KEY_NET_REQUEST_SUPPLIERIDENT, eventInfo.supplierIdent,
95         EVENT_KEY_NET_REQUEST_CALLBACK_AVAILABLE, eventInfo.callbackAvailable);
96 }
97 
SendMonitorFaultEvent(const EventInfo & eventInfo)98 void EventReport::SendMonitorFaultEvent(const EventInfo &eventInfo)
99 {
100     HiSysEventWrite(
101         HiSysEvent::Domain::NETMANAGER_STANDARD,
102         NET_CONN_MONITOR_FAULT,
103         HiSysEvent::EventType::FAULT,
104         EVENT_KEY_NET_MONITOR_SOCKETFD, eventInfo.socketFd,
105         EVENT_KEY_NET_MONITOR_NETID, eventInfo.netId,
106         EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
107         EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
108 }
109 
SendMonitorBehaviorEvent(const EventInfo & eventInfo)110 void EventReport::SendMonitorBehaviorEvent(const EventInfo &eventInfo)
111 {
112     HiSysEventWrite(
113         HiSysEvent::Domain::NETMANAGER_STANDARD,
114         NET_CONN_MONITOR_STAT,
115         HiSysEvent::EventType::BEHAVIOR,
116         EVENT_KEY_NET_MONITOR_STATUS, eventInfo.monitorStatus);
117 }
118 } // namespace NetManagerStandard
119 } // namespace OHOS