wificond: Remove offload HAL client code am: 0073709945
Change-Id: I59b64aad4cc75262019fb778115b30d1ef331bdc
diff --git a/Android.bp b/Android.bp
index bf03619..ce4869e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -37,12 +37,10 @@
include_dirs: ["system/security/keystore/include"],
shared_libs: [
- "android.hardware.wifi.offload@1.0",
"libbinder",
"libbase",
"libcutils",
"libhidlbase",
- "libhidltransport",
"libkeystore_aidl",
"libkeystore_binder",
"libkeystore_parcelables",
@@ -71,28 +69,19 @@
"logging_utils.cpp",
"scanning/channel_settings.cpp",
"scanning/hidden_network.cpp",
- "scanning/offload_scan_callback_interface_impl.cpp",
"scanning/pno_network.cpp",
"scanning/pno_settings.cpp",
"scanning/radio_chain_info.cpp",
"scanning/scan_result.cpp",
- "scanning/offload/scan_stats.cpp",
"scanning/single_scan_settings.cpp",
"scanning/scan_utils.cpp",
"scanning/scanner_impl.cpp",
- "scanning/offload/offload_scan_manager.cpp",
- "scanning/offload/offload_callback.cpp",
- "scanning/offload/offload_service_utils.cpp",
- "scanning/offload/offload_scan_utils.cpp",
"server.cpp",
],
shared_libs: [
- "android.hardware.wifi.offload@1.0",
"libbase",
"libutils",
- "libhidlbase",
- "libhidltransport",
"libwifi-system-iface",
],
whole_static_libs: [
@@ -217,26 +206,14 @@
"tests/mock_client_interface_impl.cpp",
"tests/mock_netlink_manager.cpp",
"tests/mock_netlink_utils.cpp",
- "tests/mock_offload.cpp",
- "tests/mock_offload_callback_handlers.cpp",
- "tests/mock_offload_scan_callback_interface.cpp",
- "tests/mock_offload_scan_callback_interface_impl.cpp",
- "tests/mock_offload_scan_manager.cpp",
- "tests/mock_offload_service_utils.cpp",
"tests/mock_scan_utils.cpp",
"tests/netlink_manager_unittest.cpp",
"tests/netlink_utils_unittest.cpp",
"tests/nl80211_attribute_unittest.cpp",
"tests/nl80211_packet_unittest.cpp",
- "tests/offload_callback_test.cpp",
- "tests/offload_hal_test_constants.cpp",
- "tests/offload_scan_manager_test.cpp",
- "tests/offload_scan_utils_test.cpp",
- "tests/offload_test_utils.cpp",
"tests/scanner_unittest.cpp",
"tests/scan_result_unittest.cpp",
"tests/scan_settings_unittest.cpp",
- "tests/scan_stats_unittest.cpp",
"tests/scan_utils_unittest.cpp",
"tests/server_unittest.cpp",
],
@@ -249,12 +226,9 @@
"libwificond_nl",
],
shared_libs: [
- "android.hardware.wifi.offload@1.0",
"libbase",
"libbinder",
"libcutils",
- "libhidltransport",
- "libhidlbase",
"liblog",
"libutils",
"libwifi-system-iface",
diff --git a/aidl/android/net/wifi/IPnoScanEvent.aidl b/aidl/android/net/wifi/IPnoScanEvent.aidl
index 50c1918..6488c19 100644
--- a/aidl/android/net/wifi/IPnoScanEvent.aidl
+++ b/aidl/android/net/wifi/IPnoScanEvent.aidl
@@ -18,15 +18,6 @@
// A callback for receiving pno scanning events.
interface IPnoScanEvent {
- const int PNO_SCAN_OVER_OFFLOAD_BINDER_FAILURE = 0;
- const int PNO_SCAN_OVER_OFFLOAD_REMOTE_FAILURE = 1;
-
oneway void OnPnoNetworkFound();
oneway void OnPnoScanFailed();
- // Callback notifying the framework that PNO scan is started over Offload HAL
- // interface, this is meant for metrics collection only
- oneway void OnPnoScanOverOffloadStarted();
- // Callback notifying the framework that a PNO scan running over Offload HAL
- // has failed, this is meant for metrics collection only
- oneway void OnPnoScanOverOffloadFailed(int reason);
}
diff --git a/client_interface_impl.cpp b/client_interface_impl.cpp
index 60bae8e..3e1cbca 100644
--- a/client_interface_impl.cpp
+++ b/client_interface_impl.cpp
@@ -25,7 +25,6 @@
#include "wificond/logging_utils.h"
#include "wificond/net/mlme_event.h"
#include "wificond/net/netlink_utils.h"
-#include "wificond/scanning/offload/offload_service_utils.h"
#include "wificond/scanning/scan_result.h"
#include "wificond/scanning/scan_utils.h"
#include "wificond/scanning/scanner_impl.h"
@@ -111,7 +110,6 @@
if_tool_(if_tool),
netlink_utils_(netlink_utils),
scan_utils_(scan_utils),
- offload_service_utils_(new OffloadServiceUtils()),
mlme_event_handler_(new MlmeEventHandlerImpl(this)),
binder_(new ClientInterfaceBinder(this)),
is_associated_(false),
@@ -145,8 +143,7 @@
scan_capabilities_,
wiphy_features_,
this,
- scan_utils_,
- offload_service_utils_);
+ scan_utils_);
// Need to set the interface up (especially in scan mode since wpa_supplicant
// is not started)
if_tool_->SetUpState(interface_name_.c_str(), true);
diff --git a/client_interface_impl.h b/client_interface_impl.h
index e07b18b..5a27484 100644
--- a/client_interface_impl.h
+++ b/client_interface_impl.h
@@ -30,7 +30,6 @@
#include "android/net/wifi/ISendMgmtFrameEvent.h"
#include "wificond/net/mlme_event_handler.h"
#include "wificond/net/netlink_utils.h"
-#include "wificond/scanning/offload/offload_service_utils.h"
#include "wificond/scanning/scanner_impl.h"
namespace android {
@@ -98,7 +97,6 @@
android::wifi_system::InterfaceTool* const if_tool_;
NetlinkUtils* const netlink_utils_;
ScanUtils* const scan_utils_;
- const std::shared_ptr<OffloadServiceUtils> offload_service_utils_;
const std::unique_ptr<MlmeEventHandlerImpl> mlme_event_handler_;
const android::sp<ClientInterfaceBinder> binder_;
android::sp<ScannerImpl> scanner_;
diff --git a/main.cpp b/main.cpp
index bd87c20..b6054b1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,7 +26,6 @@
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <cutils/properties.h>
-#include <hidl/HidlTransportSupport.h>
#include <libminijail.h>
#include <utils/String16.h>
#include <wifi_system/interface_tool.h>
@@ -90,14 +89,6 @@
return binder_fd;
}
-// Setup our interface to the hw Binder driver or die trying.
-int SetupHwBinderOrCrash() {
- android::hardware::configureRpcThreadpool(1, true /* callerWillJoin */);
- int binder_fd = android::hardware::setupTransportPolling();
- CHECK_GE(binder_fd, 0) << "Invalid hw binder FD: " << binder_fd;
- return binder_fd;
-}
-
void RegisterServiceOrCrash(const android::sp<android::IBinder>& service) {
android::sp<android::IServiceManager> sm = android::defaultServiceManager();
CHECK_EQ(sm != NULL, true) << "Could not obtain IServiceManager";
@@ -112,10 +103,6 @@
android::IPCThreadState::self()->handlePolledCommands();
}
-void OnHwBinderReadReady(int fd) {
- android::hardware::handleTransportPoll(fd);
-}
-
int main(int argc, char** argv) {
android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM));
LOG(INFO) << "wificond is starting up...";
@@ -130,11 +117,6 @@
android::wificond::EventLoop::kModeInput,
&OnBinderReadReady)) << "Failed to watch binder FD";
- int hw_binder_fd = SetupHwBinderOrCrash();
- CHECK(event_dispatcher->WatchFileDescriptor(
- hw_binder_fd, android::wificond::EventLoop::kModeInput,
- &OnHwBinderReadReady)) << "Failed to watch Hw Binder FD";
-
android::wificond::NetlinkManager netlink_manager(event_dispatcher.get());
if (!netlink_manager.Start()) {
LOG(ERROR) << "Failed to start netlink manager";
diff --git a/scanning/offload/hidl_call_util.h b/scanning/offload/hidl_call_util.h
deleted file mode 100644
index 6303f1a..0000000
--- a/scanning/offload/hidl_call_util.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file is modified from
-// hardware/interfaces/wifi/1.0/vts/functional/wifi_hidl_call_util.h
-
-#pragma once
-
-#include <android-base/logging.h>
-#include <functional>
-#include <tuple>
-#include <type_traits>
-#include <utility>
-
-namespace {
-namespace detail {
-template <typename>
-struct functionArgSaver;
-
-// Provides a std::function that takes one argument, and a buffer
-// wherein the function will store its argument. The buffer has
-// the same type as the argument, but with const and reference
-// modifiers removed.
-template <typename ArgT>
-struct functionArgSaver<std::function<void(ArgT)>> final {
- using StorageT = typename std::remove_const<
- typename std::remove_reference<ArgT>::type>::type;
-
- std::function<void(ArgT)> saveArgs = [this](ArgT arg) {
- this->saved_values = arg;
- };
-
- StorageT saved_values;
-};
-
-// Provides a std::function that takes two arguments, and a buffer
-// wherein the function will store its arguments. The buffer is a
-// std::pair, whose elements have the same types as the arguments
-// (but with const and reference modifiers removed).
-template <typename Arg1T, typename Arg2T>
-struct functionArgSaver<std::function<void(Arg1T, Arg2T)>> final {
- using StorageT =
- std::pair<typename std::remove_const<
- typename std::remove_reference<Arg1T>::type>::type,
- typename std::remove_const<
- typename std::remove_reference<Arg2T>::type>::type>;
-
- std::function<void(Arg1T, Arg2T)> saveArgs = [this](Arg1T arg1, Arg2T arg2) {
- this->saved_values = {arg1, arg2};
- };
-
- StorageT saved_values;
-};
-
-// Provides a std::function that takes three or more arguments, and a
-// buffer wherein the function will store its arguments. The buffer is a
-// std::tuple whose elements have the same types as the arguments (but
-// with const and reference modifiers removed).
-template <typename... ArgT>
-struct functionArgSaver<std::function<void(ArgT...)>> final {
- using StorageT = std::tuple<typename std::remove_const<
- typename std::remove_reference<ArgT>::type>::type...>;
-
- std::function<void(ArgT...)> saveArgs = [this](ArgT... arg) {
- this->saved_values = {arg...};
- };
-
- StorageT saved_values;
-};
-
-// Invokes |method| on |object|, providing |method| a CallbackT as the
-// final argument. Returns a copy of the parameters that |method| provided
-// to CallbackT. (The parameters are returned by value.)
-template <typename CallbackT, typename MethodT, typename ObjectT,
- typename... ArgT>
-std::pair<typename functionArgSaver<CallbackT>::StorageT, bool> invokeMethod(
- MethodT method, ObjectT object, ArgT&&... methodArg) {
- functionArgSaver<CallbackT> result_buffer;
- const auto& res = ((*object).*method)(std::forward<ArgT>(methodArg)...,
- result_buffer.saveArgs);
- bool transportStatus = true;
- if (!res.isOk()) {
- LOG(ERROR) << " Transport failed " << res.description();
- transportStatus = false;
- }
- return std::make_pair(result_buffer.saved_values, transportStatus);
-}
-} // namespace detail
-} // namespace
-
-// Invokes |method| on |strong_pointer|, passing provided arguments through to
-// |method|.
-//
-// Returns either:
-// - A copy of the result callback parameter (for callbacks with a single
-// parameter), OR
-// - A pair containing a copy of the result callback parameters (for callbacks
-// with two parameters), OR
-// - A tuple containing a copy of the result callback paramters (for callbacks
-// with three or more parameters).
-//
-// Example usage:
-// EXPECT_EQ(WifiStatusCode::SUCCESS,
-// HIDL_INVOKE(strong_pointer, methodReturningWifiStatus).code);
-// EXPECT_EQ(WifiStatusCode::SUCCESS,
-// HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndOneMore)
-// .first.code);
-// EXPECT_EQ(WifiStatusCode::SUCCESS, std::get<0>(
-// HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndTwoMore))
-// .code);
-#define HIDL_INVOKE(strong_pointer, method, ...) \
- (detail::invokeMethod< \
- std::remove_reference<decltype(*strong_pointer)>::type::method##_cb>( \
- &std::remove_reference<decltype(*strong_pointer)>::type::method, \
- strong_pointer, ##__VA_ARGS__))
diff --git a/scanning/offload/offload_callback.cpp b/scanning/offload/offload_callback.cpp
deleted file mode 100644
index b92a1ed..0000000
--- a/scanning/offload/offload_callback.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <memory>
-#include <vector>
-
-#include <android-base/logging.h>
-
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/offload/offload_scan_manager.h"
-#include "wificond/scanning/scan_result.h"
-
-using ::android::hardware::wifi::offload::V1_0::ScanResult;
-using ::android::hardware::wifi::offload::V1_0::OffloadStatus;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-namespace android {
-namespace wificond {
-
-OffloadCallback::OffloadCallback(OffloadCallbackHandlers* handlers)
- : handlers_(handlers) {}
-
-// Methods from ::android::hardware::wifi::offload::V1_0::IOffloadCallback
-// follow.
-Return<void> OffloadCallback::onScanResult(
- const hidl_vec<ScanResult>& scan_result) {
- if (handlers_ != nullptr) {
- handlers_->OnScanResultHandler(std::vector<ScanResult>(scan_result));
- } else {
- LOG(WARNING) << "No handler available for Offload scan results";
- }
- return Void();
-}
-
-Return<void> OffloadCallback::onError(const OffloadStatus& status) {
- if (handlers_ != nullptr) {
- handlers_->OnErrorHandler(status);
- } else {
- LOG(WARNING) << "No error handler for Offload";
- }
- return Void();
-}
-
-OffloadCallback::~OffloadCallback() {}
-
-} // namespace wificond
-} // namespace android
diff --git a/scanning/offload/offload_callback.h b/scanning/offload/offload_callback.h
deleted file mode 100644
index ae0b2f4..0000000
--- a/scanning/offload/offload_callback.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_H
-#define ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_H
-
-#include <android/hardware/wifi/offload/1.0/IOffloadCallback.h>
-#include <hidl/Status.h>
-#include <vector>
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-
-namespace android {
-namespace wificond {
-
-class OffloadCallback
- : public ::android::hardware::wifi::offload::V1_0::IOffloadCallback {
- public:
- explicit OffloadCallback(OffloadCallbackHandlers* handlers);
- virtual ~OffloadCallback();
-
- // Methods from ::android::hardware::wifi::offload::V1_0::IOffloadCallback
- // follow.
- ::android::hardware::Return<void> onScanResult(
- const ::android::hardware::hidl_vec<
- ::android::hardware::wifi::offload::V1_0::ScanResult>& scanResult)
- override;
- ::android::hardware::Return<void> onError(
- const ::android::hardware::wifi::offload::V1_0::OffloadStatus& status)
- override;
- // Methods from ::android::hidl::base::V1_0::IBase follow.
-
- private:
- OffloadCallbackHandlers* handlers_;
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_H
diff --git a/scanning/offload/offload_callback_handlers.h b/scanning/offload/offload_callback_handlers.h
deleted file mode 100644
index a202cda..0000000
--- a/scanning/offload/offload_callback_handlers.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_HANDLERS_H
-#define ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_HANDLERS_H
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include <vector>
-
-namespace android {
-namespace wificond {
-
-class OffloadCallbackHandlers {
- public:
- virtual ~OffloadCallbackHandlers() {}
-
- virtual void OnScanResultHandler(
- const std::vector<::android::hardware::wifi::offload::V1_0::ScanResult>&
- scanResult) = 0;
- virtual void OnErrorHandler(
- const ::android::hardware::wifi::offload::V1_0::OffloadStatus&
- status) = 0;
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_HANDLERS_H
diff --git a/scanning/offload/offload_scan_manager.cpp b/scanning/offload/offload_scan_manager.cpp
deleted file mode 100644
index f4c4076..0000000
--- a/scanning/offload/offload_scan_manager.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "wificond/scanning/offload/offload_scan_manager.h"
-
-#include <vector>
-
-#include <android-base/logging.h>
-
-#include "wificond/scanning/offload/hidl_call_util.h"
-#include "wificond/scanning/offload/offload_scan_utils.h"
-#include "wificond/scanning/offload/offload_service_utils.h"
-#include "wificond/scanning/offload/scan_stats.h"
-#include "wificond/scanning/scan_result.h"
-
-using android::hardware::wifi::offload::V1_0::IOffload;
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::ScanFilter;
-using android::hardware::wifi::offload::V1_0::ScanParam;
-using android::hardware::wifi::offload::V1_0::ScanStats;
-using android::hardware::wifi::offload::V1_0::OffloadStatus;
-using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
-
-using ::com::android::server::wifi::wificond::NativeScanResult;
-using ::com::android::server::wifi::wificond::NativeScanStats;
-using std::vector;
-using std::weak_ptr;
-using std::shared_ptr;
-
-using namespace std::placeholders;
-
-namespace {
-const uint32_t kSubscriptionDelayMs = 5000;
-}
-
-namespace android {
-namespace wificond {
-
-OffloadCallbackHandlersImpl::OffloadCallbackHandlersImpl(
- OffloadScanManager* offload_scan_manager)
- : offload_scan_manager_(offload_scan_manager) {}
-
-OffloadCallbackHandlersImpl::~OffloadCallbackHandlersImpl() {}
-
-void OffloadCallbackHandlersImpl::OnScanResultHandler(
- const vector<ScanResult>& scanResult) {
- if (offload_scan_manager_ != nullptr) {
- offload_scan_manager_->ReportScanResults(scanResult);
- }
-}
-
-void OffloadCallbackHandlersImpl::OnErrorHandler(const OffloadStatus& status) {
- if (offload_scan_manager_ != nullptr) {
- offload_scan_manager_->ReportError(status);
- }
-}
-
-OffloadScanManager::OffloadScanManager(
- weak_ptr<OffloadServiceUtils> utils,
- shared_ptr<OffloadScanCallbackInterface> callback)
- : wifi_offload_hal_(nullptr),
- wifi_offload_callback_(nullptr),
- death_recipient_(nullptr),
- offload_status_(OffloadScanManager::kError),
- service_available_(false),
- offload_service_utils_(utils),
- offload_callback_handlers_(new OffloadCallbackHandlersImpl(this)),
- event_callback_(callback) {
- if (InitService()) {
- offload_status_ = OffloadScanManager::kNoError;
- }
-}
-
-bool OffloadScanManager::InitService() {
- wifi_offload_hal_ = offload_service_utils_.lock()->GetOffloadService();
- if (wifi_offload_hal_ == nullptr) {
- LOG(ERROR) << "No Offload Service available";
- return false;
- }
-
- death_recipient_ = offload_service_utils_.lock()->GetOffloadDeathRecipient(
- std::bind(&OffloadScanManager::OnObjectDeath, this, _1));
- uint64_t cookie = reinterpret_cast<uint64_t>(wifi_offload_hal_.get());
-
- auto link_to_death_status =
- wifi_offload_hal_->linkToDeath(death_recipient_, cookie);
- if (!link_to_death_status.isOk()) {
- LOG(ERROR) << "Unable to register death handler "
- << link_to_death_status.description();
- return false;
- }
-
- wifi_offload_callback_ = offload_service_utils_.lock()->GetOffloadCallback(
- offload_callback_handlers_.get());
- if (wifi_offload_callback_ == nullptr) {
- LOG(ERROR) << "Invalid Offload callback object";
- return false;
- }
-
- auto set_callback_status =
- wifi_offload_hal_->setEventCallback(wifi_offload_callback_);
- if (!set_callback_status.isOk()) {
- LOG(ERROR) << "Unable to set event callback for Offload HAL";
- return false;
- }
-
- service_available_ = true;
- return true;
-}
-
-bool OffloadScanManager::InitServiceIfNeeded() {
- if (!service_available_) {
- return InitService();
- }
- return true;
-}
-
-bool OffloadScanManager::stopScan(OffloadScanManager::ReasonCode* reason_code) {
- if (!InitServiceIfNeeded() ||
- (getOffloadStatus() != OffloadScanManager::kNoError)) {
- *reason_code = OffloadScanManager::kNotAvailable;
- return false;
- }
- const auto& res = wifi_offload_hal_->unsubscribeScanResults();
- if (!res.isOk()) {
- *reason_code = OffloadScanManager::kTransactionFailed;
- LOG(WARNING) << "unsubscribeScanResults() failed " << res.description();
- return false;
- }
- *reason_code = OffloadScanManager::kNone;
- return true;
-}
-
-bool OffloadScanManager::GetScanStats(NativeScanStats* native_scan_stats) {
- const auto& result = HIDL_INVOKE(wifi_offload_hal_, getScanStats);
- const auto& offload_status_and_scan_stats = result.first;
- bool transport_status = result.second;
- if (!transport_status) {
- return false;
- }
- OffloadStatus offload_status = offload_status_and_scan_stats.first;
- ScanStats scan_stats = offload_status_and_scan_stats.second;
- if (offload_status.code != OffloadStatusCode::OK) {
- LOG(WARNING) << offload_status.description;
- return false;
- }
- *native_scan_stats = OffloadScanUtils::convertToNativeScanStats(scan_stats);
- return true;
-}
-
-bool OffloadScanManager::VerifyAndConvertHIDLStatus(
- std::pair<OffloadStatus, bool> result,
- OffloadScanManager::ReasonCode* reason_code) {
- const auto& offload_status = result.first;
- bool transport_status = result.second;
- if (!transport_status) {
- *reason_code = OffloadScanManager::kTransactionFailed;
- return false;
- }
- if (offload_status.code != OffloadStatusCode::OK) {
- LOG(WARNING) << offload_status.description;
- *reason_code = OffloadScanManager::kOperationFailed;
- return false;
- }
- return true;
-}
-
-bool OffloadScanManager::startScan(
- uint32_t interval_ms, int32_t rssi_threshold,
- const vector<vector<uint8_t>>& scan_ssids,
- const vector<vector<uint8_t>>& match_ssids,
- const vector<uint8_t>& match_security, const vector<uint32_t>& freqs,
- OffloadScanManager::ReasonCode* reason_code) {
- if (!InitServiceIfNeeded() ||
- getOffloadStatus() != OffloadScanManager::kNoError) {
- *reason_code = OffloadScanManager::kNotAvailable;
- LOG(WARNING) << "Offload HAL scans are not available";
- return false;
- }
- ScanParam param =
- OffloadScanUtils::createScanParam(scan_ssids, freqs, interval_ms);
- ScanFilter filter = OffloadScanUtils::createScanFilter(
- match_ssids, match_security, rssi_threshold);
-
- if (!ConfigureScans(param, filter, reason_code)) {
- return false;
- }
-
- if (!SubscribeScanResults(reason_code)) {
- return false;
- }
-
- *reason_code = OffloadScanManager::kNone;
- return true;
-}
-
-bool OffloadScanManager::ConfigureScans(
- ScanParam param, ScanFilter filter,
- OffloadScanManager::ReasonCode* reason_code) {
- const auto& result =
- HIDL_INVOKE(wifi_offload_hal_, configureScans, param, filter);
- if (!VerifyAndConvertHIDLStatus(result, reason_code)) {
- return false;
- }
- return true;
-}
-
-bool OffloadScanManager::SubscribeScanResults(
- OffloadScanManager::ReasonCode* reason_code) {
- const auto& result = HIDL_INVOKE(wifi_offload_hal_, subscribeScanResults,
- kSubscriptionDelayMs);
- if (!VerifyAndConvertHIDLStatus(result, reason_code)) {
- return false;
- }
- return true;
-}
-
-OffloadScanManager::StatusCode OffloadScanManager::getOffloadStatus() const {
- if (!service_available_) {
- return OffloadScanManager::kNoService;
- }
- return offload_status_;
-}
-
-bool OffloadScanManager::getScanResults(
- std::vector<NativeScanResult>* out_scan_results) {
- for (const auto& scan_result : cached_scan_results_) {
- out_scan_results->push_back(scan_result);
- }
- return true;
-}
-
-bool OffloadScanManager::getScanStats(NativeScanStats* native_scan_stats) {
- if (!InitServiceIfNeeded()) {
- LOG(ERROR) << "Offload HAL service unavailable";
- return false;
- }
- if (getOffloadStatus() != OffloadScanManager::kNoError) {
- LOG(WARNING) << "Unable to get scan stats due to Wifi Offload HAL error";
- return false;
- }
- return GetScanStats(native_scan_stats);
-}
-
-OffloadScanManager::~OffloadScanManager() {
- if (wifi_offload_hal_ != nullptr) {
- wifi_offload_hal_->unlinkToDeath(death_recipient_);
- }
-}
-
-void OffloadScanManager::ReportScanResults(
- const vector<ScanResult>& scanResult) {
- cached_scan_results_.clear();
- if (!OffloadScanUtils::convertToNativeScanResults(scanResult,
- &cached_scan_results_)) {
- LOG(WARNING) << "Unable to convert scan results to native format";
- return;
- }
- if (event_callback_ != nullptr) {
- event_callback_->OnOffloadScanResult();
- } else {
- LOG(WARNING)
- << "No callback to report Offload HAL's scan results to wificond";
- }
-}
-
-void OffloadScanManager::ReportError(const OffloadStatus& status) {
- OffloadStatusCode status_code = status.code;
- OffloadScanManager::StatusCode status_result = OffloadScanManager::kNoError;
- switch (status_code) {
- case OffloadStatusCode::OK:
- status_result = OffloadScanManager::kNoError;
- break;
- case OffloadStatusCode::TIMEOUT:
- status_result = OffloadScanManager::kTimeOut;
- break;
- case OffloadStatusCode::NO_CONNECTION:
- status_result = OffloadScanManager::kNotConnected;
- break;
- case OffloadStatusCode::ERROR:
- status_result = OffloadScanManager::kError;
- break;
- default:
- LOG(WARNING) << "Invalid Offload Error reported";
- return;
- }
- if (status_result != OffloadScanManager::kNoError) {
- LOG(WARNING) << "Offload Error reported " << status.description;
- if (event_callback_ != nullptr) {
- event_callback_->OnOffloadError(
- OffloadScanCallbackInterface::REMOTE_FAILURE);
- } else {
- LOG(WARNING) << "No callback to report Offload HAL Errors to wificond";
- }
- }
- offload_status_ = status_result;
-}
-
-void OffloadScanManager::OnObjectDeath(uint64_t cookie) {
- if (wifi_offload_hal_ == reinterpret_cast<IOffload*>(cookie)) {
- LOG(ERROR) << "Death Notification for Wifi Offload HAL";
- wifi_offload_hal_.clear();
- if (event_callback_ != nullptr) {
- event_callback_->OnOffloadError(
- OffloadScanCallbackInterface::BINDER_DEATH);
- } else {
- LOG(WARNING)
- << "No callback to report Offload HAL Binder death to wificond";
- }
- service_available_ = false;
- death_recipient_.clear();
- }
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/scanning/offload/offload_scan_manager.h b/scanning/offload/offload_scan_manager.h
deleted file mode 100644
index 2c4fa96..0000000
--- a/scanning/offload/offload_scan_manager.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WIFICOND_OFFLOAD_SCAN_MANAGER_H_
-#define WIFICOND_OFFLOAD_SCAN_MANAGER_H_
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-#include "wificond/scanning/offload_scan_callback_interface_impl.h"
-
-#include <vector>
-
-namespace com {
-namespace android {
-namespace server {
-namespace wifi {
-namespace wificond {
-
-class NativeScanResult;
-class NativeScanStats;
-
-} // namespace wificond
-} // namespace wifi
-} // namespace server
-} // namespace android
-} // namespace com
-
-namespace android {
-namespace wificond {
-
-class OffloadScanManager;
-class OffloadDeathRecipient;
-class OffloadServiceUtils;
-
-// Provides callback interface implementation from Offload HAL
-class OffloadCallbackHandlersImpl : public OffloadCallbackHandlers {
- public:
- OffloadCallbackHandlersImpl(OffloadScanManager* parent);
- ~OffloadCallbackHandlersImpl() override;
-
- void OnScanResultHandler(
- const std::vector<android::hardware::wifi::offload::V1_0::ScanResult>&
- scanResult) override;
- void OnErrorHandler(
- const android::hardware::wifi::offload::V1_0::OffloadStatus& status)
- override;
-
- private:
- OffloadScanManager* offload_scan_manager_;
-};
-
-// Provides methods to interact with Offload HAL
-class OffloadScanManager {
- public:
- enum StatusCode {
- /* Corresponds to OffloadStatusCode::OK */
- kNoError,
- /* Offload HAL service not avaialble */
- kNoService,
- /* Corresponds to OffloadStatusCode::NO_CONNECTION */
- kNotConnected,
- /* Corresponds to OffloadStatusCode::TIMEOUT */
- kTimeOut,
- /* Corresponds to OffloadStatusCode::ERROR */
- kError
- };
-
- enum ReasonCode {
- /* Default value */
- kNone,
- /* Offload HAL scans is not available */
- kNotAvailable,
- /* Offload HAL requested operation failure */
- kOperationFailed,
- /* Binder failed to deliver message to Offload HAL*/
- kTransactionFailed,
- };
-
- explicit OffloadScanManager(
- std::weak_ptr<OffloadServiceUtils> utils,
- std::shared_ptr<OffloadScanCallbackInterface> callback);
- virtual ~OffloadScanManager();
- /* Request start of offload scans with scan parameters and scan filter
- * settings. Internally calls Offload HAL service with configureScans()
- * and subscribeScanResults() APIs. Reason code indicates failure reason.
- */
- virtual bool startScan(
- uint32_t /* interval_ms */, int32_t /* rssi_threshold */,
- const std::vector<std::vector<uint8_t>>& /* scan_ssids */,
- const std::vector<std::vector<uint8_t>>& /* match_ssids */,
- const std::vector<uint8_t>& /* match_security */,
- const std::vector<uint32_t>& /* freqs */,
- ReasonCode* /* failure reason */);
- /* Request stop of offload scans, returns true if the operation succeeds
- * Otherwise, returns false. Reason code is updated in case of failure.
- */
- virtual bool stopScan(ReasonCode* /* failure reason */);
- /* Get statistics for scans performed by Offload HAL */
- virtual bool getScanStats(
- ::com::android::server::wifi::wificond::NativeScanStats* /* scanStats */);
- /* Otain status of the Offload HAL service */
- virtual StatusCode getOffloadStatus() const;
- /* Returns the most recent scan result available from Offload HAL */
- virtual bool getScanResults(
- std::vector<::com::android::server::wifi::wificond::NativeScanResult>*
- out_scan_results);
-
- private:
- void ReportScanResults(
- const std::vector<android::hardware::wifi::offload::V1_0::ScanResult>&
- scanResult);
- void ReportError(
- const android::hardware::wifi::offload::V1_0::OffloadStatus& status);
- bool VerifyAndConvertHIDLStatus(
- std::pair<android::hardware::wifi::offload::V1_0::OffloadStatus, bool>
- result,
- OffloadScanManager::ReasonCode* reason_code);
- bool GetScanStats(
- ::com::android::server::wifi::wificond::NativeScanStats* stats);
- bool SubscribeScanResults(
- OffloadScanManager::ReasonCode* reason_code);
- bool ConfigureScans(
- android::hardware::wifi::offload::V1_0::ScanParam,
- android::hardware::wifi::offload::V1_0::ScanFilter,
- OffloadScanManager::ReasonCode* reason_code);
- bool InitServiceIfNeeded();
- bool InitService();
-
- /* Handle binder death */
- void OnObjectDeath(uint64_t /* cookie */);
-
- android::sp<android::hardware::wifi::offload::V1_0::IOffload>
- wifi_offload_hal_;
- android::sp<OffloadCallback> wifi_offload_callback_;
- android::sp<OffloadDeathRecipient> death_recipient_;
- StatusCode offload_status_;
- std::vector<::com::android::server::wifi::wificond::NativeScanResult>
- cached_scan_results_;
- bool service_available_;
-
- const std::weak_ptr<OffloadServiceUtils> offload_service_utils_;
- const std::shared_ptr<OffloadCallbackHandlersImpl> offload_callback_handlers_;
- std::shared_ptr<OffloadScanCallbackInterface> event_callback_;
-
- friend class OffloadCallbackHandlersImpl;
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_OFFLOAD_SCAN_MANAGER_H_
diff --git a/scanning/offload/offload_scan_utils.cpp b/scanning/offload/offload_scan_utils.cpp
deleted file mode 100644
index d476507..0000000
--- a/scanning/offload/offload_scan_utils.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "wificond/scanning/offload/offload_scan_utils.h"
-
-#include <android-base/logging.h>
-#include <utils/Timers.h>
-
-#include "wificond/scanning/offload/scan_stats.h"
-#include "wificond/scanning/scan_result.h"
-
-using ::com::android::server::wifi::wificond::NativeScanResult;
-using ::com::android::server::wifi::wificond::NativeScanStats;
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::ScanParam;
-using android::hardware::wifi::offload::V1_0::ScanFilter;
-using android::hardware::wifi::offload::V1_0::ScanStats;
-using android::hardware::wifi::offload::V1_0::NetworkInfo;
-using android::hardware::hidl_vec;
-using std::vector;
-
-namespace android {
-namespace wificond {
-
-bool OffloadScanUtils::convertToNativeScanResults(
- const vector<ScanResult>& scan_result,
- vector<NativeScanResult>* native_scan_result) {
- if (native_scan_result == nullptr) return false;
- for (size_t i = 0; i < scan_result.size(); i++) {
- NativeScanResult single_scan_result;
- single_scan_result.ssid.assign(scan_result[i].networkInfo.ssid.begin(),
- scan_result[i].networkInfo.ssid.end());
- for (size_t j = 0; j < scan_result[i].bssid.elementCount(); j++) {
- single_scan_result.bssid.at(j) = scan_result[i].bssid[j];
- }
- single_scan_result.frequency = scan_result[i].frequency;
- single_scan_result.signal_mbm = scan_result[i].rssi;
- single_scan_result.tsf = systemTime(SYSTEM_TIME_MONOTONIC) / 1000;
- single_scan_result.capability = scan_result[i].capability;
- single_scan_result.associated = false;
- native_scan_result->push_back(std::move(single_scan_result));
- }
- return true;
-}
-
-ScanParam OffloadScanUtils::createScanParam(
- const vector<vector<uint8_t>>& ssid_list,
- const vector<uint32_t>& frequency_list, uint32_t scan_interval_ms) {
- ScanParam scan_param;
- scan_param.disconnectedModeScanIntervalMs = scan_interval_ms;
- scan_param.frequencyList = frequency_list;
- vector<hidl_vec<uint8_t>> ssid_list_tmp;
- for (const auto& ssid : ssid_list) {
- ssid_list_tmp.push_back(ssid);
- }
- scan_param.ssidList = ssid_list_tmp;
- return scan_param;
-}
-
-ScanFilter OffloadScanUtils::createScanFilter(
- const vector<vector<uint8_t>>& ssids, const vector<uint8_t>& flags,
- int8_t rssi_threshold) {
- ScanFilter scan_filter;
- vector<NetworkInfo> nw_info_list;
- size_t i = 0;
- scan_filter.rssiThreshold = rssi_threshold;
- // Note that the number of ssids should match the number of security flags
- for (const auto& ssid : ssids) {
- NetworkInfo nw_info;
- nw_info.ssid = ssid;
- if (i < flags.size()) {
- nw_info.flags = flags[i++];
- } else {
- continue;
- }
- nw_info_list.push_back(nw_info);
- }
- scan_filter.preferredNetworkInfoList = nw_info_list;
- return scan_filter;
-}
-
-NativeScanStats OffloadScanUtils::convertToNativeScanStats(
- const ScanStats& scanStats) {
- uint32_t num_channels_scanned = 0;
- uint32_t scan_duration_ms = 0;
- vector<uint8_t> histogram_channels;
-
- for (size_t i = 0; i < scanStats.scanRecord.size(); i++) {
- scan_duration_ms += scanStats.scanRecord[i].durationMs;
- num_channels_scanned += scanStats.scanRecord[i].numChannelsScanned;
- }
- for (size_t i = 0; i < scanStats.histogramChannelsScanned.size(); i++) {
- histogram_channels.push_back(scanStats.histogramChannelsScanned[i]);
- }
-
- NativeScanStats native_scan_stats(
- scanStats.numScansRequestedByWifi, scanStats.numScansServicedByWifi,
- scanStats.subscriptionDurationMs, scan_duration_ms, num_channels_scanned,
- histogram_channels);
- return native_scan_stats;
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/scanning/offload/offload_scan_utils.h b/scanning/offload/offload_scan_utils.h
deleted file mode 100644
index 22ba8ea..0000000
--- a/scanning/offload/offload_scan_utils.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WIFICOND_OFFLOAD_SCAN_UTILS_H_
-#define WIFICOND_OFFLOAD_SCAN_UTILS_H_
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include "wificond/scanning/offload/offload_callback.h"
-
-#include <vector>
-
-namespace com {
-namespace android {
-namespace server {
-namespace wifi {
-namespace wificond {
-
-class NativeScanResult;
-class NativeScanStats;
-
-} // namespace wificond
-} // namespace wifi
-} // namespace server
-} // namespace android
-} // namespace com
-
-namespace android {
-namespace wificond {
-
-// Provides utility methods for Offload Scan Manager
-class OffloadScanUtils {
- public:
- static bool convertToNativeScanResults(
- const std::vector<android::hardware::wifi::offload::V1_0::ScanResult>&,
- std::vector<::com::android::server::wifi::wificond::NativeScanResult>*);
- static android::hardware::wifi::offload::V1_0::ScanParam createScanParam(
- const std::vector<std::vector<uint8_t>>& ssid_list,
- const std::vector<uint32_t>& frequency_list, uint32_t scan_interval_ms);
- /* Creates ScanFilter using ssids, security flags and rssi_threshold
- * The caller must ensure that the number of ssids match the number of
- * security flags, also there must be ordering maintained among the two lists.
- * For eg: (ssid[0], flags[0]) describe the SSID and security settings of one
- * network
- */
- static android::hardware::wifi::offload::V1_0::ScanFilter createScanFilter(
- const std::vector<std::vector<uint8_t>>& ssids,
- const std::vector<uint8_t>& flags, int8_t rssi_threshold);
- static ::com::android::server::wifi::wificond::NativeScanStats
- convertToNativeScanStats(
- const android::hardware::wifi::offload::V1_0::ScanStats& /* scanStats */);
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_OFFLOAD_SCAN_UTILS_H_
diff --git a/scanning/offload/offload_service_utils.cpp b/scanning/offload/offload_service_utils.cpp
deleted file mode 100644
index d91f069..0000000
--- a/scanning/offload/offload_service_utils.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "wificond/scanning/offload/offload_service_utils.h"
-
-#include <android-base/logging.h>
-#include <cutils/properties.h>
-
-#include "wificond/scanning/offload/offload_scan_manager.h"
-#include "wificond/scanning/scanner_impl.h"
-
-using ::android::hardware::wifi::offload::V1_0::IOffload;
-
-namespace android {
-namespace wificond {
-
-android::sp<IOffload> OffloadServiceUtils::GetOffloadService() {
- return IOffload::tryGetService();
-}
-
-android::sp<OffloadCallback> OffloadServiceUtils::GetOffloadCallback(
- OffloadCallbackHandlers* handlers) {
- return new OffloadCallback(handlers);
-}
-
-OffloadDeathRecipient* OffloadServiceUtils::GetOffloadDeathRecipient(
- OffloadDeathRecipientHandler handler) {
- return new OffloadDeathRecipient(handler);
-}
-
-bool OffloadServiceUtils::IsOffloadScanSupported() const {
- if (property_get_bool("persist.wifi.offload.enable", false)) {
- LOG(INFO) << "Offload HAL supported";
- return true;
- }
- LOG(INFO) << "Offload HAL not supported ";
- return false;
-}
-
-std::shared_ptr<OffloadScanCallbackInterfaceImpl>
-OffloadServiceUtils::GetOffloadScanCallbackInterface(ScannerImpl* parent) {
- return std::make_shared<OffloadScanCallbackInterfaceImpl>(parent);
-}
-
-std::shared_ptr<OffloadScanManager> OffloadServiceUtils::GetOffloadScanManager(
- std::weak_ptr<OffloadServiceUtils> service_utils,
- std::shared_ptr<OffloadScanCallbackInterfaceImpl> callback_interface) {
- return std::make_shared<OffloadScanManager>(service_utils, callback_interface);
-}
-
-OffloadDeathRecipient::OffloadDeathRecipient(
- OffloadDeathRecipientHandler handler)
- : handler_(handler) {}
-
-} // namespace wificond
-} // namespace android
diff --git a/scanning/offload/offload_service_utils.h b/scanning/offload/offload_service_utils.h
deleted file mode 100644
index 42268de..0000000
--- a/scanning/offload/offload_service_utils.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WIFICOND_OFFLOAD_SERVICE_UTILS_H_
-#define WIFICOND_OFFLOAD_SERVICE_UTILS_H_
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-#include "wificond/scanning/offload_scan_callback_interface_impl.h"
-
-namespace android {
-namespace wificond {
-
-typedef std::function<void(uint64_t)> OffloadDeathRecipientHandler;
-class ScannerImpl;
-class OffloadServiceUtils;
-class OffloadScanManager;
-
-class OffloadDeathRecipient : public android::hardware::hidl_death_recipient {
- public:
- OffloadDeathRecipient(OffloadDeathRecipientHandler handler);
-
- void serviceDied(
- uint64_t cookie,
- const android::wp<android::hidl::base::V1_0::IBase>& who) override {
- this->handler_(cookie);
- }
-
- private:
- OffloadDeathRecipientHandler handler_;
-};
-
-// Provides methods to get Offload HAL service and create callback
-class OffloadServiceUtils {
- public:
- OffloadServiceUtils() = default;
- virtual ~OffloadServiceUtils() = default;
- virtual android::sp<android::hardware::wifi::offload::V1_0::IOffload>
- GetOffloadService();
- // Check if Offload scan is supported on this device.
- virtual bool IsOffloadScanSupported() const;
- virtual android::sp<OffloadCallback> GetOffloadCallback(
- OffloadCallbackHandlers* handlers);
- virtual OffloadDeathRecipient* GetOffloadDeathRecipient(
- OffloadDeathRecipientHandler handler);
- virtual std::shared_ptr<OffloadScanCallbackInterfaceImpl>
- GetOffloadScanCallbackInterface(ScannerImpl* parent);
- virtual std::shared_ptr<OffloadScanManager> GetOffloadScanManager(
- std::weak_ptr<OffloadServiceUtils> service_utils,
- std::shared_ptr<OffloadScanCallbackInterfaceImpl> callback_interface);
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_OFFLOAD_SERVICE_UTILS_H
diff --git a/scanning/offload/scan_stats.cpp b/scanning/offload/scan_stats.cpp
deleted file mode 100644
index bd5c793..0000000
--- a/scanning/offload/scan_stats.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/scanning/offload/scan_stats.h"
-
-#include <android-base/logging.h>
-
-#include "wificond/parcelable_utils.h"
-
-using android::status_t;
-
-namespace com {
-namespace android {
-namespace server {
-namespace wifi {
-namespace wificond {
-
-NativeScanStats::NativeScanStats(uint32_t num_scans_requested_by_wifi,
- uint32_t num_scans_serviced_by_wifi,
- uint32_t subscription_duration_ms,
- uint32_t scan_duration_ms,
- uint32_t num_channels_scanned,
- std::vector<uint8_t> histogram_channels)
- : num_scans_requested_by_wifi_(num_scans_requested_by_wifi),
- num_scans_serviced_by_wifi_(num_scans_serviced_by_wifi),
- subscription_duration_ms_(subscription_duration_ms),
- scan_duration_ms_(scan_duration_ms),
- num_channels_scanned_(num_channels_scanned),
- time_stamp_(0),
- histogram_channels_(histogram_channels) {}
-
-NativeScanStats::NativeScanStats()
- : num_scans_requested_by_wifi_(0),
- num_scans_serviced_by_wifi_(0),
- subscription_duration_ms_(0),
- scan_duration_ms_(0),
- num_channels_scanned_(0),
- time_stamp_(0) {}
-
-bool NativeScanStats::operator==(const NativeScanStats& rhs) const {
- if ((rhs.num_scans_requested_by_wifi_ != num_scans_requested_by_wifi_) ||
- (rhs.num_scans_serviced_by_wifi_ != num_scans_serviced_by_wifi_) ||
- (rhs.scan_duration_ms_ != scan_duration_ms_) ||
- (rhs.num_channels_scanned_ != num_channels_scanned_)) {
- return false;
- }
- if (rhs.histogram_channels_.size() != histogram_channels_.size()) {
- return false;
- }
- for (size_t i = 0; i < histogram_channels_.size(); i++) {
- if (rhs.histogram_channels_[i] != histogram_channels_[i]) {
- return false;
- }
- }
- return true;
-}
-
-status_t NativeScanStats::writeToParcel(::android::Parcel* parcel) const {
- RETURN_IF_FAILED(parcel->writeUint32(num_scans_requested_by_wifi_));
- RETURN_IF_FAILED(parcel->writeUint32(num_scans_serviced_by_wifi_));
- RETURN_IF_FAILED(parcel->writeUint32(subscription_duration_ms_));
- RETURN_IF_FAILED(parcel->writeUint32(scan_duration_ms_));
- RETURN_IF_FAILED(parcel->writeUint32(num_channels_scanned_));
- RETURN_IF_FAILED(parcel->writeByteVector(histogram_channels_));
- return ::android::OK;
-}
-
-status_t NativeScanStats::readFromParcel(const ::android::Parcel* parcel) {
- RETURN_IF_FAILED(parcel->readUint32(&num_scans_requested_by_wifi_));
- RETURN_IF_FAILED(parcel->readUint32(&num_scans_serviced_by_wifi_));
- RETURN_IF_FAILED(parcel->readUint32(&subscription_duration_ms_));
- RETURN_IF_FAILED(parcel->readUint32(&scan_duration_ms_));
- RETURN_IF_FAILED(parcel->readUint32(&num_channels_scanned_));
- RETURN_IF_FAILED(parcel->readByteVector(&histogram_channels_));
- return ::android::OK;
-}
-
-void NativeScanStats::DebugLog() {
- LOG(INFO) << "num_scans_requested_by_wifi=" << num_scans_requested_by_wifi_;
- LOG(INFO) << "num_scans_serviced_by_wifi=" << num_scans_serviced_by_wifi_;
- LOG(INFO) << "subscription_duration=" << subscription_duration_ms_;
- LOG(INFO) << "scan_duration_ms_=" << scan_duration_ms_;
- LOG(INFO) << "num_channels_scanned=" << num_channels_scanned_;
- for (size_t i = 0; i < histogram_channels_.size(); i++) {
- if (histogram_channels_[i] > 0) {
- LOG(INFO) << "Channel=" << i << " ScannedTimes="
- << static_cast<uint32_t>(histogram_channels_[i]);
- }
- }
-}
-
-} // namespace wificond
-} // namespace wifi
-} // namespace server
-} // namespace android
-} // namespace com
diff --git a/scanning/offload/scan_stats.h b/scanning/offload/scan_stats.h
deleted file mode 100644
index 05220b9..0000000
--- a/scanning/offload/scan_stats.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_SCAN_STATS_H
-#define WIFICOND_SCAN_STATS_H
-
-#include <vector>
-
-#include <binder/Parcel.h>
-#include <binder/Parcelable.h>
-
-namespace com {
-namespace android {
-namespace server {
-namespace wifi {
-namespace wificond {
-
-class NativeScanStats : public ::android::Parcelable {
- public:
- NativeScanStats();
- NativeScanStats(uint32_t num_scans_requested_by_wifi,
- uint32_t num_scans_serviced_by_wifi,
- uint32_t subscription_duration_ms, uint32_t scan_duration_ms,
- uint32_t num_channels_scanned,
- std::vector<uint8_t> histogram_channels);
-
- bool operator==(const NativeScanStats&) const;
- ::android::status_t writeToParcel(::android::Parcel* parcel) const override;
- ::android::status_t readFromParcel(const ::android::Parcel* parcel) override;
- void DebugLog();
-
- uint32_t num_scans_requested_by_wifi_;
- uint32_t num_scans_serviced_by_wifi_;
- uint32_t subscription_duration_ms_;
- uint32_t scan_duration_ms_;
- uint32_t num_channels_scanned_;
- uint32_t time_stamp_;
- std::vector<uint8_t> histogram_channels_;
-};
-
-} // namespace wificond
-} // namespace wifi
-} // namespace server
-} // namespace android
-} // namespace com
-#endif // WIFICOND_SCAN_STATS_H
diff --git a/scanning/offload_scan_callback_interface.h b/scanning/offload_scan_callback_interface.h
deleted file mode 100644
index 507a69f..0000000
--- a/scanning/offload_scan_callback_interface.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ANDROID_WIFICOND_OFFLOAD_SCAN_CALLBACK_INTERFACE_H
-#define ANDROID_WIFICOND_OFFLOAD_SCAN_CALLBACK_INTERFACE_H
-
-#include <vector>
-
-#include "wificond/scanning/scan_result.h"
-
-namespace android {
-namespace wificond {
-
-class OffloadScanCallbackInterface {
- public:
- enum AsyncErrorReason {
- BINDER_DEATH = 0,
- REMOTE_FAILURE,
- };
-
- virtual ~OffloadScanCallbackInterface() {}
-
- virtual void OnOffloadScanResult() = 0;
- virtual void OnOffloadError(AsyncErrorReason) = 0;
-};
-
-} // namespace wificond
-} // namespace android
-
-#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
deleted file mode 100644
index 53060b6..0000000
--- a/scanning/offload_scan_callback_interface_impl.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/scanning/offload_scan_callback_interface_impl.h"
-
-#include <android-base/logging.h>
-
-
-namespace android {
-namespace wificond {
-
-OffloadScanCallbackInterfaceImpl::OffloadScanCallbackInterfaceImpl(
- ScannerImpl* parent)
- : scanner_impl_(parent) {}
-
-OffloadScanCallbackInterfaceImpl::~OffloadScanCallbackInterfaceImpl() {}
-
-void OffloadScanCallbackInterfaceImpl::OnOffloadScanResult() {
- scanner_impl_->OnOffloadScanResult();
-}
-
-void OffloadScanCallbackInterfaceImpl::OnOffloadError(
- OffloadScanCallbackInterface::AsyncErrorReason error_code) {
- scanner_impl_->OnOffloadError(error_code);
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/scanning/offload_scan_callback_interface_impl.h b/scanning/offload_scan_callback_interface_impl.h
deleted file mode 100644
index 0f500a4..0000000
--- a/scanning/offload_scan_callback_interface_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_SCANNER_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
-#define WIFICOND_SCANNER_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
-
-#include "wificond/scanning/offload_scan_callback_interface.h"
-#include "wificond/scanning/scanner_impl.h"
-
-namespace android {
-namespace wificond {
-
-class ScannerImpl;
-
-class OffloadScanCallbackInterfaceImpl
- : public android::wificond::OffloadScanCallbackInterface {
- public:
- OffloadScanCallbackInterfaceImpl(ScannerImpl* parent);
- ~OffloadScanCallbackInterfaceImpl() override;
-
- void OnOffloadScanResult() override;
- void OnOffloadError(OffloadScanCallbackInterface::AsyncErrorReason) override;
-
- private:
- ScannerImpl* scanner_impl_;
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_SCANNER_OFFLOAD_SCAN_CALLBACK_INTERFACE_IML_H_
diff --git a/scanning/scanner_impl.cpp b/scanning/scanner_impl.cpp
index f2953d8..77b1e76 100644
--- a/scanning/scanner_impl.cpp
+++ b/scanning/scanner_impl.cpp
@@ -23,8 +23,6 @@
#include <android-base/logging.h>
#include "wificond/client_interface_impl.h"
-#include "wificond/scanning/offload/offload_scan_manager.h"
-#include "wificond/scanning/offload/offload_service_utils.h"
#include "wificond/scanning/scan_utils.h"
using android::binder::Status;
@@ -71,14 +69,10 @@
const ScanCapabilities& scan_capabilities,
const WiphyFeatures& wiphy_features,
ClientInterfaceImpl* client_interface,
- ScanUtils* scan_utils,
- weak_ptr<OffloadServiceUtils> offload_service_utils)
+ ScanUtils* scan_utils)
: valid_(true),
scan_started_(false),
pno_scan_started_(false),
- offload_scan_supported_(false),
- pno_scan_running_over_offload_(false),
- pno_scan_results_from_offload_(false),
interface_index_(interface_index),
scan_capabilities_(scan_capabilities),
wiphy_features_(wiphy_features),
@@ -97,12 +91,6 @@
std::bind(&ScannerImpl::OnSchedScanResultsReady,
this,
_1, _2));
- std::shared_ptr<OffloadScanCallbackInterfaceImpl>
- offload_scan_callback_interface =
- offload_service_utils.lock()->GetOffloadScanCallbackInterface(this);
- offload_scan_manager_ = offload_service_utils.lock()->GetOffloadScanManager(
- offload_service_utils, offload_scan_callback_interface);
- offload_scan_supported_ = offload_service_utils.lock()->IsOffloadScanSupported();
}
ScannerImpl::~ScannerImpl() {}
@@ -138,14 +126,8 @@
if (!CheckIsValid()) {
return Status::ok();
}
- if (pno_scan_results_from_offload_) {
- if (!offload_scan_manager_->getScanResults(out_scan_results)) {
- LOG(ERROR) << "Failed to get scan results via Offload HAL";
- }
- } else {
- if (!scan_utils_->GetScanResult(interface_index_, out_scan_results)) {
- LOG(ERROR) << "Failed to get scan results via NL80211";
- }
+ if (!scan_utils_->GetScanResult(interface_index_, out_scan_results)) {
+ LOG(ERROR) << "Failed to get scan results via NL80211";
}
return Status::ok();
}
@@ -204,41 +186,11 @@
Status ScannerImpl::startPnoScan(const PnoSettings& pno_settings,
bool* out_success) {
pno_settings_ = pno_settings;
- pno_scan_results_from_offload_ = false;
LOG(VERBOSE) << "startPnoScan";
- if (offload_scan_supported_ && StartPnoScanOffload(pno_settings)) {
- // scanning over offload succeeded
- *out_success = true;
- } else {
- *out_success = StartPnoScanDefault(pno_settings);
- }
+ *out_success = StartPnoScanDefault(pno_settings);
return Status::ok();
}
-bool ScannerImpl::StartPnoScanOffload(const PnoSettings& pno_settings) {
- OffloadScanManager::ReasonCode reason_code;
- vector<vector<uint8_t>> scan_ssids;
- vector<vector<uint8_t>> match_ssids;
- vector<uint8_t> match_security;
- // Empty frequency list: scan all frequencies.
- vector<uint32_t> freqs;
-
- ParsePnoSettings(pno_settings, &scan_ssids, &match_ssids, &freqs,
- &match_security);
- pno_scan_running_over_offload_ = offload_scan_manager_->startScan(
- pno_settings.interval_ms_,
- // TODO: honor both rssi thresholds.
- pno_settings.min_5g_rssi_, scan_ssids, match_ssids, match_security, freqs,
- &reason_code);
- if (pno_scan_running_over_offload_) {
- LOG(VERBOSE) << "Pno scans requested over Offload HAL";
- if (pno_scan_event_handler_ != nullptr) {
- pno_scan_event_handler_->OnPnoScanOverOffloadStarted();
- }
- }
- return pno_scan_running_over_offload_;
-}
-
void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
vector<vector<uint8_t>>* scan_ssids,
vector<vector<uint8_t>>* match_ssids,
@@ -253,7 +205,6 @@
for (auto& network : pno_settings.pno_networks_) {
// Add hidden network ssid.
if (network.is_hidden_) {
- // TODO remove pruning for Offload Scans
if (scan_ssids->size() + 1 >
scan_capabilities_.max_num_sched_scan_ssids) {
skipped_scan_ssids.emplace_back(network.ssid_);
@@ -347,29 +298,10 @@
}
Status ScannerImpl::stopPnoScan(bool* out_success) {
- if (offload_scan_supported_ && StopPnoScanOffload()) {
- // Pno scans over offload stopped successfully
- *out_success = true;
- } else {
- // Pno scans were not requested over offload
- *out_success = StopPnoScanDefault();
- }
+ *out_success = StopPnoScanDefault();
return Status::ok();
}
-bool ScannerImpl::StopPnoScanOffload() {
- OffloadScanManager::ReasonCode reason_code;
- if (!pno_scan_running_over_offload_) {
- return false;
- }
- if (!offload_scan_manager_->stopScan(&reason_code)) {
- LOG(WARNING) << "Unable to unsubscribe to Offload scan results";
- }
- pno_scan_running_over_offload_ = false;
- LOG(VERBOSE) << "Pno scans over Offload stopped";
- return true;
-}
-
bool ScannerImpl::StopPnoScanDefault() {
if (!CheckIsValid()) {
return false;
@@ -472,7 +404,6 @@
pno_scan_started_ = false;
} else {
LOG(INFO) << "Pno scan result ready event";
- pno_scan_results_from_offload_ = false;
pno_scan_event_handler_->OnPnoNetworkFound();
}
}
@@ -506,65 +437,6 @@
}
}
-void ScannerImpl::OnOffloadScanResult() {
- if (!pno_scan_running_over_offload_) {
- LOG(WARNING) << "Scan results from Offload HAL but scan not requested over "
- "this interface";
- return;
- }
- LOG(INFO) << "Offload Scan results received";
- pno_scan_results_from_offload_ = true;
- if (pno_scan_event_handler_ != nullptr) {
- pno_scan_event_handler_->OnPnoNetworkFound();
- } else {
- LOG(WARNING) << "No scan event handler Offload Scan result";
- }
-}
-
-void ScannerImpl::OnOffloadError(
- OffloadScanCallbackInterface::AsyncErrorReason error_code) {
- if (!pno_scan_running_over_offload_) {
- // Ignore irrelevant error notifications
- LOG(WARNING) << "Offload HAL Async Error occured but Offload HAL is not "
- "subscribed to";
- return;
- }
- LOG(ERROR) << "Offload Service Async Failure error_code=" << error_code;
- switch (error_code) {
- case OffloadScanCallbackInterface::AsyncErrorReason::BINDER_DEATH:
- LOG(ERROR) << "Binder death";
- if (pno_scan_event_handler_ != nullptr) {
- pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
- net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_BINDER_FAILURE);
- }
- break;
- case OffloadScanCallbackInterface::AsyncErrorReason::REMOTE_FAILURE:
- LOG(ERROR) << "Remote failure";
- if (pno_scan_event_handler_ != nullptr) {
- pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
- net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_REMOTE_FAILURE);
- }
- break;
- default:
- LOG(WARNING) << "Invalid Error code";
- break;
- }
- bool success = false;
- // Stop scans over Offload HAL and request them over netlink
- stopPnoScan(&success);
- if (success) {
- LOG(INFO) << "Pno scans stopped";
- }
- // Restart PNO scans over netlink interface
- success = StartPnoScanDefault(pno_settings_);
- if (success) {
- LOG(INFO) << "Pno scans restarted";
- } else {
- LOG(ERROR) << "Unable to fall back to netlink pno scan";
- pno_scan_event_handler_->OnPnoScanFailed();
- }
-}
-
void ScannerImpl::LogSsidList(vector<vector<uint8_t>>& ssid_list,
string prefix) {
if (ssid_list.empty()) {
diff --git a/scanning/scanner_impl.h b/scanning/scanner_impl.h
index cf50a37..3c1a4c7 100644
--- a/scanning/scanner_impl.h
+++ b/scanning/scanner_impl.h
@@ -24,17 +24,13 @@
#include "android/net/wifi/BnWifiScannerImpl.h"
#include "wificond/net/netlink_utils.h"
-#include "wificond/scanning/offload_scan_callback_interface.h"
#include "wificond/scanning/scan_utils.h"
namespace android {
namespace wificond {
class ClientInterfaceImpl;
-class OffloadServiceUtils;
class ScanUtils;
-class OffloadScanCallbackInterfaceImpl;
-class OffloadScanManager;
class ScannerImpl : public android::net::wifi::BnWifiScannerImpl {
public:
@@ -42,8 +38,7 @@
const ScanCapabilities& scan_capabilities,
const WiphyFeatures& wiphy_features,
ClientInterfaceImpl* client_interface,
- ScanUtils* scan_utils,
- std::weak_ptr<OffloadServiceUtils> offload_service_utils);
+ ScanUtils* scan_utils);
~ScannerImpl();
// Get the latest single scan results from kernel.
::android::binder::Status getScanResults(
@@ -71,9 +66,6 @@
const ::android::sp<::android::net::wifi::IPnoScanEvent>& handler)
override;
::android::binder::Status unsubscribePnoScanEvents() override;
- void OnOffloadScanResult();
- void OnOffloadError(
- OffloadScanCallbackInterface::AsyncErrorReason error_code);
void Invalidate();
private:
@@ -86,10 +78,7 @@
std::string prefix);
bool StartPnoScanDefault(
const ::com::android::server::wifi::wificond::PnoSettings& pno_settings);
- bool StartPnoScanOffload(
- const ::com::android::server::wifi::wificond::PnoSettings& pno_settings);
bool StopPnoScanDefault();
- bool StopPnoScanOffload();
void ParsePnoSettings(
const ::com::android::server::wifi::wificond::PnoSettings& pno_settings,
std::vector<std::vector<uint8_t>>* scan_ssids,
@@ -102,9 +91,6 @@
bool valid_;
bool scan_started_;
bool pno_scan_started_;
- bool offload_scan_supported_;
- bool pno_scan_running_over_offload_;
- bool pno_scan_results_from_offload_;
::com::android::server::wifi::wificond::PnoSettings pno_settings_;
const uint32_t interface_index_;
@@ -117,7 +103,6 @@
ScanUtils* const scan_utils_;
::android::sp<::android::net::wifi::IPnoScanEvent> pno_scan_event_handler_;
::android::sp<::android::net::wifi::IScanEvent> scan_event_handler_;
- std::shared_ptr<OffloadScanManager> offload_scan_manager_;
DISALLOW_COPY_AND_ASSIGN(ScannerImpl);
};
diff --git a/tests/mock_offload.cpp b/tests/mock_offload.cpp
deleted file mode 100644
index 02ad00d..0000000
--- a/tests/mock_offload.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload.h"
-
-namespace android {
-namespace wificond {
-
-MockOffload::MockOffload() {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload.h b/tests/mock_offload.h
deleted file mode 100644
index 399639c..0000000
--- a/tests/mock_offload.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TEST_MOCK_OFFLOAD_H
-#define WIFICOND_TEST_MOCK_OFFLOAD_H
-
-#include <gmock/gmock.h>
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-
-namespace android {
-namespace wificond {
-
-typedef std::function<void(
- const android::hardware::wifi::offload::V1_0::OffloadStatus& status,
- const android::hardware::wifi::offload::V1_0::ScanStats& scanStats)>
- OnScanStatsCallback;
-typedef std::function<void(
- const android::hardware::wifi::offload::V1_0::OffloadStatus& status)>
- StatusCallback;
-
-class MockOffload : public android::hardware::wifi::offload::V1_0::IOffload {
- public:
- MockOffload();
- ~MockOffload() override = default;
-
- MOCK_METHOD3(
- configureScans,
- android::hardware::Return<void>(
- const android::hardware::wifi::offload::V1_0::ScanParam& param,
- const android::hardware::wifi::offload::V1_0::ScanFilter& filter,
- StatusCallback _hidl_cb));
- MOCK_METHOD1(getScanStats,
- android::hardware::Return<void>(OnScanStatsCallback cb));
- MOCK_METHOD2(subscribeScanResults,
- android::hardware::Return<void>(uint32_t delayMs,
- StatusCallback _hidl_cb));
- MOCK_METHOD0(unsubscribeScanResults, android::hardware::Return<void>());
- MOCK_METHOD1(
- setEventCallback,
- android::hardware::Return<void>(
- const android::sp<
- android::hardware::wifi::offload::V1_0::IOffloadCallback>& cb));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TEST_MOCK_OFFLOAD_H
diff --git a/tests/mock_offload_callback_handlers.cpp b/tests/mock_offload_callback_handlers.cpp
deleted file mode 100644
index e4e5d48..0000000
--- a/tests/mock_offload_callback_handlers.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload_callback_handlers.h"
-
-namespace android {
-namespace wificond {
-
-MockOffloadCallbackHandlers::MockOffloadCallbackHandlers() {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload_callback_handlers.h b/tests/mock_offload_callback_handlers.h
deleted file mode 100644
index e9b6285..0000000
--- a/tests/mock_offload_callback_handlers.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
-#define WIFICOND_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-
-namespace android {
-namespace wificond {
-
-class MockOffloadCallbackHandlers : public OffloadCallbackHandlers {
- public:
- MockOffloadCallbackHandlers();
- ~MockOffloadCallbackHandlers() override = default;
-
- MOCK_METHOD1(
- OnScanResultHandler,
- void(const std::vector<
- android::hardware::wifi::offload::V1_0::ScanResult>& scanResult));
- MOCK_METHOD1(OnErrorHandler,
- void(const android::hardware::wifi::offload::V1_0::OffloadStatus&
- status));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_MOCK_OFFLOAD_CALLBACK_HANDLERS_H_
diff --git a/tests/mock_offload_scan_callback_interface.cpp b/tests/mock_offload_scan_callback_interface.cpp
deleted file mode 100644
index cb76e45..0000000
--- a/tests/mock_offload_scan_callback_interface.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload_scan_callback_interface.h"
-
-namespace android {
-namespace wificond {
-
-MockOffloadScanCallbackInterface::MockOffloadScanCallbackInterface() {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload_scan_callback_interface.h b/tests/mock_offload_scan_callback_interface.h
deleted file mode 100644
index e4f8df9..0000000
--- a/tests/mock_offload_scan_callback_interface.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_H_
-#define WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_H_
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include "wificond/scanning/offload_scan_callback_interface.h"
-
-namespace android {
-namespace wificond {
-
-class MockOffloadScanCallbackInterface : public OffloadScanCallbackInterface {
- public:
- MockOffloadScanCallbackInterface();
- ~MockOffloadScanCallbackInterface() override = default;
-
- MOCK_METHOD0(OnOffloadScanResult, void());
- MOCK_METHOD1(OnOffloadError,
- void(OffloadScanCallbackInterface::AsyncErrorReason));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_H_
diff --git a/tests/mock_offload_scan_callback_interface_impl.cpp b/tests/mock_offload_scan_callback_interface_impl.cpp
deleted file mode 100644
index b9dffc5..0000000
--- a/tests/mock_offload_scan_callback_interface_impl.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload_scan_callback_interface_impl.h"
-#include "wificond/scanning/scanner_impl.h"
-
-namespace android {
-namespace wificond {
-
-MockOffloadScanCallbackInterfaceImpl::MockOffloadScanCallbackInterfaceImpl(
- ScannerImpl* parent)
- : OffloadScanCallbackInterfaceImpl(parent) {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload_scan_callback_interface_impl.h b/tests/mock_offload_scan_callback_interface_impl.h
deleted file mode 100644
index 8b76388..0000000
--- a/tests/mock_offload_scan_callback_interface_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_IMPL_H__
-#define WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_IMPL_H__
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include "wificond/scanning/offload_scan_callback_interface_impl.h"
-
-namespace android {
-namespace wificond {
-
-class ScannerImpl;
-
-class MockOffloadScanCallbackInterfaceImpl
- : public OffloadScanCallbackInterfaceImpl {
- public:
- MockOffloadScanCallbackInterfaceImpl(ScannerImpl*);
- ~MockOffloadScanCallbackInterfaceImpl() override = default;
-
- MOCK_METHOD0(OnOffloadScanResult, void());
- MOCK_METHOD1(OnOffloadError,
- void(OffloadScanCallbackInterface::AsyncErrorReason));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_CALLBACK_INTERFACE_IMPL_H__
diff --git a/tests/mock_offload_scan_manager.cpp b/tests/mock_offload_scan_manager.cpp
deleted file mode 100644
index 8943524..0000000
--- a/tests/mock_offload_scan_manager.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload_scan_manager.h"
-
-namespace android {
-namespace wificond {
-
-MockOffloadScanManager::MockOffloadScanManager(
- std::weak_ptr<OffloadServiceUtils> service_utils,
- std::shared_ptr<OffloadScanCallbackInterface> callback_interface)
- : OffloadScanManager(service_utils, callback_interface) {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload_scan_manager.h b/tests/mock_offload_scan_manager.h
deleted file mode 100644
index 71d5e79..0000000
--- a/tests/mock_offload_scan_manager.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_MANAGER_H_
-#define WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_MANAGER_H_
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include "wificond/scanning/offload/offload_scan_manager.h"
-
-namespace android {
-namespace wificond {
-
-class MockOffloadScanManager : public OffloadScanManager {
- public:
- MockOffloadScanManager(
- std::weak_ptr<OffloadServiceUtils> service_utils,
- std::shared_ptr<OffloadScanCallbackInterface> callback_interface);
- ~MockOffloadScanManager() override = default;
-
- MOCK_METHOD7(startScan,
- bool(uint32_t interval_ms, int32_t rssi_threshold,
- const std::vector<std::vector<uint8_t>>& scan_ssids,
- const std::vector<std::vector<uint8_t>>& match_ssids,
- const std::vector<uint8_t>& match_security,
- const std::vector<uint32_t>& frequencies,
- OffloadScanManager::ReasonCode* reason_code));
- MOCK_METHOD1(stopScan, bool(OffloadScanManager::ReasonCode* reason_code));
- MOCK_METHOD1(getScanStats,
- bool(::com::android::server::wifi::wificond::NativeScanStats*
- scan_stats));
- MOCK_CONST_METHOD0(getOffloadStatus, OffloadScanManager::StatusCode());
- MOCK_METHOD1(
- getScanResults,
- bool(std::vector<
- ::com::android::server::wifi::wificond::NativeScanResult>*));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_MOCK_OFFLOAD_SCAN_MANAGER_H_
diff --git a/tests/mock_offload_service_utils.cpp b/tests/mock_offload_service_utils.cpp
deleted file mode 100644
index c58be31..0000000
--- a/tests/mock_offload_service_utils.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "wificond/tests/mock_offload_service_utils.h"
-
-namespace android {
-namespace wificond {
-
-MockOffloadServiceUtils::MockOffloadServiceUtils() {}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/mock_offload_service_utils.h b/tests/mock_offload_service_utils.h
deleted file mode 100644
index 76d022d..0000000
--- a/tests/mock_offload_service_utils.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_TEST_MOCK_OFFLOAD_SERVICE_UTILS_H_
-#define WIFICOND_TEST_MOCK_OFFLOAD_SERVICE_UTILS_H_
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-#include "wificond/scanning/offload/offload_service_utils.h"
-#include "wificond/scanning/offload_scan_callback_interface_impl.h"
-
-namespace android {
-namespace wificond {
-
-class MockOffloadServiceUtils : public OffloadServiceUtils {
- public:
- MockOffloadServiceUtils();
- ~MockOffloadServiceUtils() override = default;
- MOCK_CONST_METHOD0(IsOffloadScanSupported, bool());
- MOCK_METHOD0(GetOffloadService,
- sp<android::hardware::wifi::offload::V1_0::IOffload>());
- MOCK_METHOD1(GetOffloadCallback,
- sp<OffloadCallback>(OffloadCallbackHandlers* handlers));
- MOCK_METHOD1(GetOffloadDeathRecipient,
- android::wificond::OffloadDeathRecipient*(
- OffloadDeathRecipientHandler handler));
- MOCK_METHOD1(
- GetOffloadScanCallbackInterface,
- std::shared_ptr<OffloadScanCallbackInterfaceImpl>(ScannerImpl* scanner));
- MOCK_METHOD2(GetOffloadScanManager,
- std::shared_ptr<OffloadScanManager>(
- std::weak_ptr<OffloadServiceUtils> service_utils,
- std::shared_ptr<OffloadScanCallbackInterfaceImpl>
- callback_interface));
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TEST_MOCK_OFFLOAD_SERVICE_UTILS_H_
diff --git a/tests/offload_callback_test.cpp b/tests/offload_callback_test.cpp
deleted file mode 100644
index f55d281..0000000
--- a/tests/offload_callback_test.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <functional>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/scan_result.h"
-#include "wificond/tests/mock_offload_callback_handlers.h"
-#include "wificond/tests/offload_test_utils.h"
-
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::OffloadStatus;
-using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
-using android::hardware::hidl_vec;
-using testing::NiceMock;
-
-namespace android {
-namespace wificond {
-
-class OffloadCallbackTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- dummy_scan_results_ = OffloadTestUtils::createOffloadScanResults();
- }
-
- void TearDown() override { dummy_scan_results_.clear(); }
-
- std::vector<ScanResult> dummy_scan_results_;
- std::unique_ptr<OffloadCallback> offload_callback_;
- std::unique_ptr<NiceMock<MockOffloadCallbackHandlers>> handlers_;
-};
-
-/**
- * Testing OffloadCallback to invoke the registered callback handler
- * with the scan results when they are available
- */
-TEST_F(OffloadCallbackTest, checkScanResultSize) {
- std::vector<ScanResult> scan_result;
- handlers_.reset(new NiceMock<MockOffloadCallbackHandlers>());
- ON_CALL(*handlers_, OnScanResultHandler(testing::_))
- .WillByDefault(testing::Invoke(
- [&scan_result](std::vector<ScanResult> scanResult) -> void {
- scan_result = scanResult;
- }));
- offload_callback_.reset(new OffloadCallback(handlers_.get()));
- hidl_vec<ScanResult> offloadScanResult(dummy_scan_results_);
- offload_callback_->onScanResult(offloadScanResult);
- EXPECT_EQ(dummy_scan_results_.size(), scan_result.size());
-}
-
-/**
- * Testing OffloadCallback to invoke the registered error handler
- */
-TEST_F(OffloadCallbackTest, checkErrorStatus) {
- OffloadStatus status_;
- handlers_.reset(new NiceMock<MockOffloadCallbackHandlers>());
- ON_CALL(*handlers_, OnErrorHandler(testing::_))
- .WillByDefault(testing::Invoke(
- [&status_](OffloadStatus status) -> void { status_ = status; }));
- offload_callback_.reset(new OffloadCallback(handlers_.get()));
- OffloadStatus status =
- OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
- offload_callback_->onError(status);
- EXPECT_EQ(status_.code, OffloadStatusCode::ERROR);
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/offload_hal_test_constants.cpp b/tests/offload_hal_test_constants.cpp
deleted file mode 100644
index 79705fe..0000000
--- a/tests/offload_hal_test_constants.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "offload_hal_test_constants.h"
-
-namespace android {
-namespace wificond {
-namespace offload_hal_test_constants {
-
-const uint8_t kSsid1[] = {'G', 'o', 'o', 'g', 'l', 'e'};
-const size_t kSsid1_size = sizeof(kSsid1);
-const uint8_t kSsid2[] = {'X', 'f', 'i', 'n', 'i', 't', 'y'};
-const size_t kSsid2_size = sizeof(kSsid2);
-const uint8_t kBssid[6] = {0x12, 0xef, 0xa1, 0x2c, 0x97, 0x8b};
-const int16_t kRssi = -60;
-const int16_t kRssiThreshold = -76;
-const uint32_t kFrequency1 = 2412;
-const uint32_t kFrequency2 = 2437;
-const uint8_t kBssidSize = 6;
-const uint64_t kTsf = 0;
-const uint16_t kCapability = 0;
-const uint8_t kNetworkFlags = 0;
-const uint32_t kDisconnectedModeScanIntervalMs = 5000;
-const uint64_t kSubscriptionDurationMs = 10000;
-const uint64_t kScanDurationMs[2] = {2000, 500};
-const uint32_t kNumChannelsScanned[2] = {14, 6};
-const uint8_t kDefaultNumTimesAChannelsIsScanned = 1;
-const uint8_t kChannelNotScanned = 0;
-const uint32_t kDefaultNumScansRequestedByWifi = 2;
-const uint32_t kDefaultNumScansServicedByWifi = 2;
-const uint64_t kScanDurationTotalMs = 2000;
-const uint32_t kNumChannelsTotalScanned = 20;
-const uint32_t kNumChannelsInHistogram = 256;
-const uint64_t kDeathCode = 0xBEEF;
-
-} // namespace offload_hal_test_constants
-} // namespace wificond
-} // namespace android
diff --git a/tests/offload_hal_test_constants.h b/tests/offload_hal_test_constants.h
deleted file mode 100644
index efc589f..0000000
--- a/tests/offload_hal_test_constants.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_OFFLOAD_HAL_TEST_CONSTANTS_H_
-#define WIFICOND_OFFLOAD_HAL_TEST_CONSTANTS_H_
-
-#include <cstdint>
-
-namespace android {
-namespace wificond {
-namespace offload_hal_test_constants {
-
-extern const uint8_t kSsid1[];
-extern const size_t kSsid1_size;
-extern const uint8_t kSsid2[];
-extern const size_t kSsid2_size;
-extern const uint8_t kBssid[6];
-extern const int16_t kRssi;
-extern const int16_t kRssiThreshold;
-extern const uint32_t kFrequency1;
-extern const uint32_t kFrequency2;
-extern const uint8_t kBssidSize;
-extern const uint64_t kTsf;
-extern const uint16_t kCapability;
-extern const uint8_t kNetworkFlags;
-extern const uint32_t kDisconnectedModeScanIntervalMs;
-extern const uint64_t kSubscriptionDurationMs;
-extern const uint64_t kScanDurationMs[2];
-extern const uint32_t kNumChannelsScanned[2];
-extern const uint8_t kDefaultNumTimesAChannelsIsScanned;
-extern const uint8_t kChannelNotScanned;
-extern const uint32_t kDefaultNumScansRequestedByWifi;
-extern const uint32_t kDefaultNumScansServicedByWifi;
-extern const uint64_t kScanDurationTotalMs;
-extern const uint32_t kNumChannelsTotalScanned;
-extern const uint32_t kNumChannelsInHistogram;
-extern const uint64_t kDeathCode;
-
-} // namespace offload_hal_test_constants
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_OFFLOAD_HAL_TEST_CONSTANTS_H_
diff --git a/tests/offload_scan_manager_test.cpp b/tests/offload_scan_manager_test.cpp
deleted file mode 100644
index 9e586cb..0000000
--- a/tests/offload_scan_manager_test.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <functional>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include <gtest/gtest.h>
-
-#include "wificond/tests/mock_offload.h"
-#include "wificond/tests/mock_offload_scan_callback_interface.h"
-#include "wificond/tests/mock_offload_service_utils.h"
-#include "wificond/tests/offload_hal_test_constants.h"
-#include "wificond/tests/offload_test_utils.h"
-
-#include "wificond/scanning/offload/offload_callback.h"
-#include "wificond/scanning/offload/offload_callback_handlers.h"
-#include "wificond/scanning/offload/offload_scan_manager.h"
-#include "wificond/scanning/scan_result.h"
-
-using android::hardware::Return;
-using android::hardware::Void;
-using android::hardware::wifi::offload::V1_0::IOffload;
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::OffloadStatus;
-using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
-using android::hardware::wifi::offload::V1_0::ScanParam;
-using android::hardware::wifi::offload::V1_0::ScanFilter;
-using android::hardware::wifi::offload::V1_0::ScanStats;
-using android::sp;
-using com::android::server::wifi::wificond::NativeScanResult;
-using com::android::server::wifi::wificond::NativeScanStats;
-using testing::NiceMock;
-using testing::_;
-using testing::Invoke;
-using std::shared_ptr;
-using std::unique_ptr;
-using std::vector;
-using std::bind;
-
-using namespace std::placeholders;
-using namespace android::wificond::offload_hal_test_constants;
-
-namespace android {
-namespace wificond {
-
-sp<OffloadCallback> CaptureCallback(OffloadCallbackHandlers* handler,
- sp<OffloadCallback>* offload_callback) {
- *offload_callback = sp<OffloadCallback>(new OffloadCallback(handler));
- return *offload_callback;
-}
-
-OffloadDeathRecipient* CaptureDeathRecipient(
- OffloadDeathRecipientHandler handler,
- sp<OffloadDeathRecipient>* death_recipient_) {
- OffloadDeathRecipient* death_recipient = new OffloadDeathRecipient(handler);
- *death_recipient_ = sp<OffloadDeathRecipient>(death_recipient);
- return death_recipient;
-}
-
-Return<void> HidlStatusReturn(android::wificond::StatusCallback cb,
- OffloadStatus* status) {
- cb(*status);
- return Void();
-}
-
-Return<void> ScanStatusReturn(android::wificond::OnScanStatsCallback cb,
- OffloadStatus* status) {
- ScanStats stats;
- cb(*status, stats);
- return Void();
-}
-
-class OffloadScanManagerTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- ON_CALL(*mock_offload_service_utils_, GetOffloadCallback(_))
- .WillByDefault(Invoke(bind(CaptureCallback, _1, &offload_callback_)));
- ON_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_))
- .WillByDefault(
- Invoke(bind(CaptureDeathRecipient, _1, &death_recipient_)));
- status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::OK);
- ON_CALL(*mock_offload_, configureScans(_, _, _))
- .WillByDefault(Invoke(bind(HidlStatusReturn, _3, &status)));
- ON_CALL(*mock_offload_, subscribeScanResults(_, _))
- .WillByDefault(Invoke(bind(HidlStatusReturn, _2, &status)));
- ON_CALL(*mock_offload_, getScanStats(_))
- .WillByDefault(Invoke(bind(ScanStatusReturn, _1, &status)));
- }
-
- void TearDown() override {
- offload_callback_.clear();
- death_recipient_.clear();
- }
-
- sp<NiceMock<MockOffload>> mock_offload_{new NiceMock<MockOffload>()};
- sp<OffloadCallback> offload_callback_;
- sp<OffloadDeathRecipient> death_recipient_;
- shared_ptr<NiceMock<MockOffloadServiceUtils>> mock_offload_service_utils_{
- new NiceMock<MockOffloadServiceUtils>()};
- shared_ptr<NiceMock<MockOffloadScanCallbackInterface>>
- mock_offload_scan_callback_interface_{
- new NiceMock<MockOffloadScanCallbackInterface>()};
- unique_ptr<OffloadScanManager> offload_scan_manager_;
- OffloadStatus status;
- vector<vector<uint8_t>> scan_ssids{kSsid1, kSsid2};
- vector<vector<uint8_t>> match_ssids{kSsid1, kSsid2};
- vector<uint8_t> security_flags{kNetworkFlags, kNetworkFlags};
- vector<uint32_t> frequencies{kFrequency1, kFrequency2};
- uint64_t cookie_ = reinterpret_cast<uint64_t>(mock_offload_.get());
-};
-
-/**
- * Testing OffloadScanManager for binder death with registered cookie
- */
-TEST_F(OffloadScanManagerTest, BinderDeathRegisteredCookieAndService) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
- death_recipient_->serviceDied(cookie_, mock_offload_);
- EXPECT_EQ(OffloadScanManager::kNoService,
- offload_scan_manager_->getOffloadStatus());
-}
-
-/**
- * Testing OffloadScanManager for binder death with invalid cookie
- */
-TEST_F(OffloadScanManagerTest, BinderDeathUnregisteredCookie) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- death_recipient_->serviceDied(kDeathCode, mock_offload_);
- EXPECT_FALSE(OffloadScanManager::kNoService ==
- offload_scan_manager_->getOffloadStatus());
-}
-
-/**
- * Testing OffloadScanManager with no handle on Offloal HAL service
- * and no registered handler for Offload Scan results
- */
-TEST_F(OffloadScanManagerTest, ServiceNotAvailableTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(nullptr));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_EQ(OffloadScanManager::kNoService,
- offload_scan_manager_->getOffloadStatus());
-}
-
-/**
- * Testing OffloadScanManager when service is available and valid handler
- * registered for Offload Scan results
- */
-TEST_F(OffloadScanManagerTest, ServiceAvailableTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_EQ(OffloadScanManager::kNoError,
- offload_scan_manager_->getOffloadStatus());
-}
-
-/**
- * Testing OffloadScanManager when service is available and valid handler
- * is registered, test to ensure that registered handler is invoked when
- * scan results are available
- */
-TEST_F(OffloadScanManagerTest, CallbackInvokedTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadScanResult());
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- vector<ScanResult> dummy_scan_results_ =
- OffloadTestUtils::createOffloadScanResults();
- offload_callback_->onScanResult(dummy_scan_results_);
-}
-
-/**
- * Testing OffloadScanManager when service is available and valid handler
- * is registered, ensure that error callback is invoked
- */
-TEST_F(OffloadScanManagerTest, ErrorCallbackInvokedTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- OffloadStatus status =
- OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
- EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
- offload_callback_->onError(status);
- EXPECT_EQ(offload_scan_manager_->getOffloadStatus(),
- OffloadScanManager::kError);
-}
-
-/**
- * Testing OffloadScanManager for subscribing to the scan results from
- * Offload HAL when service is running without errors
- */
-TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsOk) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
- EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, true);
-}
-
-/**
- * Testing OffloadScanManager for subscribing to the scan results from
- * Offload HAL when service is not available
- */
-TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotAvailable) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService()).Times(2);
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(nullptr));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, false);
- EXPECT_EQ(reason_code, OffloadScanManager::kNotAvailable);
-}
-
-/**
- * Testing OffloadScanManager for subscribing to the scan results from
- * Offload HAL when service is not working correctly
- */
-TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotConnected) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- OffloadStatus status =
- OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
- offload_callback_->onError(status);
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, false);
- EXPECT_EQ(reason_code, OffloadScanManager::kNotAvailable);
-}
-
-/**
- * Testing OffloadScanManager for subscribing to the scan results from
- * Offload HAL twice when service is okay
- */
-TEST_F(OffloadScanManagerTest, StartScanTwiceTestWhenServiceIsOk) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(2);
- EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(2);
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, true);
- result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, true);
-}
-
-/**
- * Testing OffloadScanManager for unsubscribing to the scan results from
- * Offload HAL when service is ok
- */
-TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsOk) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
- EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
- EXPECT_CALL(*mock_offload_, unsubscribeScanResults());
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, true);
- result = offload_scan_manager_->stopScan(&reason_code);
- EXPECT_EQ(result, true);
-}
-
-/**
- * Testing OffloadScanManager for unsubscribing to the scan results from
- * when service is not connected to the hardware
- */
-TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
- EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, true);
- OffloadStatus status =
- OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
- offload_callback_->onError(status);
- result = offload_scan_manager_->stopScan(&reason_code);
- EXPECT_EQ(result, false);
-}
-
-/**
- * Testing OffloadScanManager for getting scan statistics when the
- * Offload HAL service is running without errors
- */
-TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsOk) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, getScanStats(_));
- NativeScanStats stats;
- bool result = offload_scan_manager_->getScanStats(&stats);
- EXPECT_EQ(result, true);
-}
-
-/**
- * Testing OffloadScanManager for getting scan statistics when the
- * Offload HAL service is not connected
- */
-TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsNotOk) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- OffloadStatus status =
- OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
- offload_callback_->onError(status);
- EXPECT_CALL(*mock_offload_, getScanStats(_)).Times(0);
- NativeScanStats stats;
- bool result = offload_scan_manager_->getScanStats(&stats);
- EXPECT_EQ(result, false);
-}
-
-/**
- * Testing OffloadScanManager for subscribing to the scan results from
- * Offload HAL when service is running without errors, operation failure
- */
-TEST_F(OffloadScanManagerTest, StartScanFailedTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(0);
- EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(1);
- status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
- OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
- bool result = offload_scan_manager_->startScan(
- kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
- security_flags, frequencies, &reason_code);
- EXPECT_EQ(result, false);
- EXPECT_EQ(reason_code, OffloadScanManager::kOperationFailed);
-}
-
-/**
- * Testing OffloadScanManager for getting scan statistics when the
- * Offload HAL service is running without errors, getting scan stats failure
- */
-TEST_F(OffloadScanManagerTest, getScanStatsFailedTest) {
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
- EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
- ON_CALL(*mock_offload_service_utils_, GetOffloadService())
- .WillByDefault(testing::Return(mock_offload_));
- offload_scan_manager_.reset(new OffloadScanManager(
- mock_offload_service_utils_, mock_offload_scan_callback_interface_));
- status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::TIMEOUT);
- EXPECT_CALL(*mock_offload_, getScanStats(_));
- NativeScanStats stats;
- bool result = offload_scan_manager_->getScanStats(&stats);
- EXPECT_EQ(result, false);
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/offload_scan_utils_test.cpp b/tests/offload_scan_utils_test.cpp
deleted file mode 100644
index 15c7e86..0000000
--- a/tests/offload_scan_utils_test.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vector>
-
-#include <android-base/logging.h>
-#include <gtest/gtest.h>
-#include "wificond/scanning/offload/offload_scan_utils.h"
-#include "wificond/scanning/scan_result.h"
-#include "wificond/tests/offload_hal_test_constants.h"
-#include "wificond/tests/offload_test_utils.h"
-
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::ScanParam;
-using android::hardware::wifi::offload::V1_0::ScanFilter;
-using android::hardware::wifi::offload::V1_0::NetworkInfo;
-using android::hardware::wifi::offload::V1_0::ScanRecord;
-using android::hardware::wifi::offload::V1_0::ScanStats;
-using ::com::android::server::wifi::wificond::NativeScanResult;
-using ::com::android::server::wifi::wificond::NativeScanStats;
-using std::vector;
-
-using namespace android::wificond::offload_hal_test_constants;
-
-namespace android {
-namespace wificond {
-
-class OffloadScanUtilsTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- dummy_scan_results_ = OffloadTestUtils::createOffloadScanResults();
- }
-
- void TearDown() override { dummy_scan_results_.clear(); }
-
- vector<ScanResult> dummy_scan_results_;
-};
-
-TEST_F(OffloadScanUtilsTest, verifyConversion) {
- vector<NativeScanResult> native_scan_results;
- EXPECT_TRUE(OffloadScanUtils::convertToNativeScanResults(
- dummy_scan_results_, &native_scan_results));
- EXPECT_EQ(native_scan_results.size(), dummy_scan_results_.size());
- for (size_t i = 0; i < native_scan_results.size(); i++) {
- EXPECT_EQ(native_scan_results[i].frequency,
- dummy_scan_results_[i].frequency);
- EXPECT_EQ(native_scan_results[i].signal_mbm, dummy_scan_results_[i].rssi);
- EXPECT_EQ(native_scan_results[i].ssid.size(),
- dummy_scan_results_[i].networkInfo.ssid.size());
- EXPECT_EQ(native_scan_results[i].bssid.size(),
- dummy_scan_results_[i].bssid.elementCount());
- EXPECT_EQ(native_scan_results[i].capability,
- dummy_scan_results_[i].capability);
- }
-}
-
-TEST_F(OffloadScanUtilsTest, verifyScanParam) {
- vector<vector<uint8_t>> scan_ssids{kSsid1, kSsid2};
- vector<uint32_t> frequencies{kFrequency1, kFrequency2};
- ScanParam scanParam = OffloadScanUtils::createScanParam(
- scan_ssids, frequencies, kDisconnectedModeScanIntervalMs);
- EXPECT_EQ(scanParam.disconnectedModeScanIntervalMs,
- kDisconnectedModeScanIntervalMs);
- for (size_t i = 0; i < frequencies.size(); i++) {
- EXPECT_EQ(scanParam.frequencyList[i], frequencies[i]);
- }
- for (size_t j = 0; j < scan_ssids.size(); j++) {
- vector<uint8_t> ssid_result = scanParam.ssidList[j];
- vector<uint8_t> ssid_input = scan_ssids[j];
- for (size_t k = 0; k < ssid_result.size(); k++) {
- EXPECT_EQ(ssid_result[k], ssid_input[k]);
- }
- }
-}
-
-TEST_F(OffloadScanUtilsTest, verifyScanFilter) {
- vector<vector<uint8_t>> match_ssids{kSsid1, kSsid2};
- vector<uint8_t> security_flags{kNetworkFlags, kNetworkFlags};
- ScanFilter scanFilter = OffloadScanUtils::createScanFilter(
- match_ssids, security_flags, kRssiThreshold);
- EXPECT_EQ(kRssiThreshold, scanFilter.rssiThreshold);
- EXPECT_FALSE(scanFilter.preferredNetworkInfoList.size() == 0);
- for (size_t i = 0; i < security_flags.size(); ++i) {
- NetworkInfo nwInfo = scanFilter.preferredNetworkInfoList[i];
- vector<uint8_t> ssid = nwInfo.ssid;
- vector<uint8_t> match_ssid = match_ssids[i];
- EXPECT_EQ(nwInfo.flags, security_flags[i]);
- for (size_t j = 0; j < ssid.size(); j++) {
- EXPECT_EQ(ssid[j], match_ssid[j]);
- }
- }
-}
-
-TEST_F(OffloadScanUtilsTest, verifyScanStats) {
- NativeScanStats stats_expected;
- ScanStats offload_scan_stats =
- OffloadTestUtils::createScanStats(&stats_expected);
- NativeScanStats stats_returned =
- OffloadScanUtils::convertToNativeScanStats(offload_scan_stats);
- EXPECT_TRUE(stats_expected == stats_returned);
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/offload_test_utils.cpp b/tests/offload_test_utils.cpp
deleted file mode 100644
index 2b2acd8..0000000
--- a/tests/offload_test_utils.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vector>
-
-#include "wificond/tests/offload_hal_test_constants.h"
-#include "wificond/tests/offload_test_utils.h"
-
-using android::hardware::wifi::offload::V1_0::ScanResult;
-using android::hardware::wifi::offload::V1_0::ScanStats;
-using android::hardware::wifi::offload::V1_0::ScanRecord;
-using android::hardware::wifi::offload::V1_0::OffloadStatus;
-using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
-
-using ::com::android::server::wifi::wificond::NativeScanResult;
-using ::com::android::server::wifi::wificond::NativeScanStats;
-
-using namespace android::wificond::offload_hal_test_constants;
-
-namespace android {
-namespace wificond {
-
-std::vector<ScanResult> OffloadTestUtils::createOffloadScanResults() {
- std::vector<ScanResult> scanResults;
- ScanResult scanResult;
- std::vector<uint8_t> ssid(kSsid1, kSsid1 + kSsid1_size);
- scanResult.tsf = kTsf;
- scanResult.rssi = kRssi;
- scanResult.frequency = kFrequency1;
- scanResult.capability = kCapability;
- memcpy(&scanResult.bssid[0], &kBssid[0], kBssidSize);
- scanResult.networkInfo.ssid = ssid;
- scanResult.networkInfo.flags = kNetworkFlags;
- scanResults.push_back(scanResult);
- return scanResults;
-}
-
-ScanStats OffloadTestUtils::createScanStats(NativeScanStats* nativeScanStats) {
- std::vector<ScanRecord> scan_records;
- std::vector<uint8_t> histogram_channels;
- uint32_t scan_duration_ms = 0;
- uint32_t num_channels_scanned = 0;
- ScanStats scan_stats;
- int numEntriesInScanRecord =
- sizeof(kNumChannelsScanned) / sizeof(kNumChannelsScanned[0]);
- for (int i = 0; i < numEntriesInScanRecord; i++) {
- ScanRecord scan_record;
- scan_record.durationMs = kScanDurationMs[i];
- scan_duration_ms += kScanDurationMs[i];
- scan_record.numChannelsScanned = kNumChannelsScanned[i];
- num_channels_scanned += kNumChannelsScanned[i];
- scan_record.numEntriesAggregated = 1;
- scan_records.push_back(scan_record);
- }
- scan_stats.scanRecord = scan_records;
- scan_stats.numScansRequestedByWifi = kDefaultNumScansRequestedByWifi;
- scan_stats.numScansServicedByWifi = kDefaultNumScansServicedByWifi;
- scan_stats.subscriptionDurationMs = kSubscriptionDurationMs;
- uint32_t skip_tmp = 256 / num_channels_scanned;
- for (size_t i = 0; i < 256; i++) {
- if (i % skip_tmp == 0) {
- scan_stats.histogramChannelsScanned[i] =
- kDefaultNumTimesAChannelsIsScanned;
- histogram_channels.push_back(kDefaultNumTimesAChannelsIsScanned);
- } else {
- scan_stats.histogramChannelsScanned[i] = kChannelNotScanned;
- histogram_channels.push_back(kChannelNotScanned);
- }
- }
- NativeScanStats native_scan_stats(kDefaultNumScansRequestedByWifi,
- kDefaultNumScansServicedByWifi,
- kSubscriptionDurationMs, scan_duration_ms,
- num_channels_scanned, histogram_channels);
- *nativeScanStats = native_scan_stats;
- return scan_stats;
-}
-
-OffloadStatus OffloadTestUtils::createOffloadStatus(OffloadStatusCode code) {
- return createOffloadStatus(code, "");
-}
-
-OffloadStatus OffloadTestUtils::createOffloadStatus(OffloadStatusCode code,
- const std::string& desc) {
- return {code, desc};
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/offload_test_utils.h b/tests/offload_test_utils.h
deleted file mode 100644
index f2370e2..0000000
--- a/tests/offload_test_utils.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef WIFICOND_OFFLOAD_TEST_UTILS_H_
-#define WIFICOND_OFFLOAD_TEST_UTILS_H_
-
-#include <android/hardware/wifi/offload/1.0/IOffload.h>
-#include <vector>
-
-#include "wificond/scanning/offload/scan_stats.h"
-#include "wificond/scanning/scan_result.h"
-
-namespace android {
-namespace wificond {
-
-class OffloadTestUtils {
- public:
- static std::vector<android::hardware::wifi::offload::V1_0::ScanResult>
- createOffloadScanResults();
- static android::hardware::wifi::offload::V1_0::ScanStats createScanStats(
- ::com::android::server::wifi::wificond::
- NativeScanStats* /* nativeScanStats */);
- static android::hardware::wifi::offload::V1_0::OffloadStatus
- createOffloadStatus(
- android::hardware::wifi::offload::V1_0::OffloadStatusCode code);
- static android::hardware::wifi::offload::V1_0::OffloadStatus
- createOffloadStatus(
- android::hardware::wifi::offload::V1_0::OffloadStatusCode code,
- const std::string& desc);
-};
-
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_OFFLOAD_TEST_UTILS_H
diff --git a/tests/scan_stats_unittest.cpp b/tests/scan_stats_unittest.cpp
deleted file mode 100644
index 6eb72d6..0000000
--- a/tests/scan_stats_unittest.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2017, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#include "wificond/scanning/offload/scan_stats.h"
-#include "wificond/tests/offload_hal_test_constants.h"
-
-using ::com::android::server::wifi::wificond::NativeScanStats;
-using namespace android::wificond::offload_hal_test_constants;
-
-namespace android {
-namespace wificond {
-
-class ScanStatsTest : public ::testing::Test {};
-
-TEST_F(ScanStatsTest, ParcelableTest) {
- std::vector<uint8_t> histogram_channels;
- for (size_t i = 0; i < kNumChannelsInHistogram; i++) {
- histogram_channels.push_back(kNumChannelsInHistogram - 1 - i);
- }
- NativeScanStats scan_stats_in(kDefaultNumScansRequestedByWifi,
- kDefaultNumScansServicedByWifi,
- kScanDurationTotalMs, kSubscriptionDurationMs,
- kNumChannelsTotalScanned, histogram_channels);
- Parcel parcel;
- EXPECT_EQ(::android::OK, scan_stats_in.writeToParcel(&parcel));
- NativeScanStats scan_stats_out;
- parcel.setDataPosition(0);
- EXPECT_EQ(::android::OK, scan_stats_out.readFromParcel(&parcel));
- EXPECT_TRUE(scan_stats_in == scan_stats_out);
-}
-
-} // namespace wificond
-} // namespace android
diff --git a/tests/scanner_unittest.cpp b/tests/scanner_unittest.cpp
index 39a591e..4d2ebdf 100644
--- a/tests/scanner_unittest.cpp
+++ b/tests/scanner_unittest.cpp
@@ -20,16 +20,11 @@
#include <gtest/gtest.h>
#include <wifi_system_test/mock_interface_tool.h>
#include "android/net/wifi/IWifiScannerImpl.h"
-#include "wificond/scanning/offload/offload_scan_utils.h"
#include "wificond/scanning/scanner_impl.h"
#include "wificond/tests/mock_client_interface_impl.h"
#include "wificond/tests/mock_netlink_manager.h"
#include "wificond/tests/mock_netlink_utils.h"
-#include "wificond/tests/mock_offload_scan_callback_interface_impl.h"
-#include "wificond/tests/mock_offload_scan_manager.h"
-#include "wificond/tests/mock_offload_service_utils.h"
#include "wificond/tests/mock_scan_utils.h"
-#include "wificond/tests/offload_test_utils.h"
using ::android::binder::Status;
using ::android::net::wifi::IWifiScannerImpl;
@@ -38,7 +33,6 @@
using ::com::android::server::wifi::wificond::PnoNetwork;
using ::com::android::server::wifi::wificond::PnoSettings;
using ::com::android::server::wifi::wificond::NativeScanResult;
-using android::hardware::wifi::offload::V1_0::ScanResult;
using ::testing::Eq;
using ::testing::Invoke;
using ::testing::NiceMock;
@@ -105,36 +99,10 @@
*out_req_flags = req_flags;
return true;
}
-
-bool ReturnOffloadScanResults(
- std::vector<NativeScanResult>* native_scan_results_,
- const std::vector<ScanResult>& offload_scan_results) {
- return OffloadScanUtils::convertToNativeScanResults(offload_scan_results,
- native_scan_results_);
-}
-
-bool ReturnNetlinkScanResults(
- uint32_t interface_index,
- std::vector<NativeScanResult>* native_scan_results_,
- const std::vector<ScanResult>& offload_scan_results) {
- return OffloadScanUtils::convertToNativeScanResults(offload_scan_results,
- native_scan_results_);
-}
-
} // namespace
class ScannerTest : public ::testing::Test {
protected:
- void SetUp() override {
- ON_CALL(*offload_service_utils_, GetOffloadScanManager(_, _))
- .WillByDefault(Return(offload_scan_manager_));
- ON_CALL(*offload_service_utils_, GetOffloadScanCallbackInterface(_))
- .WillByDefault(Return(offload_scan_callback_interface_));
- dummy_scan_results_ = OffloadTestUtils::createOffloadScanResults();
- }
-
- void TearDown() override { dummy_scan_results_.clear(); }
-
unique_ptr<ScannerImpl> scanner_impl_;
NiceMock<MockNetlinkManager> netlink_manager_;
NiceMock<MockNetlinkUtils> netlink_utils_{&netlink_manager_};
@@ -142,18 +110,8 @@
NiceMock<MockInterfaceTool> if_tool_;
NiceMock<MockClientInterfaceImpl> client_interface_impl_{
&if_tool_, &netlink_utils_, &scan_utils_};
- shared_ptr<NiceMock<MockOffloadServiceUtils>> offload_service_utils_{
- new NiceMock<MockOffloadServiceUtils>()};
- shared_ptr<NiceMock<MockOffloadScanCallbackInterfaceImpl>>
- offload_scan_callback_interface_{
- new NiceMock<MockOffloadScanCallbackInterfaceImpl>(
- scanner_impl_.get())};
- std::shared_ptr<NiceMock<MockOffloadScanManager>> offload_scan_manager_{
- new NiceMock<MockOffloadScanManager>(offload_service_utils_,
- offload_scan_callback_interface_)};
ScanCapabilities scan_capabilities_;
WiphyFeatures wiphy_features_;
- std::vector<ScanResult> dummy_scan_results_;
};
TEST_F(ScannerTest, TestSingleScan) {
@@ -164,7 +122,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &success).isOk());
EXPECT_TRUE(success);
}
@@ -176,7 +134,7 @@
wiphy_features_.supports_low_span_oneshot_scan = true;
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_LOW_SPAN;
bool success = false;
@@ -191,7 +149,7 @@
wiphy_features_.supports_low_power_oneshot_scan = true;
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_LOW_POWER;
bool success = false;
@@ -206,7 +164,7 @@
wiphy_features_.supports_high_accuracy_oneshot_scan = true;
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY;
bool success = false;
@@ -220,7 +178,7 @@
WillOnce(Return(true));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_LOW_SPAN;
bool success = false;
@@ -234,7 +192,7 @@
WillOnce(Return(true));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_LOW_POWER;
bool success = false;
@@ -248,7 +206,7 @@
WillOnce(Return(true));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SingleScanSettings settings;
settings.scan_type_ = IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY;
bool success = false;
@@ -260,7 +218,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
EXPECT_CALL(
scan_utils_,
Scan(_, _, _, _, _, _)).
@@ -277,7 +235,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
ON_CALL(
scan_utils_,
Scan(_, _, _, _, _, _)).
@@ -295,7 +253,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
EXPECT_CALL(scan_utils_, Scan(_, _, _, _, _, _))
.WillOnce(Return(true));
EXPECT_TRUE(
@@ -310,7 +268,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
EXPECT_CALL(scan_utils_, AbortScan(_)).Times(0);
EXPECT_TRUE(scanner_impl_->abortScan().isOk());
}
@@ -320,19 +278,16 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
EXPECT_CALL(scan_utils_, GetScanResult(_, _)).WillOnce(Return(true));
EXPECT_TRUE(scanner_impl_->getScanResults(&scan_results).isOk());
}
TEST_F(ScannerTest, TestStartPnoScanViaNetlink) {
bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
EXPECT_CALL(
scan_utils_,
StartScheduledScan(_, _, _, _, _, _, _, _, _)).
@@ -343,13 +298,10 @@
TEST_F(ScannerTest, TestStartPnoScanViaNetlinkWithLowPowerScanWiphySupport) {
bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
wiphy_features_.supports_low_power_oneshot_scan = true;
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
SchedScanReqFlags req_flags = {};
EXPECT_CALL(
scan_utils_,
@@ -364,13 +316,10 @@
TEST_F(ScannerTest, TestStopPnoScanViaNetlink) {
bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
// StopScheduledScan() will be called no matter if there is an ongoing
// scheduled scan or not. This is for making the system more robust.
EXPECT_CALL(scan_utils_, StopScheduledScan(_)).WillOnce(Return(true));
@@ -378,136 +327,6 @@
EXPECT_TRUE(success);
}
-TEST_F(ScannerTest, TestStartScanOverOffload) {
- bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, startScan(_, _, _, _, _, _, _))
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, stopScan(_))
- .Times(1)
- .WillRepeatedly(Return(true));
- scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
- scan_capabilities_, wiphy_features_,
- &client_interface_impl_,
- &scan_utils_, offload_service_utils_));
- scanner_impl_->startPnoScan(PnoSettings(), &success);
- EXPECT_TRUE(success);
- scanner_impl_->stopPnoScan(&success);
- EXPECT_TRUE(success);
-}
-
-TEST_F(ScannerTest, TestStartScanOverNetlinkFallback) {
- bool success = false;
- ON_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .WillByDefault(Return(true));
- scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
- scan_capabilities_, wiphy_features_,
- &client_interface_impl_,
- &scan_utils_, offload_service_utils_));
- EXPECT_CALL(*offload_scan_manager_, startScan(_, _, _, _, _, _, _))
- .WillOnce(Return(false));
- EXPECT_CALL(*offload_scan_manager_, stopScan(_)).Times(0);
- EXPECT_CALL(scan_utils_, StartScheduledScan(_, _, _, _, _, _, _, _, _))
- .WillOnce(Return(true));
- EXPECT_CALL(scan_utils_, StopScheduledScan(_)).WillOnce(Return(true));
- EXPECT_TRUE(scanner_impl_->startPnoScan(PnoSettings(), &success).isOk());
- EXPECT_TRUE(success == true);
- scanner_impl_->stopPnoScan(&success);
- EXPECT_TRUE(success);
-}
-
-TEST_F(ScannerTest, TestAsyncErrorOverOffload) {
- bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, startScan(_, _, _, _, _, _, _))
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, stopScan(_))
- .Times(1)
- .WillRepeatedly(Return(true));
- scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
- scan_capabilities_, wiphy_features_,
- &client_interface_impl_,
- &scan_utils_, offload_service_utils_));
- EXPECT_CALL(scan_utils_, StartScheduledScan(_, _, _, _, _, _, _, _, _))
- .WillOnce(Return(true));
- EXPECT_CALL(scan_utils_, StopScheduledScan(_)).WillOnce(Return(true));
- scanner_impl_->startPnoScan(PnoSettings(), &success);
- EXPECT_TRUE(success);
- scanner_impl_->OnOffloadError(
- OffloadScanCallbackInterface::AsyncErrorReason::REMOTE_FAILURE);
- scanner_impl_->stopPnoScan(&success);
- EXPECT_TRUE(success);
-}
-
-TEST_F(ScannerTest, TestGetScanResultsFromOffload) {
- bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, startScan(_, _, _, _, _, _, _))
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, getScanResults(_))
- .Times(1)
- .WillOnce(
- Invoke(bind(ReturnOffloadScanResults, _1, dummy_scan_results_)));
- EXPECT_CALL(*offload_scan_manager_, stopScan(_))
- .Times(1)
- .WillRepeatedly(Return(true));
- scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
- scan_capabilities_, wiphy_features_,
- &client_interface_impl_,
- &scan_utils_, offload_service_utils_));
- scanner_impl_->startPnoScan(PnoSettings(), &success);
- EXPECT_TRUE(success);
- scanner_impl_->OnOffloadScanResult();
- std::vector<NativeScanResult> scan_results;
- EXPECT_TRUE(scanner_impl_->getPnoScanResults(&scan_results).isOk());
- EXPECT_FALSE(scan_results.empty());
- scanner_impl_->stopPnoScan(&success);
- EXPECT_TRUE(success);
-}
-
-TEST_F(ScannerTest, TestGetScanResultsWhenOffloadFails) {
- bool success = false;
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, startScan(_, _, _, _, _, _, _))
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, stopScan(_))
- .Times(1)
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*offload_scan_manager_, getScanResults(_)).Times(0);
- EXPECT_CALL(scan_utils_, GetScanResult(_, _))
- .Times(1)
- .WillOnce(
- Invoke(bind(ReturnNetlinkScanResults, _1, _2, dummy_scan_results_)));
- scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
- scan_capabilities_, wiphy_features_,
- &client_interface_impl_,
- &scan_utils_, offload_service_utils_));
- EXPECT_CALL(scan_utils_, StartScheduledScan(_, _, _, _, _, _, _, _, _))
- .WillOnce(Return(true));
- EXPECT_CALL(scan_utils_, StopScheduledScan(_)).WillOnce(Return(true));
- EXPECT_TRUE(scanner_impl_->startPnoScan(PnoSettings(), &success).isOk());
- EXPECT_TRUE(success);
- scanner_impl_->OnOffloadError(
- OffloadScanCallbackInterface::AsyncErrorReason::REMOTE_FAILURE);
- std::vector<NativeScanResult> scan_results;
- EXPECT_TRUE(scanner_impl_->getPnoScanResults(&scan_results).isOk());
- EXPECT_FALSE(scan_results.empty());
- scanner_impl_->stopPnoScan(&success);
- EXPECT_TRUE(success);
-}
-
TEST_F(ScannerTest, TestGenerateScanPlansIfDeviceSupports) {
ScanCapabilities scan_capabilities_scan_plan_supported(
0 /* max_num_scan_ssids */,
@@ -521,7 +340,7 @@
kFakeInterfaceIndex,
scan_capabilities_scan_plan_supported, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
pno_settings.interval_ms_ = kFakeScanIntervalMs;
@@ -555,7 +374,7 @@
kFakeInterfaceIndex,
scan_capabilities_no_scan_plan_support, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
pno_settings.interval_ms_ = kFakeScanIntervalMs;
@@ -579,7 +398,7 @@
scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
scan_capabilities_, wiphy_features_,
&client_interface_impl_,
- &scan_utils_, offload_service_utils_));
+ &scan_utils_));
scanner_impl_->Invalidate();
EXPECT_CALL(scan_utils_, GetScanResult(_, _))
.Times(0)
@@ -597,12 +416,9 @@
0,
kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
PnoSettings::kFastScanIterations);
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
PnoNetwork network;
@@ -631,12 +447,9 @@
0,
kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
PnoSettings::kFastScanIterations);
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
PnoNetwork network;
@@ -673,12 +486,9 @@
0,
kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
PnoSettings::kFastScanIterations);
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
PnoNetwork network;
@@ -712,12 +522,9 @@
0,
kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
PnoSettings::kFastScanIterations);
- EXPECT_CALL(*offload_service_utils_, IsOffloadScanSupported())
- .Times(1)
- .WillRepeatedly(Return(false));
ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
wiphy_features_, &client_interface_impl_,
- &scan_utils_, offload_service_utils_);
+ &scan_utils_);
PnoSettings pno_settings;
PnoNetwork network;