1 /*
2  * Copyright (C) 2023 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 #ifndef OHOS_IENHANCE_SERVICE_H
16 #define OHOS_IENHANCE_SERVICE_H
17 
18 #include "wifi_errcode.h"
19 #include "wifi_scan_control_msg.h"
20 #include "wifi_msg.h"
21 
22 namespace OHOS {
23 namespace Wifi {
24 using P2pEnhanceCallback = std::function<void(const std::string &, int32_t)>;
25 class IEnhanceService {
26 public:
27     virtual ~IEnhanceService() = default;
28     /**
29      * @Description  Enhance service initialization function.
30      *
31      * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
32      */
33     virtual ErrCode Init() = 0;
34     /**
35      * @Description  Stopping the Enhance Service.
36      *
37      * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
38      */
39     virtual ErrCode UnInit() = 0;
40     /**
41      * @Description  check Scan is allowed.
42      *
43      * @return true: allowed, false: not allowed
44      */
45     virtual bool AllowScanBySchedStrategy() = 0;
46     /**
47      * @Description  Set EnhanceService Param.
48      *
49      * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
50      */
51     virtual ErrCode SetEnhanceParam(int64_t availableTime) = 0;
52 
53     /**
54      * @Description Install Paket Filter Program
55      *
56      * @param ipAddr - ip address
57      * @param netMaskLen - net mask length
58      * @param macAddr - mac address
59      * @param macLen - mac address length
60      * @param screenState - screen state
61      * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
62      */
63     virtual ErrCode InstallFilterProgram(
64         unsigned int ipAddr, int netMaskLen, const unsigned char *macAddr, int macLen, int screenState) = 0;
65 
66     /**
67      * @Description Get wifi category
68      *
69      * @param infoElems - info elems
70      * @param chipsetCategory - chipset category
71      * @param chipsetFeatrureCapability - chipset featrure capability
72      * @return 1: DEFAULT, 2: WIFI6, 3: WIFI6_PLUS, 4: WIFI7, 5: WIFI7_PLUS
73      */
74     virtual WifiCategory GetWifiCategory(
75         std::vector<WifiInfoElem> infoElems, int chipsetCategory, int chipsetFeatrureCapability) = 0;
76 
77     /**
78      * @Description set low tx power
79      *
80      * @param wifiLowPowerParam - wifi low power param
81      * @return ErrCode - operation result
82      */
83     virtual ErrCode SetLowTxPower(const WifiLowPowerParam wifiLowPowerParam) = 0;
84 
85     /**
86      * @Description Check Chba conncted
87      *
88      * @return true: conncted, false: not conncted
89      */
90     virtual bool CheckChbaConncted() = 0;
91 
92     /**
93      * @Description Is external scan allowed.
94      *
95      * @param scanDeviceInfo - scan device info
96      * @return true: allowed, false: not allowed
97      */
98     virtual bool IsScanAllowed(WifiScanDeviceInfo &scanDeviceInfo) = 0;
99 
100     /**
101      * @Description Is customer network.
102      *
103      * @param scanDeviceInfo - scan device info
104      * @return true: allowed, false: not allowed
105      */
106     virtual bool IsHwItCustNetwork(WifiDeviceConfig &config) = 0;
107 
108     /**
109      * @Description selfcure for multi dhcp server.
110      *
111      * @param cmd - add、get size、clear
112      * @param ipInfo - ip information
113      * @param retSize - get dhcp offer size
114      * @return ErrCode - operation result
115      */
116     virtual ErrCode DealDhcpOfferResult(const OperationCmd &cmd, const IpInfo &ipInfo, uint32_t &retSize) = 0;
117 
118     /**
119      * @Description selfcure for multi dhcp server.
120      *
121      * @param isChanged - is gateway changed situation
122      * @return ErrCode - operation result
123      */
124     virtual ErrCode IsGatewayChanged(bool &isChanged) = 0;
125 
126     /**
127      * @Description selfcure for multi dhcp server.
128      *
129      * @param isMultiDhcpServer - true、false
130      * @param startSelfcure - true、false
131      * @param ipInfo - get ipinfo
132      * @return ErrCode - operation result
133      */
134     virtual ErrCode GetStaticIpConfig(const bool &isMultiDhcpServer, const bool &startSelfcure, IpInfo &ipInfo) = 0;
135 
136     /**
137      * @Description Is Wide Bandwidth Supported.
138      *
139      * @return true: support, false: not support
140      */
141     virtual bool IsWideBandwidthSupported() = 0;
142 
143     /**
144      * @Description Check if custom network
145      *
146      * @return true or false
147      */
148     virtual bool IsCustomNetwork(WifiDeviceConfig &config) = 0;
149 
150     /**
151      * @Description Register P2pEnhance state Callback
152      *
153      * @param p2pEnhanceCallback - callback
154      * @return ErrCode - operation result
155      */
156     virtual ErrCode RegisterP2pEnhanceCallback(P2pEnhanceCallback callback) = 0;
157 
158     /**
159      * @Description unRegister P2pEnhance state Callback
160      *
161      * @return ErrCode - operation result
162      */
163     virtual ErrCode UnRegisterP2pEnhanceCallback() = 0;
164 
165     /**
166      * @Description Check Enhance Vap Available
167      *
168      * @return true: available, false: not available
169      */
170     virtual bool CheckEnhanceVapAvailable() = 0;
171 
172     /**
173      * @Description get the self wifi configuration information
174      *
175      * @param cfgType - configuration type
176      * @param cfgData - the queried data of wifi configuration
177      * @param getDatValidLen - the valid data length in the array `cfgData`
178      * @return ErrCode - operation result
179      */
180     virtual ErrCode Hid2dGetSelfWifiCfgInfo(SelfCfgType cfgType, char cfgData[CFG_DATA_MAX_BYTES],
181         int* getDatValidLen) = 0;
182 
183     /**
184      * @Description set the peer wifi configuration information
185      *
186      * @param cfgType - configuration type
187      * @param cfgData - the wifi configuration data to be set
188      * @param setDataValidLen - the valid data length in the array `cfgData`
189      * @return ErrCode - operation result
190      */
191     virtual ErrCode Hid2dSetPeerWifiCfgInfo(PeerCfgType cfgType, char cfgData[CFG_DATA_MAX_BYTES],
192         int setDataValidLen) = 0;
193 
194     /**
195      * @Description obtain supported frequency
196      *
197      * @param freq - current use freq
198      * @param is160M - where use 160M Frequency
199      * @return int - supported frequency
200      */
201     virtual int FreqEnhance(int freq, bool is160M) = 0;
202 };
203 }  // namespace Wifi
204 }  // namespace OHOS
205 #endif
206