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 I_WIFI_SCAN_H
17 #define I_WIFI_SCAN_H
18 
19 #ifdef OHOS_ARCH_LITE
20 #include "iproxy_client.h"
21 #else
22 #include <string_ex.h>
23 #include <iremote_broker.h>
24 #include "message_parcel.h"
25 #include "message_option.h"
26 #endif
27 #include "wifi_scan_msg.h"
28 #include "wifi_errcode.h"
29 #include "i_wifi_scan_callback.h"
30 
31 namespace OHOS {
32 namespace Wifi {
33 #ifdef OHOS_ARCH_LITE
34 class IWifiScan {
35 public:
36 #else
37 class IWifiScan : public IRemoteBroker {
38 public:
39     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.wifi.IWifiScan");
40 #endif
~IWifiScan()41     virtual ~IWifiScan()
42     {}
43 
44     /**
45      * @Description Set the Scan Control Info object
46      *
47      * @param info - ScanControlInfo object
48      * @return ErrCode - operation result
49      */
50     virtual ErrCode SetScanControlInfo(const ScanControlInfo &info) = 0;
51 
52     /**
53      * @Description Start scan Wifi
54      *
55      * @param compatible - indicates whether compatibility is maintained
56      * @return ErrCode - operation result
57      */
58     virtual ErrCode Scan(bool compatible = true) = 0;
59 
60     /**
61      * @Description Start scan with specified params
62      *
63      * @param params - WifiScanParams object
64      * @return ErrCode - operation result
65      */
66     virtual ErrCode AdvanceScan(const WifiScanParams &params) = 0;
67 
68     /**
69      * @Description Check whether the ScanAlways mode is enabled
70      *
71      * @param bOpen - true / false
72      * @return ErrCode - operation result
73      */
74     virtual ErrCode IsWifiClosedScan(bool &bOpen) = 0;
75 
76     /**
77      * @Description Obtain the scanning result
78      *
79      * @param result - Get result venctor of WifiScanInfo
80      * @param compatible - indicates whether compatibility is maintained
81      * @return ErrCode - operation result
82      */
83     virtual ErrCode GetScanInfoList(std::vector<WifiScanInfo> &result, bool compatible = true) = 0;
84     /**
85      * @Description SetScanOnlyAvailable.
86      *
87      * @return ErrCode - operation result
88      */
89     virtual ErrCode SetScanOnlyAvailable(bool bScanOnlyAvailable) = 0;
90 
91     /**
92      * @Description GetScanOnly Whether Available.
93      *
94      * @return ErrCode - operation result
95      */
96     virtual ErrCode GetScanOnlyAvailable(bool &bScanOnlyAvailable) = 0;
97 
98     /**
99      * @Description Start/Stop wifi pno scan.
100      *
101      * @param isStartAction - start or stop pno scan
102      * @param periodMs - pno scan interval
103      * @param suspendReason - pno scan suspend reason
104      * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
105      */
106     virtual ErrCode StartWifiPnoScan(bool isStartAction, int periodMs, int suspendReason) = 0;
107 
108 #ifdef OHOS_ARCH_LITE
109     virtual ErrCode RegisterCallBack(const std::shared_ptr<IWifiScanCallback> &callback,
110         const std::vector<std::string> &event) = 0;
111 #else
112     virtual ErrCode RegisterCallBack(const sptr<IWifiScanCallback> &callback,
113         const std::vector<std::string> &event) = 0;
114 #endif
115 
116     /**
117      * @Description Get supported features
118      *
119      * @param features - return supported features
120      * @return ErrCode - operation result
121      */
122     virtual ErrCode GetSupportedFeatures(long &features) = 0;
123 
124     /**
125      * @Description Check whether service is died.
126      *
127      * @return bool - true: service is died, false: service is not died.
128      */
129     virtual bool IsRemoteDied(void) = 0;
130 };
131 }  // namespace Wifi
132 }  // namespace OHOS
133 #endif
134