• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 #ifndef OHOS_I_WIFI_DEVICE_H
16 #define OHOS_I_WIFI_DEVICE_H
17 
18 #include <set>
19 #include "wifi_errcode.h"
20 #ifndef OHOS_ARCH_LITE
21 #include "iremote_broker.h"
22 #include "message_parcel.h"
23 #include "message_option.h"
24 #endif
25 #include "i_wifi_device_callback.h"
26 #include "wifi_errcode.h"
27 #include "network_selection.h"
28 
29 namespace OHOS {
30 namespace Wifi {
31 #ifdef OHOS_ARCH_LITE
32 class IWifiDevice {
33 #else
34 class IWifiDevice : public IRemoteBroker {
35 #endif
36 public:
~IWifiDevice()37     virtual ~IWifiDevice()
38     {}
39 
40     /**
41      * @Description Turn on Wi-Fi
42      *
43      * @return ErrCode - operation result
44      */
45     virtual ErrCode EnableWifi() = 0;
46 
47     /**
48      * @Description Turn off Wi-Fi
49      *
50      * @return ErrCode - operation result
51      */
52     virtual ErrCode DisableWifi() = 0;
53 
54     /**
55      * @Description create the Wi-Fi protect.
56      *
57      * @param protectType - WifiProtectMode object
58      * @param protectName - the protect name
59      * @return ErrCode - operation result
60      */
61     virtual ErrCode InitWifiProtect(const WifiProtectType &protectType, const std::string &protectName) = 0;
62 
63     /**
64      * @Description Acquire the Wi-Fi protect mode.
65      *
66      * @param protectMode - WifiProtectMode object
67      * @param protectName - the protect name
68      * @return ErrCode - operation result
69      */
70     virtual ErrCode GetWifiProtectRef(const WifiProtectMode &protectMode, const std::string &protectName) = 0;
71 
72     /**
73      * @Description Query application whether or not acquired the Wi-Fi protect.
74      *
75      * @param protectName - the protect name
76      * @param isHoldProtect - out Whether or not acquired the Wi-Fi protect
77      * @return ErrCode - operation result
78      */
79     virtual ErrCode IsHeldWifiProtectRef(const std::string &protectName, bool &isHoldProtect) = 0;
80     /**
81      * @Description Release the Wi-Fi protect mode.
82      *
83      * @param protectName - the protect name
84      * @return ErrCode - operation result
85      */
86     virtual ErrCode PutWifiProtectRef(const std::string &protectName) = 0;
87 
88     /**
89      * @Description Remove the wifi candidate device config equals to input network id
90      *
91      * @param networkId - the candidate device network id
92      * @return ErrCode - operation result
93      */
94     virtual ErrCode RemoveCandidateConfig(int networkId) = 0;
95 
96     /**
97      * @Description Remove the wifi candidate device config by WifiDeviceConfig
98      *
99      * @param config - the candidate config to be removed
100      * @return ErrCode - operation result
101      */
102     virtual ErrCode RemoveCandidateConfig(const WifiDeviceConfig &config) = 0;
103 
104     /**
105      * @Description Add a wifi device configuration.
106      *
107      * @param config - WifiDeviceConfig object
108      * @param result - the device configuration's network id
109      * @param isCandidate - Whether is candidate
110      * @return ErrCode - operation result
111      */
112     virtual ErrCode AddDeviceConfig(const WifiDeviceConfig &config, int &result, bool isCandidate) = 0;
113 
114     /**
115      * @Description Update a wifi device configuration.
116      *
117      * @param config - WifiDeviceConfig object
118      * @param result - the device configuration's network id after updated
119      * @return ErrCode - operation result
120      */
121     virtual ErrCode UpdateDeviceConfig(const WifiDeviceConfig &config, int &result) = 0;
122 
123     /**
124      * @Description Remove the wifi device config equals to input network id
125      *
126      * @param networkId - want to remove device config's network id
127      * @return ErrCode - operation result
128      */
129     virtual ErrCode RemoveDevice(int networkId) = 0;
130 
131     /**
132      * @Description Delete all device configs.
133      *
134      * @return ErrCode - operation result
135      */
136     virtual ErrCode RemoveAllDevice() = 0;
137 
138     /**
139      * @Description set tx power for sar
140      *
141      * @param power - tx power
142      * @return ErrCode - operation result
143      */
144     virtual ErrCode SetTxPower(int power) = 0;
145 
146     /**
147      * @Description Get all the device configs
148      *
149      * @param result - Get result vector of WifiDeviceConfig
150      * @param isCandidate - Whether is candidate
151      * @return ErrCode - operation result
152      */
153     virtual ErrCode GetDeviceConfigs(std::vector<WifiDeviceConfig> &result, bool isCandidate) = 0;
154 
155     /**
156      * @Description Enable device config, when set attemptEnable, disable other device config
157      *
158      * @param networkId - need enable device config's network id
159      * @param attemptEnable - if set true, disable other device config
160      * @return ErrCode - operation result
161      */
162     virtual ErrCode EnableDeviceConfig(int networkId, bool attemptEnable) = 0;
163 
164     /**
165      * @Description Disable Wi-Fi device configuration.
166      *
167      * @param networkId - device config's network id
168      * @return ErrCode - operation result
169      */
170     virtual ErrCode DisableDeviceConfig(int networkId) = 0;
171 
172     /**
173      * @Description Set whther to allow automatic connect by networkId.
174      *
175      * @param networkId - Identifies the network to be set. The value of networkId cannot be less than 0.
176      * @param isAllowed - Identifies whether allow auto connect or not.
177      * @return ErrCode - operation result
178      */
179     virtual ErrCode AllowAutoConnect(int32_t networkId, bool isAllowed) = 0;
180 
181     /**
182      * @Description Connecting to a Specified Network
183      *
184      * @param networkId - network id
185      * @param isCandidate - Whether is candidate
186      * @return ErrCode - operation result
187      */
188     virtual ErrCode ConnectToNetwork(int networkId, bool isCandidate) = 0;
189 
190     /**
191      * @Description Connect To a network base WifiDeviceConfig object
192      *
193      * @param config - WifiDeviceConfig object
194      * @return ErrCode - operation result
195      */
196     virtual ErrCode ConnectToDevice(const WifiDeviceConfig &config) = 0;
197 
198     /**
199      * @Description roam to target bssid
200      *
201      * @param networkId - target networkId
202      * @param bssid - target bssid
203      * @param isCandidate - Whether is candidate
204      * @return ErrCode - operation result
205      */
206     virtual ErrCode StartRoamToNetwork(const int networkId, const std::string bssid, const bool isCandidate) = 0;
207 
208     /**
209      * @Description connect to user select ssid and bssid network
210      *
211      * @param networkId - target networkId
212      * @param bssid - target bssid
213      * @param isCandidate - Whether is candidate
214      * @return ErrCode - operation result
215      */
216     virtual ErrCode StartConnectToUserSelectNetwork(int networkId, std::string bssid, bool isCandidate) = 0;
217 
218     /**
219      * @Description Check whether Wi-Fi is connected.
220      *
221      * @param isConnected - true / false
222      * @return bool - true: connected, false: not connected
223      */
224     virtual ErrCode IsConnected(bool &isConnected) = 0;
225 
226     /**
227      * @Description Reconnect to the currently active network
228      *
229      * @return ErrCode - operation result
230      */
231     virtual ErrCode ReConnect() = 0;
232 
233     /**
234      * @Description ReAssociate network
235      *
236      * @return ErrCode - operation result
237      */
238     virtual ErrCode ReAssociate(void) = 0;
239 
240     /**
241      * @Description Disconnect
242      *
243      * @return ErrCode - operation result
244      */
245     virtual ErrCode Disconnect(void) = 0;
246 
247     /**
248      * @Description Enable WPS connection
249      *
250      * @param config - WpsConfig object
251      * @return ErrCode - operation result
252      */
253     virtual ErrCode StartWps(const WpsConfig &config) = 0;
254 
255     /**
256      * @Description Close the WPS connection
257      *
258      * @return ErrCode - operation result
259      */
260     virtual ErrCode CancelWps(void) = 0;
261 
262     /**
263      * @Description Check whether Wi-Fi is active
264      *
265      * @param bActive - active / inactive
266      * @return ErrCode - operation result
267      */
268     virtual ErrCode IsWifiActive(bool &bActive) = 0;
269 
270     /**
271      * @Description Check whether Wi-Fi is metered hotspot
272      *
273      * @param bMeteredHotspot - isMeteredHotspot / notMeteredHotspot
274      * @return ErrCode - operation result
275      */
276     virtual ErrCode IsMeteredHotspot(bool &bMeteredHotspot) = 0;
277 
278     /**
279      * @Description Get the Wifi State
280      *
281      * @param state - return current wifi state
282      * @return ErrCode - operation result
283      */
284     virtual ErrCode GetWifiState(int &state) = 0;
285 
286     /**
287      * @Description Obtains the current Wi-Fi connection information
288      *
289      * @param info - WifiLinkedInfo object
290      * @return ErrCode - operation result
291      */
292     virtual ErrCode GetLinkedInfo(WifiLinkedInfo &info) = 0;
293 
294     virtual ErrCode GetSignalPollInfoArray(std::vector<WifiSignalPollInfo> &wifiSignalPollInfos, int length) = 0;
295 
296     /**
297      * @Description Obtains the disconnected reason
298      *
299      * @param reason - DisconnectedReason object
300      * @return ErrCode - operation result
301      */
302     virtual ErrCode GetDisconnectedReason(DisconnectedReason &reason) = 0;
303 
304     /**
305      * @Description Obtaining DHCP Request Information
306      *
307      * @param info - IpInfo object
308      * @return ErrCode - operation result
309      */
310     virtual ErrCode GetIpInfo(IpInfo &info) = 0;
311 
312     /**
313      * @Description Obtaining DHCP Request Information
314      *
315      * @param info - IpV6Info object
316      * @return ErrCode - operation result
317      */
318     virtual ErrCode GetIpv6Info(IpV6Info &info) = 0;
319 
320     /**
321      * @Description Set the Country Code
322      *
323      * @param countryCode - country code
324      * @return ErrCode - operation result
325      */
326     virtual ErrCode SetCountryCode(const std::string &countryCode) = 0;
327 
328     /**
329      * @Description Obtains the country code
330      *
331      * @param countryCode - output the country code
332      * @return ErrCode - operation result
333      */
334     virtual ErrCode GetCountryCode(std::string &countryCode) = 0;
335 
336     /**
337      * @Description Register callback function.
338      *
339      * @param callback - IWifiDeviceCallBack object
340      * @return ErrCode - operation result
341      */
342 #ifdef OHOS_ARCH_LITE
343     virtual ErrCode RegisterCallBack(const std::shared_ptr<IWifiDeviceCallBack> &callback,
344         const std::vector<std::string> &event) = 0;
345 #else
346     virtual ErrCode RegisterCallBack(const sptr<IWifiDeviceCallBack> &callback,
347         const std::vector<std::string> &event) = 0;
348 #endif
349 
350     /**
351      * @Description Get the Signal Level object
352      *
353      * @param rssi - rssi
354      * @param band - band
355      * @param level - return the level
356      * @return ErrCode - operation result
357      */
358     virtual ErrCode GetSignalLevel(const int &rssi, const int &band, int &level) = 0;
359 
360     /**
361      * @Description Get supported features
362      *
363      * @param features - return supported features
364      * @return ErrCode - operation result
365      */
366     virtual ErrCode GetSupportedFeatures(long &features) = 0;
367 
368     /**
369      * @Description Check if supported input feature
370      *
371      * @param feature - input feature
372      * @return ErrCode - operation result
373      */
374     virtual ErrCode IsFeatureSupported(long feature, bool &isSupported) = 0;
375 
376     /**
377      * @Description  Get the device MAC address.
378      *
379      * @param result - Get device mac String
380      * @return ErrCode - operation result
381      */
382     virtual ErrCode GetDeviceMacAddress(std::string &result) = 0;
383 
384     /**
385      * @Description set low latency mode
386      *
387      * @param enabled - true: enable low latency, false: disable low latency
388      * @return bool - operation result
389      */
390     virtual bool SetLowLatencyMode(bool enabled) = 0;
391 
392     /**
393      * @Description Check whether service is died.
394      *
395      * @return bool - true: service is died, false: service is not died.
396      */
397     virtual bool IsRemoteDied(void) = 0;
398 
399     /**
400      * @Description check wifi-band type is supported
401      *
402      * @param bandType - wifi band type
403      * @param supported - supported / unsupported
404      * @return ErrCode - operation result
405      */
406     virtual ErrCode IsBandTypeSupported(int bandType, bool &supported) = 0;
407 
408     /**
409      * @Description get all 5g channellist
410      *
411      * @param result - get result vector of int
412      * @return ErrCode - operation result
413      */
414     virtual ErrCode Get5GHzChannelList(std::vector<int> &result) = 0;
415 
416     /**
417      * @Description set frozen app
418      *
419      * @param pidList - pids of frozen app
420      * @param isFrozen - is app frozen
421      * @return ErrCode - operation result
422      */
423     virtual ErrCode SetAppFrozen(std::set<int> pidList, bool isFrozen) = 0;
424 
425     /**
426      * @Description reset all frozen app
427      *
428      * @return ErrCode - operation result
429      */
430     virtual ErrCode ResetAllFrozenApp() = 0;
431 
432     /**
433      * @Description  disable auto join.
434      *
435      * @param conditionName autoJoinDisabled condition.
436      * @return WifiErrorNo
437      */
438     virtual ErrCode DisableAutoJoin(const std::string &conditionName) = 0;
439 
440     /**
441      * @Description  enable auto join.
442      *
443      * @param conditionName autoJoinDisabled condition.
444      * @return WifiErrorNo
445      */
446     virtual ErrCode EnableAutoJoin(const std::string &conditionName) = 0;
447 
448     /**
449      * @Description  register auto join condition.
450      *
451      * @param conditionName the name of condition.
452      * @param autoJoinCondition condition.
453      * @return WifiErrorNo
454      */
455     virtual ErrCode RegisterAutoJoinCondition(const std::string &conditionName,
456                                               const std::function<bool()> &autoJoinCondition) = 0;
457 
458     /**
459      * @Description  deregister auto join condition.
460      *
461      * @param conditionName the name of condition.
462      * @return WifiErrorNo
463      */
464     virtual ErrCode DeregisterAutoJoinCondition(const std::string &conditionName) = 0;
465 
466     /**
467      * @Description  register external filter builder.
468      *
469      * @param filterTag filterTag which define where the filter should be inserted.
470      * @param filterName the name of the filter to build.
471      * @param filterBuilder filter builder.
472      * @return WifiErrorNo
473      */
474     virtual ErrCode RegisterFilterBuilder(const FilterTag &filterTag, const std::string &filterName,
475                                           const FilterBuilder &filterBuilder) = 0;
476 
477     /**
478      * @Description  deregister external filter builder.
479      *
480      * @param filterTag filterTag which define where the filter should be inserted.
481      * @param filterName the name of the filter to build.
482      * @return WifiErrorNo
483      */
484     virtual ErrCode DeregisterFilterBuilder(const FilterTag &filterTag, const std::string &filterName) = 0;
485 
486    /**
487      * Register the common builder function
488      *
489      * @param TagType scoreTag which define where the score or filter should be inserted.
490      * @param tagName the score or filter name.
491      * @param CommonBuilder CommonBuilder function.
492      */
493     virtual ErrCode RegisterCommonBuilder(const TagType &tagType, const std::string &tagName,
494                                           const CommonBuilder &commonBuilder) = 0;
495     /**
496      * Deregister the common builder function
497      *
498      * @param TagType TagType which define where the score or filter should be inserted.
499      * @param tagName the score or filte name.
500      */
501     virtual ErrCode DeregisterCommonBuilder(const TagType &tagType, const std::string &tagName) = 0;
502 
503     /**
504      * @Description start portal certification
505      *
506      * @return ErrCode - operation result
507      */
508     virtual ErrCode StartPortalCertification() = 0;
509 
510     virtual ErrCode GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config) = 0;
511     /**
512      * @Description reset factory
513      *
514      * @return ErrCode - operation result
515      */
516     virtual ErrCode FactoryReset() = 0;
517 
518     /**
519      * @Description Accept network control information from RSS.
520      *
521      * @param networkControlInfo - structure of network control infomation
522      * @return ErrCode - operation result
523      */
524     virtual ErrCode ReceiveNetworkControlInfo(const WifiNetworkControlInfo& networkControlInfo) = 0;
525 
526     /**
527      * @Description LimitSpeed
528      *
529      * @return ErrCode - operation result
530      */
531     virtual ErrCode LimitSpeed(const int controlId, const int limitMode) = 0;
532     /**
533      * @Description SetLowTxPower
534      *
535      * @return ErrCode - operation result
536      */
537     virtual ErrCode SetLowTxPower(const WifiLowPowerParam wifiLowPowerParam) = 0;
538 
539     /**
540      * @Description hilink connect
541      *
542      * @return ErrCode - operation result
543      */
544     virtual ErrCode EnableHiLinkHandshake(bool uiFlag, std::string &bssid, WifiDeviceConfig &deviceConfig) = 0;
545 
546     /**
547      * @Description Enable semi-Wifi
548      *
549      * @return ErrCode - operation result
550      */
551     virtual ErrCode EnableSemiWifi() = 0;
552 
553     /**
554      * @Description Obtains the wifi detail state
555      *
556      * @param state - WifiDetailState object
557      * @return ErrCode - operation result
558      */
559     virtual ErrCode GetWifiDetailState(WifiDetailState &state) = 0;
560 
561     /**
562      * @Description set satellite state
563      *
564      * @return ErrCode - operation result
565      */
566     virtual ErrCode SetSatelliteState(const int state) = 0;
567 #ifndef OHOS_ARCH_LITE
568 public:
569     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.wifi.IWifiDeviceService");
570 #endif
571 
572     /**
573      * @Description Get single device config
574      *
575      * @param networkId - the network id of the device config
576      * @param config - Get result vector of WifiDeviceConfig
577      * @return ErrCode - operation result
578      */
579     virtual ErrCode GetDeviceConfig(const int &networkId, WifiDeviceConfig &config) = 0;
580 
581     /**
582      * @Description set data packet identification mark rule
583      *
584      * @param uid - target app uid
585      * @param protocol - target protocol type
586      * @param enable - enable/disable dpi mark
587      */
588     virtual ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) = 0;
589 
590     /**
591      * @Description Update Network Lag Info
592      *
593      * @param networkLagType - recv networkLagType
594      * @param networkLagInfo - recv networkLagInfo
595      * @return ErrCode - operation result
596      */
597     virtual ErrCode UpdateNetworkLagInfo(const NetworkLagType networkLagType, const NetworkLagInfo &networkLagInfo) = 0;
598 
599     /**
600      * @Description Get Vowifi Signal Info.
601      *
602      * @return VoWifiSignalInfo : wifi signal info
603      */
604     virtual ErrCode FetchWifiSignalInfoForVoWiFi(VoWifiSignalInfo &signalInfo) = 0;
605 
606     /**
607      * @Description Check Is Support VoWifi Detect.
608      *
609      * @return bool - supported: true, unsupported: false.
610      */
611     virtual ErrCode IsSupportVoWifiDetect(bool &isSupported) = 0;
612 
613     /**
614      * @Description set VoWifi detect mode.
615      *
616      * @param info WifiDetectConfInfo
617      */
618     virtual ErrCode SetVoWifiDetectMode(WifiDetectConfInfo info) = 0;
619 
620     /**
621      * indicate VoWifiDetectMode
622      *
623      * @return VoWifiDetectMode
624      */
625     virtual ErrCode GetVoWifiDetectMode(WifiDetectConfInfo &info) = 0;
626 
627     /**
628      * @Description set vowifi detect period.
629      *
630      * @param period period of vowifi detect
631      */
632     virtual ErrCode SetVoWifiDetectPeriod(int period) = 0;
633 
634     /**
635      * @Description Get vowifi detection period
636      *
637      * @return vowifi detection period
638      */
639     virtual ErrCode GetVoWifiDetectPeriod(int &period) = 0;
640 
641     /**
642      * @Description Obtains the current Wi-Fi connection information
643      *
644      * @param multiLinkedInfo - wifi mlo linked info
645      * @return ErrCode - operation result
646      */
647     virtual ErrCode GetMultiLinkedInfo(std::vector<WifiLinkedInfo> &multiLinkedInfo) = 0;
648 
649     /**
650      * @Description Add wifi block list and wifi white list
651      *
652      * @param config - WifiRestrictedInfo object
653      * @param result - the result of wifi access list
654      * @return ErrCode - operation result
655      */
656     virtual ErrCode SetWifiRestrictedList(const std::vector<WifiRestrictedInfo> &wifiRestrictedInfoList) = 0;
657 };
658 }  // namespace Wifi
659 }  // namespace OHOS
660 #endif
661