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