• 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 
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 void WriteWifiStateHiSysEvent(const std::string& serviceType, WifiOperType operType);
81 
82 void WriteWifiApStateHiSysEvent(int32_t state);
83 
84 void WriteWifiBridgeStateHiSysEvent(int32_t state);
85 
86 void WriteWifiP2pStateHiSysEvent(const std::string& inter, int32_t type, int32_t state);
87 
88 void WriteWifiConnectionHiSysEvent(const WifiConnectionType& type, const std::string& pkgName);
89 
90 void WriteAuthFailHiSysEvent(const std::string &authFailReason, int subErrCode = 0);
91 
92 void WriteAssocFailHiSysEvent(const std::string &assocFailReason, int subErrCode = 0);
93 
94 void WriteDhcpFailHiSysEvent(const std::string &dhcpFailReason, int subErrCode = 0);
95 
96 void WriteScanLimitHiSysEvent(const std::string &scanInitiator, int scanLimitType, bool isForeground = false);
97 
98 void WriteAutoConnectFailEvent(const std::string &failReason, const std::string &subReason = "");
99 
100 void WriteWifiScanHiSysEvent(const int result, const std::string& pkgName);
101 
102 void WriteWifiEventReceivedHiSysEvent(const std::string& eventType, int value);
103 
104 void WriteWifiBandHiSysEvent(int band);
105 
106 void WriteWifiSignalHiSysEvent(int direction, int txPackets, int rxPackets);
107 
108 void WriteWifiOperateStateHiSysEvent(int operateType, int operateState);
109 
110 void WriteWifiAbnormalDisconnectHiSysEvent(int errorCode);
111 
112 void WriteWifiConnectionInfoHiSysEvent(int networkId);
113 
114 void WriteWifiOpenAndCloseFailedHiSysEvent(int operateType, std::string failReason, int apState);
115 
116 void WriteSoftApOpenAndCloseFailedEvent(int operateType, std::string failReason);
117 
118 void WriteWifiAccessIntFailedHiSysEvent(int operateRes, int failCnt);
119 
120 void WriteWifiPnoScanHiSysEvent(int isStartScan, int suspendReason);
121 
122 void WriteBrowserFailedForPortalHiSysEvent(int respCode, std::string &server);
123 
124 void WriteP2pKpiCountHiSysEvent(int eventType);
125 
126 void WriteP2pConnectFailedHiSysEvent(int errCode, int failRes);
127 
128 void WriteP2pAbDisConnectHiSysEvent(int errCode, int failRes);
129 
130 void WriteSoftApAbDisconnectHiSysEvent(int errorCode);
131 
132 void WriteIsInternetHiSysEvent(int isInternet);
133 
134 void WriteSoftApConnectFailHiSysEvent(int errorCnt);
135 
136 void WriteWifiScanApiFailHiSysEvent(const std::string& pkgName, const WifiScanFailReason failReason);
137 
138 void WriteWifiEncryptionFailHiSysEvent(int event, const std::string &maskSsid,
139     const std::string &keyMgmt, int encryptedModule);
140 
141 void WritePortalStateHiSysEvent(int portalState);
142 
143 void WriteArpInfoHiSysEvent(uint64_t arpRtt, int arpFailedCount);
144 
145 void WriteLinkInfoHiSysEvent(int signalLevel, int rssi, int band, int linkSpeed);
146 
147 void WriteConnectTypeHiSysEvent(int connectType, bool isFirstConnect = false);
148 
149 void WriteWifiLinkTypeHiSysEvent(const std::string &ssid, int32_t wifiLinkType, const std::string &triggerReason);
150 
151 void WriteEmlsrExitReasonHiSysEvent(const std::string &ssid, int32_t reason);
152 
153 void WriteStaConnectIface(const std::string &ifName);
154 
155 void WriteWifiWpaStateHiSysEvent(int state);
156 
157 void WritePortalAuthExpiredHisysevent(int respCode, int detectNum, time_t connTime,
158     time_t portalAuthTime, bool isNotificationClicked);
159 
160 void WriteWifiSelfcureHisysevent(int type);
161 
162 void Write3VapConflictHisysevent(int type);
163 }  // namespace Wifi
164 }  // namespace OHOS
165 #endif
166