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 const int HISYS_EVENT_DEFAULT_VALUE = -1;
45 const int HISYS_EVENT_PROTAL_STATE_NOT_PORTAL = 0;
46 const int HISYS_EVENT_PROTAL_STATE_PORTAL_VERIFIED = 1;
47 const int HISYS_EVENT_PROTAL_STATE_PORTAL_UNVERIFIED = 2;
48 
49 const std::string HISYS_STA_POWER_STATE_CHANGE = "wifiStateChange";
50 const std::string HISYS_STA_CONN_STATE_CHANGE = "wifiConnectionChange";
51 const std::string HISYS_STA_SCAN_STATE_CHANGE = "wifiScanStateChange";
52 const std::string HISYS_STA_RSSI_STATE_CHANGE = "wifiRssiChange";
53 const std::string HISYS_HOTSPOT_STATE_CHANGE = "hotspotStateChange";
54 const std::string HISYS_HOTSPOT_STA_JOIN = "hotspotStaJoin";
55 const std::string HISYS_HOTSPOT_STA_LEAVE = "hotspotStaLeave";
56 const std::string HISYS_P2P_STATE_CHANGE = "p2pStateChange";
57 const std::string HISYS_P2P_CONN_STATE_CHANGE = "p2pConnectionChange";
58 const std::string HISYS_P2P_DEVICE_STATE_CHANGE = "p2pDeviceChange";
59 const std::string HISYS_P2P_PERSISTENT_GROUP_CHANGE = "p2pPersistentGroupChange";
60 const std::string HISYS_P2P_PEER_DEVICE_CHANGE = "p2pPeerDeviceChange";
61 const std::string HISYS_P2P_DISCOVERY_CHANGE = "p2pDiscoveryChange";
62 
63 const std::string HISYS_SERVICE_TYPE_STA = "STA";
64 const std::string HISYS_SERVICE_TYPE_AP = "AP";
65 const std::string HISYS_SERVICE_TYPE_P2P = "P2P";
66 
67 void WriteWifiStateHiSysEvent(const std::string& serviceType, WifiOperType operType);
68 
69 void WriteWifiApStateHiSysEvent(int32_t state);
70 
71 void WriteWifiP2pStateHiSysEvent(const std::string& inter, int32_t type, int32_t state);
72 
73 void WriteWifiConnectionHiSysEvent(const WifiConnectionType& type, const std::string& pkgName);
74 
75 void WriteWifiScanHiSysEvent(const int result, const std::string& pkgName);
76 
77 void WriteWifiEventReceivedHiSysEvent(const std::string& eventType, int value);
78 
79 void WriteWifiBandHiSysEvent(int band);
80 
81 void WriteWifiSignalHiSysEvent(int direction, int txPackets, int rxPackets);
82 
83 void WriteWifiOperateStateHiSysEvent(int operateType, int operateState);
84 
85 void WriteWifiAbnormalDisconnectHiSysEvent(int errorCode);
86 
87 void WriteWifiConnectionInfoHiSysEvent(int networkId);
88 
89 void WriteWifiOpenAndCloseFailedHiSysEvent(int operateType, std::string failReason, int apState);
90 
91 void WriteSoftApOpenAndCloseFailedEvent(int operateType, std::string failReason);
92 
93 void WriteWifiAccessIntFailedHiSysEvent(int operateRes, int failCnt);
94 
95 void WriteWifiPnoScanHiSysEvent(int isStartScan, int suspendReason);
96 
97 void WriteBrowserFailedForPortalHiSysEvent(int respCode, std::string &server);
98 
99 void WriteWifiConnectFailedEventHiSysEvent(int operateType);
100 
101 void WriteP2pKpiCountHiSysEvent(int eventType);
102 
103 void WriteP2pConnectFailedHiSysEvent(int errCode, int failRes);
104 
105 void WriteP2pAbDisConnectHiSysEvent(int errCode, int failRes);
106 
107 void WriteSoftApAbDisconnectHiSysEvent(int errorCode);
108 
109 void WriteIsInternetHiSysEvent(int isInternet);
110 
111 void WriteSoftApConnectFailHiSysEvent(int errorCnt);
112 
113 void WriteWifiScanApiFailHiSysEvent(const std::string& pkgName, int failReason);
114 
115 void WriteWifiEncryptionFailHiSysEvent(int event, const std::string &maskSsid,
116     const std::string &keyMgmt, int encryptedModule);
117 
118 void WritePortalStateHiSysEvent(int portalState);
119 
120 void WriteArpInfoHiSysEvent(uint64_t arpRtt, int arpFailedCount);
121 
122 void WriteLinkInfoHiSysEvent(int signalLevel, int rssi, int band, int linkSpeed);
123 
124 void WirteConnectTypeHiSysEvent(std::string connectType);
125 
126 void WriteWifiWpaStateHiSysEvent(int state);
127 
128 void WritePortalAuthExpiredHisysevent(int respCode, int detectNum, time_t connTime,
129     time_t portalAuthTime, bool isNotificationClicked);
130 
131 void WriteWifiSelfcureHisysevent(int type);
132 }  // namespace Wifi
133 }  // namespace OHOS
134 #endif
135