• 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 = "NET_SUPPLIER_UPDATE_SUPPLIERID";
30 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO = "NET_SUPPLIER_UPDATE_SUPPLIERINFO";
31 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID = "NET_SUPPLIER_UPDATE_NETLINKID";
32 constexpr const char *EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO = "NET_SUPPLIER_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_CAPABILITIE = "NET_REQUEST_CAPABILITIE";
36 constexpr const char *EVENT_KEY_NET_MONITOR_SOCKETFD = "NET_MONITOR_SOCKETFD";
37 constexpr const char *EVENT_KEY_NET_MONITOR_NETID = "NET_MONITOR_NETID";
38 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_BEARERTYPE = "NET_SUPPLIER_REGISTER_BEARERTYPE";
39 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_IDENT = "NET_SUPPLIER_REGISTER_IDENT";
40 constexpr const char *EVENT_KEY_NET_SUPPLIER_REGISTER_SUPPLIERID = "NET_SUPPLIER_REGISTER_SUPPLIERID";
41 constexpr const char *EVENT_KEY_NET_REQUEST_CALLBACK_AVAILABLE = "NET_REQUEST_CALLBACK_AVAILABLE";
42 constexpr const char *EVENT_KEY_NET_REQUEST_SUPPLIERIDENT = "NET_REQUEST_SUPPLIERIDENT";
43 constexpr const char *EVENT_KEY_NET_REQUEST_NETCAPS = "NET_REQUEST_NETCAPS";
44 constexpr const char *EVENT_KEY_NET_MONITOR_STATUS = "NET_MONITOR_STATUS";
45 } // namespace
46 
SendSupplierFaultEvent(const EventInfo & eventInfo)47 void EventReport::SendSupplierFaultEvent(const EventInfo &eventInfo)
48 {
49      HiSysEvent::Write(
50         HiSysEvent::Domain::NETMANAGER_STANDARD,
51         NET_CONN_SUPPLER_FAULT,
52         HiSysEvent::EventType::FAULT,
53         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERID, eventInfo.updateSupplierId,
54         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO, eventInfo.supplierInfo,
55         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID, eventInfo.updateNetlinkId,
56         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO, eventInfo.netlinkInfo,
57         EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
58         EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
59 }
60 
SendSupplierBehaviorEvent(const EventInfo & eventInfo)61 void EventReport::SendSupplierBehaviorEvent(const EventInfo &eventInfo)
62 {
63      HiSysEvent::Write(
64         HiSysEvent::Domain::NETMANAGER_STANDARD,
65         NET_CONN_SUPPLER_STAT,
66         HiSysEvent::EventType::BEHAVIOR,
67         EVENT_KEY_NET_SUPPLIER_REGISTER_BEARERTYPE, eventInfo.bearerType,
68         EVENT_KEY_NET_SUPPLIER_REGISTER_IDENT, eventInfo.ident,
69         EVENT_KEY_NET_SUPPLIER_REGISTER_SUPPLIERID, eventInfo.supplierId,
70         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERID, eventInfo.updateSupplierId,
71         EVENT_KEY_NET_SUPPLIER_UPDATE_SUPPLIERINFO, eventInfo.supplierInfo,
72         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKID, eventInfo.updateNetlinkId,
73         EVENT_KEY_NET_SUPPLIER_UPDATE_NETLINKINFO, eventInfo.netlinkInfo);
74 }
75 
SendRequestFaultEvent(const EventInfo & eventInfo)76 void EventReport::SendRequestFaultEvent(const EventInfo &eventInfo)
77 {
78      HiSysEvent::Write(
79         HiSysEvent::Domain::NETMANAGER_STANDARD,
80         NET_CONN_REQUEST_FAULT,
81         HiSysEvent::EventType::FAULT,
82         EVENT_KEY_NET_REQUEST_CAPABILITIE, eventInfo.capabilities,
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      HiSysEvent::Write(
90         HiSysEvent::Domain::NETMANAGER_STANDARD,
91         NET_CONN_REQUEST_STAT,
92         HiSysEvent::EventType::BEHAVIOR,
93         EVENT_KEY_NET_REQUEST_CAPABILITIE, eventInfo.capabilities,
94         EVENT_KEY_NET_REQUEST_CALLBACK_AVAILABLE, eventInfo.callbackAvailable,
95         EVENT_KEY_NET_REQUEST_SUPPLIERIDENT, eventInfo.supplierIdent,
96         EVENT_KEY_NET_REQUEST_NETCAPS, eventInfo.netcaps);
97 }
98 
SendMonitorFaultEvent(const EventInfo & eventInfo)99 void EventReport::SendMonitorFaultEvent(const EventInfo &eventInfo)
100 {
101      HiSysEvent::Write(
102         HiSysEvent::Domain::NETMANAGER_STANDARD,
103         NET_CONN_MONITOR_FAULT,
104         HiSysEvent::EventType::FAULT,
105         EVENT_KEY_NET_MONITOR_SOCKETFD, eventInfo.socketFd,
106         EVENT_KEY_NET_MONITOR_NETID, eventInfo.netId,
107         EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
108         EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
109 }
110 
SendMonitorBehaviorEvent(const EventInfo & eventInfo)111 void EventReport::SendMonitorBehaviorEvent(const EventInfo &eventInfo)
112 {
113      HiSysEvent::Write(
114         HiSysEvent::Domain::NETMANAGER_STANDARD,
115         NET_CONN_MONITOR_STAT,
116         HiSysEvent::EventType::BEHAVIOR,
117         EVENT_KEY_NET_MONITOR_STATUS, eventInfo.monitorStatus);
118 }
119 } // namespace NetManagerStandard
120 } // namespace OHOS