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 
16 #ifndef OHOS_WIFI_SCAN_H
17 #define OHOS_WIFI_SCAN_H
18 
19 #include "wifi_errcode.h"
20 #include "wifi_scan_msg.h"
21 #include "i_wifi_scan_callback.h"
22 
23 namespace OHOS {
24 namespace Wifi {
25 class WifiScan {
26 public:
27     static std::shared_ptr<WifiScan> GetInstance(int systemAbilityId, int instId = 0);
28 
29     virtual ~WifiScan();
30 
31     /**
32      * @Description Set the Scan Control Info object
33      *
34      * @param info - ScanControlInfo object
35      * @return ErrCode - operation result
36      */
37     virtual ErrCode SetScanControlInfo(const ScanControlInfo &info) = 0;
38 
39     /**
40      * @Description Start scan Wifi
41      *
42      * @param compatible - indicates whether compatibility is maintained
43      * @return ErrCode - operation result
44      */
45     virtual ErrCode Scan(bool compatible = true) = 0;
46 
47     /**
48      * @Description Obtain the scanning result
49      *
50      * @param result - Get result vector of WifiScanInfo
51      * @param compatible - indicates whether compatibility is maintained
52      * @return ErrCode - operation result
53      */
54     virtual ErrCode GetScanInfoList(std::vector<WifiScanInfo> &result, bool compatible = true) = 0;
55 
56     /**
57      * @Description Start scan with specified params
58      *
59      * @param params - WifiScanParams object
60      * @return ErrCode - operation result
61      */
62     virtual ErrCode AdvanceScan(const WifiScanParams &params) = 0;
63 
64 #ifdef OHOS_ARCH_LITE
65     virtual ErrCode RegisterCallBack(const std::shared_ptr<IWifiScanCallback> &callback,
66         const std::vector<std::string> &event) = 0;
67 #else
68     virtual ErrCode RegisterCallBack(const sptr<IWifiScanCallback> &callback,
69         const std::vector<std::string> &event) = 0;
70 #endif
71 
72     /**
73      * @Description Get supported features
74      *
75      * @param features - return supported features
76      * @return ErrCode - operation result
77      */
78     virtual ErrCode GetSupportedFeatures(long &features) = 0;
79 
80     /**
81      * @Description Check if supported input feature
82      *
83      * @param feature - input feature
84      * @return bool - true if supported, false if unsupported
85      */
86     virtual bool IsFeatureSupported(long feature) = 0;
87 
88     /**
89      * @Description SetScanOnlyAvailable.
90      *
91      * @return ErrCode - operation result
92      */
93     virtual ErrCode SetScanOnlyAvailable(bool bScanOnlyAvailable) = 0;
94 
95     /**
96      * @Description GetScanOnly Whether Available.
97      *
98      * @return ErrCode - operation result
99      */
100     virtual ErrCode GetScanOnlyAvailable(bool &bScanOnlyAvailable) = 0;
101 
102     /**
103      * @Description Start pno scan
104      *
105      * @param isStartAction - true:start pno scan; false:stop pno scan
106      * @param periodMs - pno scan interval
107      * @param suspendReason - pno scan suspent reason
108      * @return ErrCode - operation result
109      */
110     virtual ErrCode StartWifiPnoScan(bool isStartAction, int periodMs, int suspendReason) = 0;
111 };
112 }  // namespace Wifi
113 }  // namespace OHOS
114 #endif
115