OSDN Git Service

release-request-323db86e-b638-4d24-8eb1-d2e3bf4a9d1a-for-git_oc-mr1-release-4017779...
[android-x86/system-connectivity-wificond.git] / scanning / scanner_impl.h
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef WIFICOND_SCANNER_IMPL_H_
18 #define WIFICOND_SCANNER_IMPL_H_
19
20 #include <vector>
21
22 #include <android-base/macros.h>
23 #include <binder/Status.h>
24
25 #include "android/net/wifi/BnWifiScannerImpl.h"
26 #include "wificond/net/netlink_utils.h"
27 #include "wificond/scanning/offload/offload_scan_manager.h"
28
29 namespace android {
30 namespace wificond {
31
32 class ClientInterfaceImpl;
33 class ScanUtils;
34
35 class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
36  public:
37   ScannerImpl(uint32_t wiphy_index,
38               uint32_t interface_index,
39               const ScanCapabilities& scan_capabilities,
40               const WiphyFeatures& wiphy_features,
41               ClientInterfaceImpl* client_interface,
42               NetlinkUtils* netlink_utils,
43               ScanUtils* scan_utils);
44   ~ScannerImpl();
45   // Returns a vector of available frequencies for 2.4GHz channels.
46   ::android::binder::Status getAvailable2gChannels(
47       ::std::unique_ptr<::std::vector<int32_t>>* out_frequencies) override;
48   // Returns a vector of available frequencies for 5GHz non-DFS channels.
49   ::android::binder::Status getAvailable5gNonDFSChannels(
50       ::std::unique_ptr<::std::vector<int32_t>>* out_frequencies) override;
51   // Returns a vector of available frequencies for DFS channels.
52   ::android::binder::Status getAvailableDFSChannels(
53       ::std::unique_ptr<::std::vector<int32_t>>* out_frequencies) override;
54   // Get the latest scan results from kernel.
55   ::android::binder::Status getScanResults(
56       std::vector<com::android::server::wifi::wificond::NativeScanResult>*
57           out_scan_results) override;
58   ::android::binder::Status scan(
59       const ::com::android::server::wifi::wificond::SingleScanSettings&
60           scan_settings,
61       bool* out_success) override;
62   ::android::binder::Status startPnoScan(
63       const ::com::android::server::wifi::wificond::PnoSettings& pno_settings,
64       bool* out_success) override;
65   ::android::binder::Status stopPnoScan(bool* out_success) override;
66   ::android::binder::Status abortScan(bool* out_success) override;
67
68   ::android::binder::Status subscribeScanEvents(
69       const ::android::sp<::android::net::wifi::IScanEvent>& handler) override;
70   ::android::binder::Status unsubscribeScanEvents() override;
71   ::android::binder::Status subscribePnoScanEvents(
72       const ::android::sp<::android::net::wifi::IPnoScanEvent>& handler) override;
73   ::android::binder::Status unsubscribePnoScanEvents() override;
74   void Invalidate();
75
76  private:
77   bool CheckIsValid();
78   void OnOffloadScanResult(
79       std::vector<::com::android::server::wifi::wificond::NativeScanResult>);
80   void OnScanResultsReady(
81       uint32_t interface_index,
82       bool aborted,
83       std::vector<std::vector<uint8_t>>& ssids,
84       std::vector<uint32_t>& frequencies);
85   void OnSchedScanResultsReady(uint32_t interface_index, bool scan_stopped);
86   void LogSsidList(std::vector<std::vector<uint8_t>>& ssid_list,
87                    std::string prefix);
88   bool StartPnoScanDefault(
89       const ::com::android::server::wifi::wificond::PnoSettings& pno_settings);
90   bool StartPnoScanOffload(
91       const ::com::android::server::wifi::wificond::PnoSettings& pno_settings);
92   bool StopPnoScanDefault();
93   bool StopPnoScanOffload();
94   void ParsePnoSettings(
95     const ::com::android::server::wifi::wificond::PnoSettings& pno_settings,
96     std::vector<std::vector<uint8_t>>* scan_ssids,
97     std::vector<std::vector<uint8_t>>* match_ssids,
98     std::vector<uint32_t>* freqs,
99     std::vector<uint8_t>* match_security);
100   // Boolean variables describing current scanner status.
101   bool valid_;
102   bool scan_started_;
103   bool pno_scan_started_;
104   bool offload_scan_supported_;
105
106   const uint32_t wiphy_index_;
107   const uint32_t interface_index_;
108
109   // Scanning relevant capability information for this wiphy/interface.
110   ScanCapabilities scan_capabilities_;
111   WiphyFeatures wiphy_features_;
112
113   ClientInterfaceImpl* client_interface_;
114   NetlinkUtils* const netlink_utils_;
115   ScanUtils* const scan_utils_;
116   ::android::sp<::android::net::wifi::IPnoScanEvent> pno_scan_event_handler_;
117   ::android::sp<::android::net::wifi::IScanEvent> scan_event_handler_;
118   std::unique_ptr<OffloadScanManager> offload_scan_manager_;
119
120   DISALLOW_COPY_AND_ASSIGN(ScannerImpl);
121 };
122
123 }  // namespace wificond
124 }  // namespace android
125
126 #endif  // WIFICOND_SCANNER_IMPL_H_