• 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 #ifndef OHOS_WIFI_HISYSEVENT_H
17 #define OHOS_WIFI_HISYSEVENT_H
18 
19 #include <string>
20 #include "wifi_msg.h"
21 #define AP_ERR_CODE 3
22 #define AP_STA_PSK_MISMATCH_CNT 1
23 
24 #define ENCRYPTION_EVENT 0
25 #define DECRYPTION_EVENT 1
26 #define NONE_ENCRYTION_UTIL 2
27 
28 #define SOFTAP_MOUDLE_EVENT 0
29 #define STA_MOUDLE_EVENT 1
30 
31 namespace OHOS {
32 namespace Wifi {
33 enum class WifiOperType {
34     ENABLE,
35     DISABLE,
36     SEMI_ENABLE
37 };
38 
39 enum class WifiConnectionType {
40     CONNECT,
41     DISCONNECT
42 };
43 
44 inline const int HISYS_EVENT_DEFAULT_VALUE = -1;
45 inline const int HISYS_EVENT_PROTAL_STATE_NOT_PORTAL = 0;
46 inline const int HISYS_EVENT_PROTAL_STATE_PORTAL_VERIFIED = 1;
47 inline const int HISYS_EVENT_PROTAL_STATE_PORTAL_UNVERIFIED = 2;
48 
49 inline const std::string HISYS_STA_POWER_STATE_CHANGE = "wifiStateChange";
50 inline const std::string HISYS_STA_CONN_STATE_CHANGE = "wifiConnectionChange";
51 inline const std::string HISYS_STA_SCAN_STATE_CHANGE = "wifiScanStateChange";
52 inline const std::string HISYS_STA_RSSI_STATE_CHANGE = "wifiRssiChange";
53 inline const std::string HISYS_HOTSPOT_STATE_CHANGE = "hotspotStateChange";
54 inline const std::string HISYS_HOTSPOT_STA_JOIN = "hotspotStaJoin";
55 inline const std::string HISYS_HOTSPOT_STA_LEAVE = "hotspotStaLeave";
56 inline const std::string HISYS_P2P_STATE_CHANGE = "p2pStateChange";
57 inline const std::string HISYS_P2P_CONN_STATE_CHANGE = "p2pConnectionChange";
58 inline const std::string HISYS_P2P_DEVICE_STATE_CHANGE = "p2pDeviceChange";
59 inline const std::string HISYS_P2P_PERSISTENT_GROUP_CHANGE = "p2pPersistentGroupChange";
60 inline const std::string HISYS_P2P_PEER_DEVICE_CHANGE = "p2pPeerDeviceChange";
61 inline const std::string HISYS_P2P_DISCOVERY_CHANGE = "p2pDiscoveryChange";
62 
63 inline const std::string HISYS_SERVICE_TYPE_STA = "STA";
64 inline const std::string HISYS_SERVICE_TYPE_AP = "AP";
65 inline const std::string HISYS_SERVICE_TYPE_P2P = "P2P";
66 
67 enum class WifiScanFailReason {
68     DEFAULT = -1,
69     PROXY_FAIL,
70     PERMISSION_DENIED,
71     SCAN_SERVICE_NOT_RUNNING,
72     SERVICE_SCAN_FAIL,
73     SERVICE_ADVANCE_SCAN_FAIL,
74     HDI_SERVICE_DIED,
75     HDI_SCAN_FAIL,
76     HDI_PNO_SCAN_FAIL,
77     HDI_GET_SCAN_INFOS_FAIL
78 };
79 
80 struct Pref5gStatisticsInfo {
81     std::string bssid;
82     std::string ssid;
83     int32_t freq = 0;
84     int64_t durationNoInternet = 0;
85     int32_t enterMonitorNum = 0;
86     int32_t monitorActiveScanNum = 0;
87     int32_t rela5gNum = 0;
88     int32_t notAdj5gNum = 0;
89     int32_t notInternetRela5gNum = 0;
90     int32_t allRela5gInBlockListNum = 0;
91     int32_t satisfySwitchRssiNoSelectedNum = 0;
92     int32_t inBlackListNum = 0;
93     bool isUserConnected = false;
94     bool isIn5gPref = false;
95     bool has5gPrefSwitch = false;
96     std::chrono::steady_clock::time_point noInternetTime = std::chrono::steady_clock::time_point::min();
97     std::chrono::steady_clock::time_point connectTime = std::chrono::steady_clock::time_point::min();
98 
ResetPref5gStatisticsInfo99     void Reset()
100     {
101         bssid = "";
102         ssid = "";
103         freq = 0;
104         durationNoInternet = 0;
105         enterMonitorNum = 0;
106         monitorActiveScanNum = 0;
107         rela5gNum = 0;
108         notAdj5gNum = 0;
109         notInternetRela5gNum = 0;
110         allRela5gInBlockListNum = 0;
111         satisfySwitchRssiNoSelectedNum = 0;
112         inBlackListNum = 0;
113         isUserConnected = false;
114         isIn5gPref = false;
115         has5gPrefSwitch = false;
116         noInternetTime = std::chrono::steady_clock::time_point::min();
117         connectTime = std::chrono::steady_clock::time_point::min();
118     }
119 };
120 
121 struct IodStatisticInfo {
122     int32_t in2OutCnt = 0;
123     int32_t out2InCnt = 0;
124     int32_t outdoorFilterCnt = 0;
125     int32_t outdoorAutoSelectCnt = 0;
126     int32_t outdoorConnLevel0 = 0;
127     int32_t outdoorConnLevel1 = 0;
128     int32_t outdoorConnLevel2 = 0;
129     int32_t outdoorConnLevel3 = 0;
130     int32_t outdoorConnLevel4 = 0;
131     int32_t indoorConnLevel0 = 0;
132     int32_t indoorConnLevel1 = 0;
133     int32_t indoorConnLevel2 = 0;
134     int32_t indoorConnLevel3 = 0;
135     int32_t indoorConnLevel4 = 0;
136     int32_t outdoorConnShortTime = 0;
137     int32_t indoorConnShortTime = 0;
138 };
139 
140 void WriteWifiStateHiSysEvent(const std::string& serviceType, WifiOperType operType);
141 
142 void WriteWifiApStateHiSysEvent(int32_t state);
143 
144 void WriteWifiBridgeStateHiSysEvent(int32_t state);
145 
146 void WriteWifiP2pStateHiSysEvent(const std::string& inter, int32_t type, int32_t state);
147 
148 void WriteWifiConnectionHiSysEvent(int type, const std::string& pkgName);
149 
150 void WriteAuthFailHiSysEvent(const std::string &authFailReason, int subErrCode = 0);
151 
152 void WriteAssocFailHiSysEvent(const std::string &assocFailReason, int subErrCode = 0);
153 
154 void WriteDhcpFailHiSysEvent(const std::string &dhcpFailReason, int subErrCode = 0);
155 
156 void WriteScanLimitHiSysEvent(const std::string &scanInitiator, int scanLimitType, bool isForeground = false);
157 
158 void WriteAutoConnectFailEvent(const std::string &failReason, const std::string &subReason = "");
159 
160 void WriteWifiScanHiSysEvent(const int result, const std::string& pkgName);
161 
162 void WriteWifiEventReceivedHiSysEvent(const std::string& eventType, int value);
163 
164 void WriteWifiBandHiSysEvent(int band);
165 
166 void WriteWifiSignalHiSysEvent(int direction, int txPackets, int rxPackets);
167 
168 void WriteWifiOperateStateHiSysEvent(int operateType, int operateState);
169 
170 void WriteWifiAbnormalDisconnectHiSysEvent(int errorCode, int locallyGenerated);
171 
172 void WriteWifiBeaconLostHiSysEvent(int errorCode);
173 
174 void WriteWifiConnectionInfoHiSysEvent(int networkId);
175 
176 void WriteWifiOpenAndCloseFailedHiSysEvent(int operateType, std::string failReason, int apState);
177 
178 void WriteSoftApOpenAndCloseFailedEvent(int operateType, std::string failReason);
179 
180 void WriteSoftApOperateHiSysEvent(int operateType);
181 
182 void WriteWifiAccessIntFailedHiSysEvent(int operateRes, int failCnt, int selfCureResetState,
183     std::string selfCureHistory);
184 
185 void WriteWifiPnoScanHiSysEvent(int isStartScan, int suspendReason);
186 
187 void WriteBrowserFailedForPortalHiSysEvent(int respCode, std::string &server);
188 
189 void WriteP2pKpiCountHiSysEvent(int eventType);
190 
191 void WriteP2pConnectFailedHiSysEvent(int errCode, int failRes);
192 
193 void WriteP2pAbDisConnectHiSysEvent(int errCode, int failRes);
194 
195 void WriteSoftApAbDisconnectHiSysEvent(int errorCode);
196 
197 void WriteIsInternetHiSysEvent(int isInternet);
198 
199 void WriteSoftApConnectFailHiSysEvent(int errorCnt);
200 
201 void WriteSoftApClientAccessNetErrorHiSysEvent(int errorCode);
202 
203 void WriteWifiScanApiFailHiSysEvent(const std::string& pkgName, const WifiScanFailReason failReason);
204 
205 void WriteWifiEncryptionFailHiSysEvent(int event, const std::string &maskSsid,
206     const std::string &keyMgmt, int encryptedModule);
207 
208 void WritePortalStateHiSysEvent(int portalState);
209 
210 void WriteArpInfoHiSysEvent(uint64_t arpRtt, int32_t arpFailedCount, int32_t gatewayCnt = 0);
211 
212 void WriteLinkInfoHiSysEvent(int signalLevel, int rssi, int band, int linkSpeed);
213 
214 void WriteConnectTypeHiSysEvent(int connectType, bool isFirstConnect = false);
215 
216 void WriteWifiLinkTypeHiSysEvent(const std::string &ssid, int32_t wifiLinkType, const std::string &triggerReason);
217 
218 void WriteEmlsrExitReasonHiSysEvent(const std::string &ssid, int32_t reason);
219 
220 void WriteStaConnectIface(const std::string &ifName);
221 
222 void WriteWifiWpaStateHiSysEvent(int state);
223 
224 void WritePortalAuthExpiredHisysevent(int respCode, int detectNum, time_t connTime,
225     time_t portalAuthTime, bool isNotificationClicked);
226 
227 void WriteWifiSelfcureHisysevent(int type);
228 
229 void Write3VapConflictHisysevent(int type);
230 
231 void Write5gPrefFailedHisysevent(Pref5gStatisticsInfo &info);
232 
233 void WriteAutoSelectHiSysEvent(int selectType, const std::string &selectedInfo,
234     const std::string &filteredReason, const std::string &savedResult);
235 
236 void WriteDhcpInfoHiSysEvent(const IpInfo &ipInfo, const IpV6Info &ipv6Info);
237 
238 void WriteIodHiSysEvent(const IodStatisticInfo &iodStatisticInfo);
239 }  // namespace Wifi
240 }  // namespace OHOS
241 #endif
242