summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSohani Rao2017-08-15 18:00:51 -0500
committerandroid-build-merger2017-08-15 18:00:51 -0500
commit27f8c00f1f52a53be1fef13bdff6d13d2b55a703 (patch)
tree90aedc31f2484da046eee22f99e4238c0319787f
parent8129c5be6721324ccb70984b9aa90707f639cce0 (diff)
parente15c0edc98c9e6e906b9c53d1691a6bcfae5c61d (diff)
downloadsystem-connectivity-wificond-27f8c00f1f52a53be1fef13bdff6d13d2b55a703.tar.gz
system-connectivity-wificond-27f8c00f1f52a53be1fef13bdff6d13d2b55a703.tar.xz
system-connectivity-wificond-27f8c00f1f52a53be1fef13bdff6d13d2b55a703.zip
Wificond: Async Errors from Offload HAL service
am: e15c0edc98 Change-Id: I3e35f8f110a4f0a7853a86e81fb89c7d42d9cc90
-rw-r--r--Android.mk2
-rw-r--r--scanning/offload/offload_scan_manager.cpp64
-rw-r--r--scanning/offload/offload_scan_manager.h30
-rw-r--r--scanning/offload/offload_service_utils.cpp3
-rw-r--r--scanning/offload_scan_callback_interface.h42
-rw-r--r--scanning/offload_scan_callback_interface_impl.cpp42
-rw-r--r--scanning/offload_scan_callback_interface_impl.h44
-rw-r--r--scanning/scanner_impl.cpp194
-rw-r--r--scanning/scanner_impl.h36
-rw-r--r--tests/mock_offload_scan_callback_interface.cpp25
-rw-r--r--tests/mock_offload_scan_callback_interface.h41
-rw-r--r--tests/offload_scan_manager_test.cpp85
12 files changed, 420 insertions, 188 deletions
diff --git a/Android.mk b/Android.mk
index a5dc6e0..fd42006 100644
--- a/Android.mk
+++ b/Android.mk
@@ -66,6 +66,7 @@ LOCAL_SRC_FILES := \
66 rtt/rtt_controller_impl.cpp \ 66 rtt/rtt_controller_impl.cpp \
67 scanning/channel_settings.cpp \ 67 scanning/channel_settings.cpp \
68 scanning/hidden_network.cpp \ 68 scanning/hidden_network.cpp \
69 scanning/offload_scan_callback_interface_impl.cpp \
69 scanning/pno_network.cpp \ 70 scanning/pno_network.cpp \
70 scanning/pno_settings.cpp \ 71 scanning/pno_settings.cpp \
71 scanning/scan_result.cpp \ 72 scanning/scan_result.cpp \
@@ -175,6 +176,7 @@ LOCAL_SRC_FILES := \
175 tests/mock_netlink_utils.cpp \ 176 tests/mock_netlink_utils.cpp \
176 tests/mock_offload.cpp \ 177 tests/mock_offload.cpp \
177 tests/mock_offload_callback_handlers.cpp \ 178 tests/mock_offload_callback_handlers.cpp \
179 tests/mock_offload_scan_callback_interface.cpp \
178 tests/mock_offload_service_utils.cpp \ 180 tests/mock_offload_service_utils.cpp \
179 tests/mock_scan_utils.cpp \ 181 tests/mock_scan_utils.cpp \
180 tests/netlink_manager_unittest.cpp \ 182 tests/netlink_manager_unittest.cpp \
diff --git a/scanning/offload/offload_scan_manager.cpp b/scanning/offload/offload_scan_manager.cpp
index 5e3d90d..5c73362 100644
--- a/scanning/offload/offload_scan_manager.cpp
+++ b/scanning/offload/offload_scan_manager.cpp
@@ -35,11 +35,11 @@ using android::hardware::wifi::offload::V1_0::OffloadStatus;
35using android::hardware::wifi::offload::V1_0::OffloadStatusCode; 35using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
36 36
37using android::wificond::OffloadCallback; 37using android::wificond::OffloadCallback;
38using android::wificond::OnNativeScanResultsReadyHandler;
39using ::com::android::server::wifi::wificond::NativeScanResult; 38using ::com::android::server::wifi::wificond::NativeScanResult;
40using ::com::android::server::wifi::wificond::NativeScanStats; 39using ::com::android::server::wifi::wificond::NativeScanStats;
41using std::vector; 40using std::vector;
42using std::weak_ptr; 41using std::weak_ptr;
42using std::shared_ptr;
43 43
44using namespace std::placeholders; 44using namespace std::placeholders;
45 45
@@ -69,19 +69,15 @@ void OffloadCallbackHandlersImpl::OnErrorHandler(const OffloadStatus& status) {
69 } 69 }
70} 70}
71 71
72OffloadScanManager::OffloadScanManager(weak_ptr<OffloadServiceUtils> utils, 72OffloadScanManager::OffloadScanManager(
73 OnNativeScanResultsReadyHandler handler) 73 weak_ptr<OffloadServiceUtils> utils,
74 shared_ptr<OffloadScanCallbackInterface> callback)
74 : wifi_offload_hal_(nullptr), 75 : wifi_offload_hal_(nullptr),
75 wifi_offload_callback_(nullptr), 76 wifi_offload_callback_(nullptr),
76 offload_status_(OffloadScanManager::kError), 77 offload_status_(OffloadScanManager::kError),
77 subscription_enabled_(false),
78 offload_callback_handlers_(new OffloadCallbackHandlersImpl(this)), 78 offload_callback_handlers_(new OffloadCallbackHandlersImpl(this)),
79 scan_result_handler_(handler) { 79 event_callback_(callback) {
80 auto offload_scan_utils = utils.lock(); 80 auto offload_scan_utils = utils.lock();
81 if (scan_result_handler_ == nullptr) {
82 LOG(ERROR) << "Invalid Offload scan result handler";
83 return;
84 }
85 wifi_offload_hal_ = offload_scan_utils->GetOffloadService(); 81 wifi_offload_hal_ = offload_scan_utils->GetOffloadService();
86 if (wifi_offload_hal_ == nullptr) { 82 if (wifi_offload_hal_ == nullptr) {
87 LOG(ERROR) << "No Offload Service available"; 83 LOG(ERROR) << "No Offload Service available";
@@ -110,14 +106,15 @@ OffloadScanManager::OffloadScanManager(weak_ptr<OffloadServiceUtils> utils,
110} 106}
111 107
112bool OffloadScanManager::stopScan(OffloadScanManager::ReasonCode* reason_code) { 108bool OffloadScanManager::stopScan(OffloadScanManager::ReasonCode* reason_code) {
113 if (!subscription_enabled_) { 109 if (getOffloadStatus() != OffloadScanManager::kNoError) {
114 LOG(VERBOSE) << "Scans are not subscribed over Offload HAL"; 110 *reason_code = OffloadScanManager::kNotAvailable;
115 *reason_code = OffloadScanManager::kNotSubscribed;
116 return false; 111 return false;
117 } 112 }
118 if (wifi_offload_hal_ != nullptr) { 113 const auto& res = wifi_offload_hal_->unsubscribeScanResults();
119 wifi_offload_hal_->unsubscribeScanResults(); 114 if (!res.isOk()) {
120 subscription_enabled_ = false; 115 *reason_code = OffloadScanManager::kTransactionFailed;
116 LOG(WARNING) << "unsubscribeScanResults() failed " << res.description();
117 return false;
121 } 118 }
122 *reason_code = OffloadScanManager::kNone; 119 *reason_code = OffloadScanManager::kNone;
123 return true; 120 return true;
@@ -177,12 +174,13 @@ bool OffloadScanManager::startScan(
177 return false; 174 return false;
178 } 175 }
179 176
180 if (!subscription_enabled_ && !SubscribeScanResults(reason_code)) { 177 if (!SubscribeScanResults(reason_code)) {
181 return false; 178 return false;
182 } 179 }
183 180
184 subscription_enabled_ = true;
185 *reason_code = OffloadScanManager::kNone; 181 *reason_code = OffloadScanManager::kNone;
182 /* Clear up the scan cache every time a new scan is requested */
183 cached_scan_results_.clear();
186 return true; 184 return true;
187} 185}
188 186
@@ -214,6 +212,14 @@ OffloadScanManager::StatusCode OffloadScanManager::getOffloadStatus() const {
214 return offload_status_; 212 return offload_status_;
215} 213}
216 214
215bool OffloadScanManager::getScanResults(
216 std::vector<NativeScanResult>* out_scan_results) {
217 for (auto scan_result : cached_scan_results_) {
218 out_scan_results->push_back(scan_result);
219 }
220 return true;
221}
222
217bool OffloadScanManager::getScanStats(NativeScanStats* native_scan_stats) { 223bool OffloadScanManager::getScanStats(NativeScanStats* native_scan_stats) {
218 if (getOffloadStatus() != OffloadScanManager::kNoError) { 224 if (getOffloadStatus() != OffloadScanManager::kNoError) {
219 LOG(WARNING) << "Unable to get scan stats due to Wifi Offload HAL error"; 225 LOG(WARNING) << "Unable to get scan stats due to Wifi Offload HAL error";
@@ -230,11 +236,13 @@ OffloadScanManager::~OffloadScanManager() {
230 236
231void OffloadScanManager::ReportScanResults( 237void OffloadScanManager::ReportScanResults(
232 const vector<ScanResult>& scanResult) { 238 const vector<ScanResult>& scanResult) {
233 if (scan_result_handler_ != nullptr) { 239 cached_scan_results_ =
234 scan_result_handler_( 240 OffloadScanUtils::convertToNativeScanResults(scanResult);
235 OffloadScanUtils::convertToNativeScanResults(scanResult)); 241 if (event_callback_ != nullptr) {
242 event_callback_->OnOffloadScanResult();
236 } else { 243 } else {
237 LOG(ERROR) << "No scan result handler for Offload ScanManager"; 244 LOG(WARNING)
245 << "No callback to report Offload HAL's scan results to wificond";
238 } 246 }
239} 247}
240 248
@@ -260,6 +268,12 @@ void OffloadScanManager::ReportError(const OffloadStatus& status) {
260 } 268 }
261 if (status_result != OffloadScanManager::kNoError) { 269 if (status_result != OffloadScanManager::kNoError) {
262 LOG(WARNING) << "Offload Error reported " << status.description; 270 LOG(WARNING) << "Offload Error reported " << status.description;
271 if (event_callback_ != nullptr) {
272 event_callback_->OnOffloadError(
273 OffloadScanCallbackInterface::REMOTE_FAILURE);
274 } else {
275 LOG(WARNING) << "No callback to report Offload HAL Errors to wificond";
276 }
263 } 277 }
264 offload_status_ = status_result; 278 offload_status_ = status_result;
265} 279}
@@ -267,6 +281,14 @@ void OffloadScanManager::ReportError(const OffloadStatus& status) {
267void OffloadScanManager::OnObjectDeath(uint64_t cookie) { 281void OffloadScanManager::OnObjectDeath(uint64_t cookie) {
268 if (wifi_offload_hal_ == reinterpret_cast<IOffload*>(cookie)) { 282 if (wifi_offload_hal_ == reinterpret_cast<IOffload*>(cookie)) {
269 wifi_offload_hal_.clear(); 283 wifi_offload_hal_.clear();
284 if (event_callback_ != nullptr) {
285 event_callback_->OnOffloadError(
286 OffloadScanCallbackInterface::BINDER_DEATH);
287 } else {
288 LOG(WARNING)
289 << "No callback to report Offload HAL Binder death to wificond";
290 }
291
270 LOG(ERROR) << "Death Notification for Wifi Offload HAL"; 292 LOG(ERROR) << "Death Notification for Wifi Offload HAL";
271 } 293 }
272} 294}
diff --git a/scanning/offload/offload_scan_manager.h b/scanning/offload/offload_scan_manager.h
index e2c2b0c..c928ba9 100644
--- a/scanning/offload/offload_scan_manager.h
+++ b/scanning/offload/offload_scan_manager.h
@@ -20,6 +20,7 @@
20#include "wificond/scanning/offload/offload_callback.h" 20#include "wificond/scanning/offload/offload_callback.h"
21#include "wificond/scanning/offload/offload_callback_handlers.h" 21#include "wificond/scanning/offload/offload_callback_handlers.h"
22#include "wificond/scanning/offload/offload_service_utils.h" 22#include "wificond/scanning/offload/offload_service_utils.h"
23#include "wificond/scanning/offload_scan_callback_interface.h"
23 24
24#include <vector> 25#include <vector>
25 26
@@ -43,11 +44,6 @@ namespace wificond {
43 44
44class OffloadScanManager; 45class OffloadScanManager;
45 46
46typedef std::function<void(
47 const std::vector<::com::android::server::wifi::wificond::NativeScanResult>
48 scanResult)>
49 OnNativeScanResultsReadyHandler;
50
51// Provides callback interface implementation from Offload HAL 47// Provides callback interface implementation from Offload HAL
52class OffloadCallbackHandlersImpl : public OffloadCallbackHandlers { 48class OffloadCallbackHandlersImpl : public OffloadCallbackHandlers {
53 public: 49 public:
@@ -86,21 +82,19 @@ class OffloadScanManager {
86 kNone, 82 kNone,
87 /* Offload HAL scans is not available */ 83 /* Offload HAL scans is not available */
88 kNotAvailable, 84 kNotAvailable,
89 /* Offload HAL service is not subscribed to */
90 kNotSubscribed,
91 /* Offload HAL requested operation failure */ 85 /* Offload HAL requested operation failure */
92 kOperationFailed, 86 kOperationFailed,
93 /* Binder failed to deliver message to Offload HAL*/ 87 /* Binder failed to deliver message to Offload HAL*/
94 kTransactionFailed, 88 kTransactionFailed,
95 }; 89 };
96 90
97 explicit OffloadScanManager(std::weak_ptr<OffloadServiceUtils> utils, 91 explicit OffloadScanManager(
98 OnNativeScanResultsReadyHandler handler); 92 std::weak_ptr<OffloadServiceUtils> utils,
93 std::shared_ptr<OffloadScanCallbackInterface> callback);
99 virtual ~OffloadScanManager(); 94 virtual ~OffloadScanManager();
100 /* Request start of offload scans with scan parameters and scan filter 95 /* Request start of offload scans with scan parameters and scan filter
101 * settings. Internally calls Offload HAL service with configureScans() 96 * settings. Internally calls Offload HAL service with configureScans()
102 * and subscribeScanResults() APIs. If already subscribed, it updates 97 * and subscribeScanResults() APIs. Reason code indicates failure reason.
103 * the scan configuration only. Reason code is updated in failure case
104 */ 98 */
105 bool startScan(uint32_t /* interval_ms */, int32_t /* rssi_threshold */, 99 bool startScan(uint32_t /* interval_ms */, int32_t /* rssi_threshold */,
106 const std::vector<std::vector<uint8_t>>& /* scan_ssids */, 100 const std::vector<std::vector<uint8_t>>& /* scan_ssids */,
@@ -108,9 +102,8 @@ class OffloadScanManager {
108 const std::vector<uint8_t>& /* match_security */, 102 const std::vector<uint8_t>& /* match_security */,
109 const std::vector<uint32_t>& /* freqs */, 103 const std::vector<uint32_t>& /* freqs */,
110 ReasonCode* /* failure reason */); 104 ReasonCode* /* failure reason */);
111 /* Request stop of offload scans, returns true if scans were subscribed 105 /* Request stop of offload scans, returns true if the operation succeeds
112 * to from the Offload HAL service. Otherwise, returns false. Reason code 106 * Otherwise, returns false. Reason code is updated in case of failure.
113 * is updated in case of failure.
114 */ 107 */
115 bool stopScan(ReasonCode* /* failure reason */); 108 bool stopScan(ReasonCode* /* failure reason */);
116 /* Get statistics for scans performed by Offload HAL */ 109 /* Get statistics for scans performed by Offload HAL */
@@ -118,6 +111,10 @@ class OffloadScanManager {
118 ::com::android::server::wifi::wificond::NativeScanStats* /* scanStats */); 111 ::com::android::server::wifi::wificond::NativeScanStats* /* scanStats */);
119 /* Otain status of the Offload HAL service */ 112 /* Otain status of the Offload HAL service */
120 StatusCode getOffloadStatus() const; 113 StatusCode getOffloadStatus() const;
114 /* Returns the most recent scan result available from Offload HAL */
115 bool getScanResults(
116 std::vector<::com::android::server::wifi::wificond::NativeScanResult>*
117 out_scan_results);
121 118
122 private: 119 private:
123 void ReportScanResults( 120 void ReportScanResults(
@@ -143,10 +140,11 @@ class OffloadScanManager {
143 android::sp<OffloadCallback> wifi_offload_callback_; 140 android::sp<OffloadCallback> wifi_offload_callback_;
144 android::sp<OffloadDeathRecipient> death_recipient_; 141 android::sp<OffloadDeathRecipient> death_recipient_;
145 StatusCode offload_status_; 142 StatusCode offload_status_;
146 bool subscription_enabled_; 143 std::vector<::com::android::server::wifi::wificond::NativeScanResult>
144 cached_scan_results_;
147 145
148 const std::unique_ptr<OffloadCallbackHandlersImpl> offload_callback_handlers_; 146 const std::unique_ptr<OffloadCallbackHandlersImpl> offload_callback_handlers_;
149 OnNativeScanResultsReadyHandler scan_result_handler_; 147 std::shared_ptr<OffloadScanCallbackInterface> event_callback_;
150 148
151 friend class OffloadCallbackHandlersImpl; 149 friend class OffloadCallbackHandlersImpl;
152}; 150};
diff --git a/scanning/offload/offload_service_utils.cpp b/scanning/offload/offload_service_utils.cpp
index 2a14a32..da26b71 100644
--- a/scanning/offload/offload_service_utils.cpp
+++ b/scanning/offload/offload_service_utils.cpp
@@ -14,6 +14,9 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16#include "wificond/scanning/offload/offload_service_utils.h" 16#include "wificond/scanning/offload/offload_service_utils.h"
17
18#include <android-base/logging.h>
19
17#include "wificond/scanning/offload/offload_scan_manager.h" 20#include "wificond/scanning/offload/offload_scan_manager.h"
18 21
19using ::android::hardware::wifi::offload::V1_0::IOffload; 22using ::android::hardware::wifi::offload::V1_0::IOffload;
diff --git a/scanning/offload_scan_callback_interface.h b/scanning/offload_scan_callback_interface.h
new file mode 100644
index 0000000..507a69f
--- /dev/null
+++ b/scanning/offload_scan_callback_interface.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2017 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#ifndef ANDROID_WIFICOND_OFFLOAD_SCAN_CALLBACK_INTERFACE_H
17#define ANDROID_WIFICOND_OFFLOAD_SCAN_CALLBACK_INTERFACE_H
18
19#include <vector>
20
21#include "wificond/scanning/scan_result.h"
22
23namespace android {
24namespace wificond {
25
26class OffloadScanCallbackInterface {
27 public:
28 enum AsyncErrorReason {
29 BINDER_DEATH = 0,
30 REMOTE_FAILURE,
31 };
32
33 virtual ~OffloadScanCallbackInterface() {}
34
35 virtual void OnOffloadScanResult() = 0;
36 virtual void OnOffloadError(AsyncErrorReason) = 0;
37};
38
39} // namespace wificond
40} // namespace android
41
42#endif // ANDROID_WIFICOND_OFFLOAD_SCAN_CALLBACK_INTERFACE_H
diff --git a/scanning/offload_scan_callback_interface_impl.cpp b/scanning/offload_scan_callback_interface_impl.cpp
new file mode 100644
index 0000000..a3e39da
--- /dev/null
+++ b/scanning/offload_scan_callback_interface_impl.cpp
@@ -0,0 +1,42 @@
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#include "wificond/scanning/offload_scan_callback_interface_impl.h"
18
19#include <android-base/logging.h>
20
21using com::android::server::wifi::wificond::NativeScanResult;
22
23namespace android {
24namespace wificond {
25
26OffloadScanCallbackInterfaceImpl::OffloadScanCallbackInterfaceImpl(
27 ScannerImpl* parent)
28 : scanner_impl_(parent) {}
29
30OffloadScanCallbackInterfaceImpl::~OffloadScanCallbackInterfaceImpl() {}
31
32void OffloadScanCallbackInterfaceImpl::OnOffloadScanResult() {
33 scanner_impl_->OnOffloadScanResult();
34}
35
36void OffloadScanCallbackInterfaceImpl::OnOffloadError(
37 OffloadScanCallbackInterface::AsyncErrorReason error_code) {
38 scanner_impl_->OnOffloadError(error_code);
39}
40
41} // namespace wificond
42} // namespace android
diff --git a/scanning/offload_scan_callback_interface_impl.h b/scanning/offload_scan_callback_interface_impl.h
new file mode 100644
index 0000000..0f500a4
--- /dev/null
+++ b/scanning/offload_scan_callback_interface_impl.h
@@ -0,0 +1,44 @@
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_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
18#define WIFICOND_SCANNER_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
19
20#include "wificond/scanning/offload_scan_callback_interface.h"
21#include "wificond/scanning/scanner_impl.h"
22
23namespace android {
24namespace wificond {
25
26class ScannerImpl;
27
28class OffloadScanCallbackInterfaceImpl
29 : public android::wificond::OffloadScanCallbackInterface {
30 public:
31 OffloadScanCallbackInterfaceImpl(ScannerImpl* parent);
32 ~OffloadScanCallbackInterfaceImpl() override;
33
34 void OnOffloadScanResult() override;
35 void OnOffloadError(OffloadScanCallbackInterface::AsyncErrorReason) override;
36
37 private:
38 ScannerImpl* scanner_impl_;
39};
40
41} // namespace wificond
42} // namespace android
43
44#endif // WIFICOND_SCANNER_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
diff --git a/scanning/scanner_impl.cpp b/scanning/scanner_impl.cpp
index 9bf13b3..e9ff517 100644
--- a/scanning/scanner_impl.cpp
+++ b/scanning/scanner_impl.cpp
@@ -22,9 +22,9 @@
22#include <android-base/logging.h> 22#include <android-base/logging.h>
23 23
24#include "wificond/client_interface_impl.h" 24#include "wificond/client_interface_impl.h"
25#include "wificond/scanning/scan_utils.h"
26#include "wificond/scanning/offload/offload_service_utils.h"
27#include "wificond/scanning/offload/offload_scan_manager.h" 25#include "wificond/scanning/offload/offload_scan_manager.h"
26#include "wificond/scanning/offload/offload_service_utils.h"
27#include "wificond/scanning/scan_utils.h"
28 28
29using android::binder::Status; 29using android::binder::Status;
30using android::net::wifi::IPnoScanEvent; 30using android::net::wifi::IPnoScanEvent;
@@ -39,19 +39,18 @@ using std::pair;
39using std::string; 39using std::string;
40using std::vector; 40using std::vector;
41using std::weak_ptr; 41using std::weak_ptr;
42using std::shared_ptr;
42 43
43using namespace std::placeholders; 44using namespace std::placeholders;
44 45
45namespace android { 46namespace android {
46namespace wificond { 47namespace wificond {
47 48
48ScannerImpl::ScannerImpl(uint32_t wiphy_index, 49ScannerImpl::ScannerImpl(uint32_t wiphy_index, uint32_t interface_index,
49 uint32_t interface_index,
50 const ScanCapabilities& scan_capabilities, 50 const ScanCapabilities& scan_capabilities,
51 const WiphyFeatures& wiphy_features, 51 const WiphyFeatures& wiphy_features,
52 ClientInterfaceImpl* client_interface, 52 ClientInterfaceImpl* client_interface,
53 NetlinkUtils* netlink_utils, 53 NetlinkUtils* netlink_utils, ScanUtils* scan_utils,
54 ScanUtils* scan_utils,
55 weak_ptr<OffloadServiceUtils> offload_service_utils) 54 weak_ptr<OffloadServiceUtils> offload_service_utils)
56 : valid_(true), 55 : valid_(true),
57 scan_started_(false), 56 scan_started_(false),
@@ -70,25 +69,23 @@ ScannerImpl::ScannerImpl(uint32_t wiphy_index,
70 << (int)interface_index_; 69 << (int)interface_index_;
71 scan_utils_->SubscribeScanResultNotification( 70 scan_utils_->SubscribeScanResultNotification(
72 interface_index_, 71 interface_index_,
73 std::bind(&ScannerImpl::OnScanResultsReady, 72 std::bind(&ScannerImpl::OnScanResultsReady, this, _1, _2, _3, _4));
74 this,
75 _1, _2, _3, _4));
76 // Subscribe scheduled scan result notification from kernel. 73 // Subscribe scheduled scan result notification from kernel.
77 scan_utils_->SubscribeSchedScanResultNotification( 74 scan_utils_->SubscribeSchedScanResultNotification(
78 interface_index_, 75 interface_index_,
79 std::bind(&ScannerImpl::OnSchedScanResultsReady, 76 std::bind(&ScannerImpl::OnSchedScanResultsReady,
80 this, 77 this,
81 _1, _2)); 78 _1, _2));
82 offload_scan_manager_.reset( 79 std::shared_ptr<OffloadScanCallbackInterfaceImpl>
83 new OffloadScanManager( 80 offload_scan_callback_interface =
84 offload_service_utils, 81 std::make_shared<OffloadScanCallbackInterfaceImpl>(
85 std::bind(&ScannerImpl::OnOffloadScanResult, 82 *(new OffloadScanCallbackInterfaceImpl(this)));
86 this, _1))); 83 offload_scan_manager_.reset(new OffloadScanManager(
84 offload_service_utils, offload_scan_callback_interface));
87 offload_scan_supported_ = offload_service_utils.lock()->IsOffloadScanSupported(); 85 offload_scan_supported_ = offload_service_utils.lock()->IsOffloadScanSupported();
88} 86}
89 87
90ScannerImpl::~ScannerImpl() { 88ScannerImpl::~ScannerImpl() {}
91}
92 89
93void ScannerImpl::Invalidate() { 90void ScannerImpl::Invalidate() {
94 LOG(INFO) << "Unsubscribe scan result for interface with index: " 91 LOG(INFO) << "Unsubscribe scan result for interface with index: "
@@ -111,17 +108,15 @@ Status ScannerImpl::getAvailable2gChannels(
111 return Status::ok(); 108 return Status::ok();
112 } 109 }
113 BandInfo band_info; 110 BandInfo band_info;
114 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, 111 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, &band_info,
115 &band_info, 112 &scan_capabilities_, &wiphy_features_)) {
116 &scan_capabilities_,
117 &wiphy_features_)) {
118 LOG(ERROR) << "Failed to get wiphy info from kernel"; 113 LOG(ERROR) << "Failed to get wiphy info from kernel";
119 out_frequencies->reset(nullptr); 114 out_frequencies->reset(nullptr);
120 return Status::ok(); 115 return Status::ok();
121 } 116 }
122 117
123 out_frequencies->reset(new vector<int32_t>(band_info.band_2g.begin(), 118 out_frequencies->reset(
124 band_info.band_2g.end())); 119 new vector<int32_t>(band_info.band_2g.begin(), band_info.band_2g.end()));
125 return Status::ok(); 120 return Status::ok();
126} 121}
127 122
@@ -131,17 +126,15 @@ Status ScannerImpl::getAvailable5gNonDFSChannels(
131 return Status::ok(); 126 return Status::ok();
132 } 127 }
133 BandInfo band_info; 128 BandInfo band_info;
134 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, 129 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, &band_info,
135 &band_info, 130 &scan_capabilities_, &wiphy_features_)) {
136 &scan_capabilities_,
137 &wiphy_features_)) {
138 LOG(ERROR) << "Failed to get wiphy info from kernel"; 131 LOG(ERROR) << "Failed to get wiphy info from kernel";
139 out_frequencies->reset(nullptr); 132 out_frequencies->reset(nullptr);
140 return Status::ok(); 133 return Status::ok();
141 } 134 }
142 135
143 out_frequencies->reset(new vector<int32_t>(band_info.band_5g.begin(), 136 out_frequencies->reset(
144 band_info.band_5g.end())); 137 new vector<int32_t>(band_info.band_5g.begin(), band_info.band_5g.end()));
145 return Status::ok(); 138 return Status::ok();
146} 139}
147 140
@@ -151,10 +144,8 @@ Status ScannerImpl::getAvailableDFSChannels(
151 return Status::ok(); 144 return Status::ok();
152 } 145 }
153 BandInfo band_info; 146 BandInfo band_info;
154 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, 147 if (!netlink_utils_->GetWiphyInfo(wiphy_index_, &band_info,
155 &band_info, 148 &scan_capabilities_, &wiphy_features_)) {
156 &scan_capabilities_,
157 &wiphy_features_)) {
158 LOG(ERROR) << "Failed to get wiphy info from kernel"; 149 LOG(ERROR) << "Failed to get wiphy info from kernel";
159 out_frequencies->reset(nullptr); 150 out_frequencies->reset(nullptr);
160 return Status::ok(); 151 return Status::ok();
@@ -186,8 +177,8 @@ Status ScannerImpl::scan(const SingleScanSettings& scan_settings,
186 LOG(WARNING) << "Scan already started"; 177 LOG(WARNING) << "Scan already started";
187 } 178 }
188 // Only request MAC address randomization when station is not associated. 179 // Only request MAC address randomization when station is not associated.
189 bool request_random_mac = wiphy_features_.supports_random_mac_oneshot_scan && 180 bool request_random_mac = wiphy_features_.supports_random_mac_oneshot_scan &&
190 !client_interface_->IsAssociated(); 181 !client_interface_->IsAssociated();
191 182
192 // Initialize it with an empty ssid for a wild card scan. 183 // Initialize it with an empty ssid for a wild card scan.
193 vector<vector<uint8_t>> ssids = {{}}; 184 vector<vector<uint8_t>> ssids = {{}};
@@ -222,11 +213,12 @@ Status ScannerImpl::scan(const SingleScanSettings& scan_settings,
222 213
223Status ScannerImpl::startPnoScan(const PnoSettings& pno_settings, 214Status ScannerImpl::startPnoScan(const PnoSettings& pno_settings,
224 bool* out_success) { 215 bool* out_success) {
225 if (!offload_scan_supported_ || !StartPnoScanOffload(pno_settings)) { 216 pno_settings_ = pno_settings;
226 *out_success = StartPnoScanDefault(pno_settings); 217 if (offload_scan_supported_ && StartPnoScanOffload(pno_settings)) {
227 } else {
228 // scanning over offload succeeded 218 // scanning over offload succeeded
229 *out_success = true; 219 *out_success = true;
220 } else {
221 *out_success = StartPnoScanDefault(pno_settings);
230 } 222 }
231 return Status::ok(); 223 return Status::ok();
232} 224}
@@ -239,25 +231,28 @@ bool ScannerImpl::StartPnoScanOffload(const PnoSettings& pno_settings) {
239 // Empty frequency list: scan all frequencies. 231 // Empty frequency list: scan all frequencies.
240 vector<uint32_t> freqs; 232 vector<uint32_t> freqs;
241 233
242 ParsePnoSettings(pno_settings, &scan_ssids, &match_ssids, &freqs, &match_security); 234 ParsePnoSettings(pno_settings, &scan_ssids, &match_ssids, &freqs,
243 235 &match_security);
244 bool success = offload_scan_manager_->startScan( 236
245 pno_settings.interval_ms_, 237 pno_scan_running_over_offload_ = offload_scan_manager_->startScan(
246 // TODO: honor both rssi thresholds. 238 pno_settings.interval_ms_,
247 pno_settings.min_5g_rssi_, 239 // TODO: honor both rssi thresholds.
248 scan_ssids, 240 pno_settings.min_5g_rssi_, scan_ssids, match_ssids, match_security, freqs,
249 match_ssids, 241 &reason_code);
250 match_security, 242 if (pno_scan_running_over_offload_) {
251 freqs, 243 LOG(VERBOSE) << "Pno scans requested over Offload HAL";
252 &reason_code); 244 if (pno_scan_event_handler_ != nullptr) {
253 return success; 245 pno_scan_event_handler_->OnPnoScanOverOffloadStarted();
246 }
247 }
248 return pno_scan_running_over_offload_;
254} 249}
255 250
256void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings, 251void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
257 vector<vector<uint8_t>>* scan_ssids, 252 vector<vector<uint8_t>>* scan_ssids,
258 vector<vector<uint8_t>>* match_ssids, 253 vector<vector<uint8_t>>* match_ssids,
259 vector<uint32_t>* freqs, 254 vector<uint32_t>* freqs,
260 vector<uint8_t>* match_security) { 255 vector<uint8_t>* match_security) {
261 // TODO provide actionable security match parameters 256 // TODO provide actionable security match parameters
262 const uint8_t kNetworkFlagsDefault = 0; 257 const uint8_t kNetworkFlagsDefault = 0;
263 vector<vector<uint8_t>> skipped_scan_ssids; 258 vector<vector<uint8_t>> skipped_scan_ssids;
@@ -266,7 +261,8 @@ void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
266 // Add hidden network ssid. 261 // Add hidden network ssid.
267 if (network.is_hidden_) { 262 if (network.is_hidden_) {
268 // TODO remove pruning for Offload Scans 263 // TODO remove pruning for Offload Scans
269 if (scan_ssids->size() + 1 > scan_capabilities_.max_num_sched_scan_ssids) { 264 if (scan_ssids->size() + 1 >
265 scan_capabilities_.max_num_sched_scan_ssids) {
270 skipped_scan_ssids.emplace_back(network.ssid_); 266 skipped_scan_ssids.emplace_back(network.ssid_);
271 continue; 267 continue;
272 } 268 }
@@ -287,7 +283,7 @@ void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
287 283
288bool ScannerImpl::StartPnoScanDefault(const PnoSettings& pno_settings) { 284bool ScannerImpl::StartPnoScanDefault(const PnoSettings& pno_settings) {
289 if (!CheckIsValid()) { 285 if (!CheckIsValid()) {
290 return false; 286 return false;
291 } 287 }
292 if (pno_scan_started_) { 288 if (pno_scan_started_) {
293 LOG(WARNING) << "Pno scan already started"; 289 LOG(WARNING) << "Pno scan already started";
@@ -324,18 +320,27 @@ bool ScannerImpl::StartPnoScanDefault(const PnoSettings& pno_settings) {
324} 320}
325 321
326Status ScannerImpl::stopPnoScan(bool* out_success) { 322Status ScannerImpl::stopPnoScan(bool* out_success) {
327 if (!offload_scan_supported_ || !StopPnoScanOffload()) { 323 if (offload_scan_supported_ && StopPnoScanOffload()) {
328 *out_success = StopPnoScanDefault();
329 } else {
330 // Pno scans over offload stopped successfully 324 // Pno scans over offload stopped successfully
331 *out_success = true; 325 *out_success = true;
326 } else {
327 // Pno scans were not requested over offload
328 *out_success = StopPnoScanDefault();
332 } 329 }
333 return Status::ok(); 330 return Status::ok();
334} 331}
335 332
336bool ScannerImpl::StopPnoScanOffload() { 333bool ScannerImpl::StopPnoScanOffload() {
337 OffloadScanManager::ReasonCode reason_code; 334 OffloadScanManager::ReasonCode reason_code;
338 return(offload_scan_manager_->stopScan(&reason_code)); 335 if (!pno_scan_running_over_offload_) {
336 return false;
337 }
338 if (!offload_scan_manager_->stopScan(&reason_code)) {
339 LOG(WARNING) << "Unable to unsubscribe to Offload scan results";
340 }
341 pno_scan_running_over_offload_ = false;
342 LOG(VERBOSE) << "Pno scans over Offload stopped";
343 return true;
339} 344}
340 345
341bool ScannerImpl::StopPnoScanDefault() { 346bool ScannerImpl::StopPnoScanDefault() {
@@ -387,7 +392,6 @@ Status ScannerImpl::unsubscribeScanEvents() {
387 return Status::ok(); 392 return Status::ok();
388} 393}
389 394
390
391Status ScannerImpl::subscribePnoScanEvents(const sp<IPnoScanEvent>& handler) { 395Status ScannerImpl::subscribePnoScanEvents(const sp<IPnoScanEvent>& handler) {
392 if (!CheckIsValid()) { 396 if (!CheckIsValid()) {
393 return Status::ok(); 397 return Status::ok();
@@ -407,11 +411,9 @@ Status ScannerImpl::unsubscribePnoScanEvents() {
407 return Status::ok(); 411 return Status::ok();
408} 412}
409 413
410void ScannerImpl::OnScanResultsReady( 414void ScannerImpl::OnScanResultsReady(uint32_t interface_index, bool aborted,
411 uint32_t interface_index, 415 vector<vector<uint8_t>>& ssids,
412 bool aborted, 416 vector<uint32_t>& frequencies) {
413 vector<vector<uint8_t>>& ssids,
414 vector<uint32_t>& frequencies) {
415 if (!scan_started_) { 417 if (!scan_started_) {
416 LOG(INFO) << "Received external scan result notification from kernel."; 418 LOG(INFO) << "Received external scan result notification from kernel.";
417 } 419 }
@@ -476,6 +478,58 @@ SchedScanIntervalSetting ScannerImpl::GenerateIntervalSetting(
476 } 478 }
477} 479}
478 480
481void ScannerImpl::OnOffloadScanResult() {
482 if (!pno_scan_running_over_offload_) {
483 LOG(WARNING) << "Scan results from Offload HAL but scan not requested over "
484 "this interface";
485 return;
486 }
487 LOG(INFO) << "Offload Scan results received";
488 if (pno_scan_event_handler_ != nullptr) {
489 pno_scan_event_handler_->OnPnoNetworkFound();
490 } else {
491 LOG(WARNING) << "No scan event handler Offload Scan result";
492 }
493}
494
495void ScannerImpl::OnOffloadError(
496 OffloadScanCallbackInterface::AsyncErrorReason error_code) {
497 bool success;
498 if (!pno_scan_running_over_offload_) {
499 // Ignore irrelevant error notifications
500 LOG(WARNING) << "Offload HAL Async Error occured but Offload HAL is not "
501 "subscribed to";
502 return;
503 }
504 LOG(ERROR) << "Offload Service Async Failure error_code=" << error_code;
505 // Stop scans over Offload HAL and request them over netlink
506 stopPnoScan(&success);
507 if (success) {
508 LOG(INFO) << "Pno scans stopped";
509 }
510 switch (error_code) {
511 case OffloadScanCallbackInterface::AsyncErrorReason::BINDER_DEATH:
512 if (pno_scan_event_handler_ != nullptr) {
513 pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
514 net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_BINDER_FAILURE);
515 }
516 break;
517 case OffloadScanCallbackInterface::AsyncErrorReason::REMOTE_FAILURE:
518 if (pno_scan_event_handler_ != nullptr) {
519 pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
520 net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_REMOTE_FAILURE);
521 }
522 break;
523 default:
524 LOG(WARNING) << "Invalid Error code";
525 break;
526 }
527 startPnoScan(pno_settings_, &success);
528 if (success) {
529 LOG(INFO) << "Pno scans restarted";
530 }
531}
532
479void ScannerImpl::LogSsidList(vector<vector<uint8_t>>& ssid_list, 533void ScannerImpl::LogSsidList(vector<vector<uint8_t>>& ssid_list,
480 string prefix) { 534 string prefix) {
481 if (ssid_list.empty()) { 535 if (ssid_list.empty()) {
@@ -491,15 +545,5 @@ void ScannerImpl::LogSsidList(vector<vector<uint8_t>>& ssid_list,
491 LOG(WARNING) << prefix << ": " << ssid_list_string; 545 LOG(WARNING) << prefix << ": " << ssid_list_string;
492} 546}
493 547
494void ScannerImpl::OnOffloadScanResult(
495 std::vector<NativeScanResult> scanResult) {
496 LOG(INFO) << "Offload Scan results received";
497 if (pno_scan_event_handler_ != nullptr) {
498 pno_scan_event_handler_->OnPnoNetworkFound();
499 } else {
500 LOG(WARNING) << "No scan event handler Offload Scan result";
501 }
502}
503
504} // namespace wificond 548} // namespace wificond
505} // namespace android 549} // namespace android
diff --git a/scanning/scanner_impl.h b/scanning/scanner_impl.h
index 2bb9262..e97e967 100644
--- a/scanning/scanner_impl.h
+++ b/scanning/scanner_impl.h
@@ -26,22 +26,23 @@
26#include "wificond/net/netlink_utils.h" 26#include "wificond/net/netlink_utils.h"
27#include "wificond/scanning/offload/offload_scan_manager.h" 27#include "wificond/scanning/offload/offload_scan_manager.h"
28#include "wificond/scanning/scan_utils.h" 28#include "wificond/scanning/scan_utils.h"
29#include "wificond/scanning/offload_scan_callback_interface_impl.h"
29 30
30namespace android { 31namespace android {
31namespace wificond { 32namespace wificond {
32 33
33class ClientInterfaceImpl; 34class ClientInterfaceImpl;
34class OffloadServiceUtils; 35class OffloadServiceUtils;
36class ScanUtils;
37class OffloadScanCallbackInterfaceImpl;
35 38
36class ScannerImpl : public android::net::wifi::BnWifiScannerImpl { 39class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
37 public: 40 public:
38 ScannerImpl(uint32_t wiphy_index, 41 ScannerImpl(uint32_t wiphy_index, uint32_t interface_index,
39 uint32_t interface_index,
40 const ScanCapabilities& scan_capabilities, 42 const ScanCapabilities& scan_capabilities,
41 const WiphyFeatures& wiphy_features, 43 const WiphyFeatures& wiphy_features,
42 ClientInterfaceImpl* client_interface, 44 ClientInterfaceImpl* client_interface,
43 NetlinkUtils* netlink_utils, 45 NetlinkUtils* netlink_utils, ScanUtils* scan_utils,
44 ScanUtils* scan_utils,
45 std::weak_ptr<OffloadServiceUtils> offload_service_utils); 46 std::weak_ptr<OffloadServiceUtils> offload_service_utils);
46 ~ScannerImpl(); 47 ~ScannerImpl();
47 // Returns a vector of available frequencies for 2.4GHz channels. 48 // Returns a vector of available frequencies for 2.4GHz channels.
@@ -71,19 +72,19 @@ class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
71 const ::android::sp<::android::net::wifi::IScanEvent>& handler) override; 72 const ::android::sp<::android::net::wifi::IScanEvent>& handler) override;
72 ::android::binder::Status unsubscribeScanEvents() override; 73 ::android::binder::Status unsubscribeScanEvents() override;
73 ::android::binder::Status subscribePnoScanEvents( 74 ::android::binder::Status subscribePnoScanEvents(
74 const ::android::sp<::android::net::wifi::IPnoScanEvent>& handler) override; 75 const ::android::sp<::android::net::wifi::IPnoScanEvent>& handler)
76 override;
75 ::android::binder::Status unsubscribePnoScanEvents() override; 77 ::android::binder::Status unsubscribePnoScanEvents() override;
78 void OnOffloadScanResult();
79 void OnOffloadError(
80 OffloadScanCallbackInterface::AsyncErrorReason error_code);
76 void Invalidate(); 81 void Invalidate();
77 82
78 private: 83 private:
79 bool CheckIsValid(); 84 bool CheckIsValid();
80 void OnOffloadScanResult( 85 void OnScanResultsReady(uint32_t interface_index, bool aborted,
81 std::vector<::com::android::server::wifi::wificond::NativeScanResult>); 86 std::vector<std::vector<uint8_t>>& ssids,
82 void OnScanResultsReady( 87 std::vector<uint32_t>& frequencies);
83 uint32_t interface_index,
84 bool aborted,
85 std::vector<std::vector<uint8_t>>& ssids,
86 std::vector<uint32_t>& frequencies);
87 void OnSchedScanResultsReady(uint32_t interface_index, bool scan_stopped); 88 void OnSchedScanResultsReady(uint32_t interface_index, bool scan_stopped);
88 void LogSsidList(std::vector<std::vector<uint8_t>>& ssid_list, 89 void LogSsidList(std::vector<std::vector<uint8_t>>& ssid_list,
89 std::string prefix); 90 std::string prefix);
@@ -94,11 +95,10 @@ class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
94 bool StopPnoScanDefault(); 95 bool StopPnoScanDefault();
95 bool StopPnoScanOffload(); 96 bool StopPnoScanOffload();
96 void ParsePnoSettings( 97 void ParsePnoSettings(
97 const ::com::android::server::wifi::wificond::PnoSettings& pno_settings, 98 const ::com::android::server::wifi::wificond::PnoSettings& pno_settings,
98 std::vector<std::vector<uint8_t>>* scan_ssids, 99 std::vector<std::vector<uint8_t>>* scan_ssids,
99 std::vector<std::vector<uint8_t>>* match_ssids, 100 std::vector<std::vector<uint8_t>>* match_ssids,
100 std::vector<uint32_t>* freqs, 101 std::vector<uint32_t>* freqs, std::vector<uint8_t>* match_security);
101 std::vector<uint8_t>* match_security);
102 SchedScanIntervalSetting GenerateIntervalSetting( 102 SchedScanIntervalSetting GenerateIntervalSetting(
103 const ::com::android::server::wifi::wificond::PnoSettings& pno_settings) const; 103 const ::com::android::server::wifi::wificond::PnoSettings& pno_settings) const;
104 104
@@ -107,6 +107,8 @@ class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
107 bool scan_started_; 107 bool scan_started_;
108 bool pno_scan_started_; 108 bool pno_scan_started_;
109 bool offload_scan_supported_; 109 bool offload_scan_supported_;
110 bool pno_scan_running_over_offload_;
111 ::com::android::server::wifi::wificond::PnoSettings pno_settings_;
110 112
111 const uint32_t wiphy_index_; 113 const uint32_t wiphy_index_;
112 const uint32_t interface_index_; 114 const uint32_t interface_index_;
diff --git a/tests/mock_offload_scan_callback_interface.cpp b/tests/mock_offload_scan_callback_interface.cpp
new file mode 100644
index 0000000..cb76e45
--- /dev/null
+++ b/tests/mock_offload_scan_callback_interface.cpp
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2017 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#include "wificond/tests/mock_offload_scan_callback_interface.h"
18
19namespace android {
20namespace wificond {
21
22MockOffloadScanCallbackInterface::MockOffloadScanCallbackInterface() {}
23
24} // namespace wificond
25} // namespace android
diff --git a/tests/mock_offload_scan_callback_interface.h b/tests/mock_offload_scan_callback_interface.h
new file mode 100644
index 0000000..e7cdcc1
--- /dev/null
+++ b/tests/mock_offload_scan_callback_interface.h
@@ -0,0 +1,41 @@
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_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
18#define WIFICOND_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
19
20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
22
23#include "wificond/scanning/offload_scan_callback_interface.h"
24
25namespace android {
26namespace wificond {
27
28class MockOffloadScanCallbackInterface : public OffloadScanCallbackInterface {
29 public:
30 MockOffloadScanCallbackInterface();
31 ~MockOffloadScanCallbackInterface() override = default;
32
33 MOCK_METHOD0(OnOffloadScanResult, void());
34 MOCK_METHOD1(OnOffloadError,
35 void(OffloadScanCallbackInterface::AsyncErrorReason));
36};
37
38} // namespace wificond
39} // namespace android
40
41#endif // WIFICOND_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
diff --git a/tests/offload_scan_manager_test.cpp b/tests/offload_scan_manager_test.cpp
index 2dbf953..9c612ae 100644
--- a/tests/offload_scan_manager_test.cpp
+++ b/tests/offload_scan_manager_test.cpp
@@ -23,6 +23,7 @@
23#include <gtest/gtest.h> 23#include <gtest/gtest.h>
24 24
25#include "wificond/tests/mock_offload.h" 25#include "wificond/tests/mock_offload.h"
26#include "wificond/tests/mock_offload_scan_callback_interface.h"
26#include "wificond/tests/mock_offload_service_utils.h" 27#include "wificond/tests/mock_offload_service_utils.h"
27#include "wificond/tests/offload_hal_test_constants.h" 28#include "wificond/tests/offload_hal_test_constants.h"
28#include "wificond/tests/offload_test_utils.h" 29#include "wificond/tests/offload_test_utils.h"
@@ -112,6 +113,9 @@ class OffloadScanManagerTest : public ::testing::Test {
112 sp<OffloadDeathRecipient> death_recipient_; 113 sp<OffloadDeathRecipient> death_recipient_;
113 shared_ptr<NiceMock<MockOffloadServiceUtils>> mock_offload_service_utils_{ 114 shared_ptr<NiceMock<MockOffloadServiceUtils>> mock_offload_service_utils_{
114 new NiceMock<MockOffloadServiceUtils>()}; 115 new NiceMock<MockOffloadServiceUtils>()};
116 shared_ptr<NiceMock<MockOffloadScanCallbackInterface>>
117 mock_offload_scan_callback_interface_{
118 new NiceMock<MockOffloadScanCallbackInterface>()};
115 unique_ptr<OffloadScanManager> offload_scan_manager_; 119 unique_ptr<OffloadScanManager> offload_scan_manager_;
116 OffloadStatus status; 120 OffloadStatus status;
117 vector<vector<uint8_t>> scan_ssids{kSsid1, kSsid2}; 121 vector<vector<uint8_t>> scan_ssids{kSsid1, kSsid2};
@@ -131,8 +135,8 @@ TEST_F(OffloadScanManagerTest, BinderDeathRegisteredCookieAndService) {
131 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 135 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
132 .WillByDefault(testing::Return(mock_offload_)); 136 .WillByDefault(testing::Return(mock_offload_));
133 offload_scan_manager_.reset(new OffloadScanManager( 137 offload_scan_manager_.reset(new OffloadScanManager(
134 mock_offload_service_utils_, 138 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
135 [](vector<NativeScanResult> scanResult) -> void {})); 139 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
136 death_recipient_->serviceDied(cookie_, mock_offload_); 140 death_recipient_->serviceDied(cookie_, mock_offload_);
137 EXPECT_EQ(OffloadScanManager::kNoService, 141 EXPECT_EQ(OffloadScanManager::kNoService,
138 offload_scan_manager_->getOffloadStatus()); 142 offload_scan_manager_->getOffloadStatus());
@@ -147,8 +151,7 @@ TEST_F(OffloadScanManagerTest, BinderDeathUnregisteredCookie) {
147 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 151 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
148 .WillByDefault(testing::Return(mock_offload_)); 152 .WillByDefault(testing::Return(mock_offload_));
149 offload_scan_manager_.reset(new OffloadScanManager( 153 offload_scan_manager_.reset(new OffloadScanManager(
150 mock_offload_service_utils_, 154 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
151 [](vector<NativeScanResult> scanResult) -> void {}));
152 death_recipient_->serviceDied(kDeathCode, mock_offload_); 155 death_recipient_->serviceDied(kDeathCode, mock_offload_);
153 EXPECT_FALSE(OffloadScanManager::kNoService == 156 EXPECT_FALSE(OffloadScanManager::kNoService ==
154 offload_scan_manager_->getOffloadStatus()); 157 offload_scan_manager_->getOffloadStatus());
@@ -163,8 +166,7 @@ TEST_F(OffloadScanManagerTest, ServiceNotAvailableTest) {
163 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 166 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
164 .WillByDefault(testing::Return(nullptr)); 167 .WillByDefault(testing::Return(nullptr));
165 offload_scan_manager_.reset(new OffloadScanManager( 168 offload_scan_manager_.reset(new OffloadScanManager(
166 mock_offload_service_utils_, 169 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
167 [](vector<NativeScanResult> scanResult) -> void {}));
168 EXPECT_EQ(OffloadScanManager::kNoService, 170 EXPECT_EQ(OffloadScanManager::kNoService,
169 offload_scan_manager_->getOffloadStatus()); 171 offload_scan_manager_->getOffloadStatus());
170} 172}
@@ -180,8 +182,7 @@ TEST_F(OffloadScanManagerTest, ServiceAvailableTest) {
180 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 182 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
181 .WillByDefault(testing::Return(mock_offload_)); 183 .WillByDefault(testing::Return(mock_offload_));
182 offload_scan_manager_.reset(new OffloadScanManager( 184 offload_scan_manager_.reset(new OffloadScanManager(
183 mock_offload_service_utils_, 185 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
184 [](vector<NativeScanResult> scanResult) -> void {}));
185 EXPECT_EQ(OffloadScanManager::kNoError, 186 EXPECT_EQ(OffloadScanManager::kNoError,
186 offload_scan_manager_->getOffloadStatus()); 187 offload_scan_manager_->getOffloadStatus());
187} 188}
@@ -192,21 +193,17 @@ TEST_F(OffloadScanManagerTest, ServiceAvailableTest) {
192 * scan results are available 193 * scan results are available
193 */ 194 */
194TEST_F(OffloadScanManagerTest, CallbackInvokedTest) { 195TEST_F(OffloadScanManagerTest, CallbackInvokedTest) {
195 bool callback_invoked = false;
196 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService()); 196 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
197 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_)); 197 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
198 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_)); 198 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
199 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 199 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
200 .WillByDefault(testing::Return(mock_offload_)); 200 .WillByDefault(testing::Return(mock_offload_));
201 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadScanResult());
201 offload_scan_manager_.reset(new OffloadScanManager( 202 offload_scan_manager_.reset(new OffloadScanManager(
202 mock_offload_service_utils_, 203 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
203 [&callback_invoked](vector<NativeScanResult> scanResult) -> void {
204 callback_invoked = true;
205 }));
206 vector<ScanResult> dummy_scan_results_ = 204 vector<ScanResult> dummy_scan_results_ =
207 OffloadTestUtils::createOffloadScanResults(); 205 OffloadTestUtils::createOffloadScanResults();
208 offload_callback_->onScanResult(dummy_scan_results_); 206 offload_callback_->onScanResult(dummy_scan_results_);
209 EXPECT_EQ(true, callback_invoked);
210} 207}
211 208
212/** 209/**
@@ -220,10 +217,10 @@ TEST_F(OffloadScanManagerTest, ErrorCallbackInvokedTest) {
220 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 217 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
221 .WillByDefault(testing::Return(mock_offload_)); 218 .WillByDefault(testing::Return(mock_offload_));
222 offload_scan_manager_.reset(new OffloadScanManager( 219 offload_scan_manager_.reset(new OffloadScanManager(
223 mock_offload_service_utils_, 220 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
224 [](vector<NativeScanResult> scanResult) -> void {}));
225 OffloadStatus status = 221 OffloadStatus status =
226 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR); 222 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
223 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
227 offload_callback_->onError(status); 224 offload_callback_->onError(status);
228 EXPECT_EQ(offload_scan_manager_->getOffloadStatus(), 225 EXPECT_EQ(offload_scan_manager_->getOffloadStatus(),
229 OffloadScanManager::kError); 226 OffloadScanManager::kError);
@@ -240,8 +237,7 @@ TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsOk) {
240 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 237 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
241 .WillByDefault(testing::Return(mock_offload_)); 238 .WillByDefault(testing::Return(mock_offload_));
242 offload_scan_manager_.reset(new OffloadScanManager( 239 offload_scan_manager_.reset(new OffloadScanManager(
243 mock_offload_service_utils_, 240 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
244 [](vector<NativeScanResult> scanResult) -> void {}));
245 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)); 241 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
246 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)); 242 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
247 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone; 243 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
@@ -260,8 +256,7 @@ TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotAvailable) {
260 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 256 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
261 .WillByDefault(testing::Return(nullptr)); 257 .WillByDefault(testing::Return(nullptr));
262 offload_scan_manager_.reset(new OffloadScanManager( 258 offload_scan_manager_.reset(new OffloadScanManager(
263 mock_offload_service_utils_, 259 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
264 [](vector<NativeScanResult> scanResult) -> void {}));
265 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone; 260 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
266 bool result = offload_scan_manager_->startScan( 261 bool result = offload_scan_manager_->startScan(
267 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids, 262 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
@@ -281,8 +276,7 @@ TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotConnected) {
281 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 276 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
282 .WillByDefault(testing::Return(mock_offload_)); 277 .WillByDefault(testing::Return(mock_offload_));
283 offload_scan_manager_.reset(new OffloadScanManager( 278 offload_scan_manager_.reset(new OffloadScanManager(
284 mock_offload_service_utils_, 279 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
285 [](vector<NativeScanResult> scanResult) -> void {}));
286 OffloadStatus status = 280 OffloadStatus status =
287 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION); 281 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
288 offload_callback_->onError(status); 282 offload_callback_->onError(status);
@@ -305,9 +299,8 @@ TEST_F(OffloadScanManagerTest, StartScanTwiceTestWhenServiceIsOk) {
305 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 299 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
306 .WillByDefault(testing::Return(mock_offload_)); 300 .WillByDefault(testing::Return(mock_offload_));
307 offload_scan_manager_.reset(new OffloadScanManager( 301 offload_scan_manager_.reset(new OffloadScanManager(
308 mock_offload_service_utils_, 302 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
309 [](vector<NativeScanResult> scanResult) -> void {})); 303 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(2);
310 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(1);
311 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(2); 304 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(2);
312 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone; 305 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
313 bool result = offload_scan_manager_->startScan( 306 bool result = offload_scan_manager_->startScan(
@@ -331,8 +324,7 @@ TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsOk) {
331 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 324 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
332 .WillByDefault(testing::Return(mock_offload_)); 325 .WillByDefault(testing::Return(mock_offload_));
333 offload_scan_manager_.reset(new OffloadScanManager( 326 offload_scan_manager_.reset(new OffloadScanManager(
334 mock_offload_service_utils_, 327 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
335 [](vector<NativeScanResult> scanResult) -> void {}));
336 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)); 328 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
337 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)); 329 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
338 EXPECT_CALL(*mock_offload_, unsubscribeScanResults()); 330 EXPECT_CALL(*mock_offload_, unsubscribeScanResults());
@@ -347,26 +339,7 @@ TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsOk) {
347 339
348/** 340/**
349 * Testing OffloadScanManager for unsubscribing to the scan results from 341 * Testing OffloadScanManager for unsubscribing to the scan results from
350 * Offload HAL without first subscribing 342 * when service is not connected to the hardware
351 */
352TEST_F(OffloadScanManagerTest, StopScanTestWithoutStartWhenServiceIsOk) {
353 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
354 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
355 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
356 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
357 .WillByDefault(testing::Return(mock_offload_));
358 offload_scan_manager_.reset(new OffloadScanManager(
359 mock_offload_service_utils_,
360 [](vector<NativeScanResult> scanResult) -> void {}));
361 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
362 bool result = offload_scan_manager_->stopScan(&reason_code);
363 EXPECT_EQ(result, false);
364 EXPECT_EQ(reason_code, OffloadScanManager::kNotSubscribed);
365}
366
367/**
368 * Testing OffloadScanManager for unsubscribing to the scan results from
369 * Offload HAL without first subscribing when service is not working correctly
370 */ 343 */
371TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) { 344TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) {
372 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService()); 345 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
@@ -374,11 +347,9 @@ TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) {
374 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 347 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
375 .WillByDefault(testing::Return(mock_offload_)); 348 .WillByDefault(testing::Return(mock_offload_));
376 offload_scan_manager_.reset(new OffloadScanManager( 349 offload_scan_manager_.reset(new OffloadScanManager(
377 mock_offload_service_utils_, 350 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
378 [](vector<NativeScanResult> scanResult) -> void {}));
379 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)); 351 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
380 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)); 352 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
381 EXPECT_CALL(*mock_offload_, unsubscribeScanResults());
382 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone; 353 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
383 bool result = offload_scan_manager_->startScan( 354 bool result = offload_scan_manager_->startScan(
384 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids, 355 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
@@ -388,7 +359,7 @@ TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) {
388 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION); 359 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
389 offload_callback_->onError(status); 360 offload_callback_->onError(status);
390 result = offload_scan_manager_->stopScan(&reason_code); 361 result = offload_scan_manager_->stopScan(&reason_code);
391 EXPECT_EQ(result, true); 362 EXPECT_EQ(result, false);
392} 363}
393 364
394/** 365/**
@@ -402,8 +373,7 @@ TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsOk) {
402 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 373 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
403 .WillByDefault(testing::Return(mock_offload_)); 374 .WillByDefault(testing::Return(mock_offload_));
404 offload_scan_manager_.reset(new OffloadScanManager( 375 offload_scan_manager_.reset(new OffloadScanManager(
405 mock_offload_service_utils_, 376 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
406 [](vector<NativeScanResult> scanResult) -> void {}));
407 EXPECT_CALL(*mock_offload_, getScanStats(_)); 377 EXPECT_CALL(*mock_offload_, getScanStats(_));
408 NativeScanStats stats; 378 NativeScanStats stats;
409 bool result = offload_scan_manager_->getScanStats(&stats); 379 bool result = offload_scan_manager_->getScanStats(&stats);
@@ -421,8 +391,7 @@ TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsNotOk) {
421 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 391 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
422 .WillByDefault(testing::Return(mock_offload_)); 392 .WillByDefault(testing::Return(mock_offload_));
423 offload_scan_manager_.reset(new OffloadScanManager( 393 offload_scan_manager_.reset(new OffloadScanManager(
424 mock_offload_service_utils_, 394 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
425 [](vector<NativeScanResult> scanResult) -> void {}));
426 OffloadStatus status = 395 OffloadStatus status =
427 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION); 396 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
428 offload_callback_->onError(status); 397 offload_callback_->onError(status);
@@ -443,8 +412,7 @@ TEST_F(OffloadScanManagerTest, StartScanFailedTest) {
443 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 412 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
444 .WillByDefault(testing::Return(mock_offload_)); 413 .WillByDefault(testing::Return(mock_offload_));
445 offload_scan_manager_.reset(new OffloadScanManager( 414 offload_scan_manager_.reset(new OffloadScanManager(
446 mock_offload_service_utils_, 415 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
447 [](vector<NativeScanResult> scanResult) -> void {}));
448 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(0); 416 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(0);
449 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(1); 417 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(1);
450 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR); 418 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
@@ -467,8 +435,7 @@ TEST_F(OffloadScanManagerTest, getScanStatsFailedTest) {
467 ON_CALL(*mock_offload_service_utils_, GetOffloadService()) 435 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
468 .WillByDefault(testing::Return(mock_offload_)); 436 .WillByDefault(testing::Return(mock_offload_));
469 offload_scan_manager_.reset(new OffloadScanManager( 437 offload_scan_manager_.reset(new OffloadScanManager(
470 mock_offload_service_utils_, 438 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
471 [](vector<NativeScanResult> scanResult) -> void {}));
472 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::TIMEOUT); 439 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::TIMEOUT);
473 EXPECT_CALL(*mock_offload_, getScanStats(_)); 440 EXPECT_CALL(*mock_offload_, getScanStats(_));
474 NativeScanStats stats; 441 NativeScanStats stats;