LOCAL_SRC_FILES := \
main.cpp
LOCAL_SHARED_LIBRARIES := \
+ android.hardware.wifi.offload@1.0 \
libbinder \
libbase \
libcutils \
+ libhidlbase \
+ libhwbinder \
+ libhidltransport \
libminijail \
libutils \
libwifi-system
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
LOCAL_SHARED_LIBRARIES := \
+ android.hardware.wifi.offload@1.0 \
libbase \
libutils \
+ libhidlbase \
+ libhwbinder \
+ libhidltransport \
libwifi-system
LOCAL_WHOLE_STATIC_LIBRARIES := \
libwificond_ipc \
libwificond \
libwificond_nl
LOCAL_SHARED_LIBRARIES := \
+ android.hardware.wifi.offload@1.0 \
libbase \
libbinder \
+ libhidltransport \
+ libhidlbase \
+ libhwbinder \
liblog \
libutils \
libwifi-system
--- /dev/null
+/*
+ * 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::hidl_vec;
+using ::android::hardware::Return;
+
+namespace android {
+namespace wificond {
+
+OffloadCallback::OffloadCallback(OnOffloadScanResultsReadyHandler handler)
+ : scan_result_handler_(handler) {
+}
+
+// Methods from ::android::hardware::wifi::offload::V1_0::IOffloadCallback follow.
+Return<void> OffloadCallback::onScanResult(const hidl_vec<ScanResult>& scan_result) {
+ if (scan_result_handler_ != nullptr) {
+ scan_result_handler_(std::vector<ScanResult>(scan_result));
+ } else {
+ LOG(WARNING) << "No handler available for Offload scan results";
+ }
+ return Void();
+}
+
+OffloadCallback::~OffloadCallback() {}
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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>
+
+namespace android {
+namespace wificond {
+
+using ::android::hardware::hidl_vec;
+using ::android::hardware::wifi::offload::V1_0::IOffloadCallback;
+using ::android::hardware::wifi::offload::V1_0::ScanResult;
+using ::android::hardware::Void;
+using ::android::hidl::base::V1_0::IBase;
+
+typedef std::function<void(
+ const std::vector<ScanResult>& scanResult)> OnOffloadScanResultsReadyHandler;
+
+class OffloadCallback : public IOffloadCallback {
+ public:
+ explicit OffloadCallback(OnOffloadScanResultsReadyHandler handler);
+ virtual ~OffloadCallback();
+
+ // Methods from ::android::hardware::wifi::offload::V1_0::IOffloadCallback follow.
+ ::android::hardware::Return<void> onScanResult(
+ const hidl_vec<ScanResult>& scanResult) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+
+ private:
+ OnOffloadScanResultsReadyHandler scan_result_handler_;
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOADCALLBACK_H
--- /dev/null
+/*
+ * 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/offload_scan_utils.h"
+#include "wificond/scanning/offload/offload_service_utils.h"
+#include "wificond/scanning/scan_result.h"
+
+using ::android::hardware::hidl_vec;
+using android::hardware::wifi::offload::V1_0::IOffload;
+using android::hardware::wifi::offload::V1_0::ScanResult;
+using android::wificond::OffloadCallback;
+using ::com::android::server::wifi::wificond::NativeScanResult;
+using android::wificond::OnNativeScanResultsReadyHandler;
+
+namespace android {
+namespace wificond {
+
+OffloadScanManager::OffloadScanManager(OffloadServiceUtils *utils,
+ OnNativeScanResultsReadyHandler handler)
+ : wifi_offload_hal_(nullptr),
+ wifi_offload_callback_(nullptr),
+ scan_result_handler_(handler) {
+ if (utils == nullptr) return;
+ if (scan_result_handler_ == nullptr) return;
+ wifi_offload_hal_ = utils->GetOffloadService();
+ if (wifi_offload_hal_ == nullptr) {
+ LOG(WARNING) << "No Offload Service available";
+ return;
+ }
+ wifi_offload_callback_ = utils->GetOffloadCallback(
+ std::bind(&OffloadScanManager::ReportScanResults, this,
+ std::placeholders::_1));
+ wifi_offload_hal_->setEventCallback(wifi_offload_callback_);
+}
+
+OffloadScanManager::~OffloadScanManager() {}
+
+void OffloadScanManager::ReportScanResults(
+ const std::vector<ScanResult> scanResult) {
+ if (scan_result_handler_ != nullptr) {
+ scan_result_handler_(OffloadScanUtils::convertToNativeScanResults(scanResult));
+ }
+}
+
+bool OffloadScanManager::isServiceAvailable() const {
+ return wifi_offload_hal_ != nullptr;
+}
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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_service_utils.h"
+
+#include <vector>
+
+using ::android::hardware::hidl_vec;
+using android::hardware::wifi::offload::V1_0::ScanResult;
+using android::hardware::wifi::offload::V1_0::IOffload;
+
+using std::unique_ptr;
+
+namespace com {
+namespace android {
+namespace server {
+namespace wifi {
+namespace wificond {
+
+class NativeScanResult;
+
+} // namespace wificond
+} // namespace wifi
+} // namespace server
+} // namespace android
+} // namespace com
+
+namespace android {
+namespace wificond {
+
+typedef std::function<void(
+ const std::vector<::com::android::server::wifi::wificond::NativeScanResult>
+ scanResult)> OnNativeScanResultsReadyHandler;
+
+// Provides methods to interact with Offload HAL
+class OffloadScanManager {
+ public:
+ explicit OffloadScanManager(OffloadServiceUtils* utils,
+ OnNativeScanResultsReadyHandler handler);
+ virtual ~OffloadScanManager();
+ bool isServiceAvailable() const;
+
+ private:
+ void ReportScanResults(const std::vector<ScanResult> scanResult);
+
+ android::sp<IOffload> wifi_offload_hal_;
+ android::sp<OffloadCallback> wifi_offload_callback_;
+ OnNativeScanResultsReadyHandler scan_result_handler_;
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_OFFLOAD_SCAN_MANAGER_H_
--- /dev/null
+/*
+ * 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 "wificond/scanning/scan_result.h"
+
+using ::com::android::server::wifi::wificond::NativeScanResult;
+using android::hardware::wifi::offload::V1_0::ScanResult;
+
+namespace android {
+namespace wificond {
+
+std::vector<NativeScanResult> OffloadScanUtils::convertToNativeScanResults(
+ const std::vector<ScanResult>& scanResult) {
+ std::vector<NativeScanResult> nativeScanResult;
+ nativeScanResult.reserve(scanResult.size());
+ for (size_t i = 0; i < scanResult.size(); i++) {
+ NativeScanResult singleScanResult;
+ singleScanResult.ssid = scanResult[i].networkInfo.ssid;
+ singleScanResult.bssid.assign(scanResult[i].networkInfo.ssid.begin(),
+ scanResult[i].networkInfo.ssid.end());
+ singleScanResult.frequency = scanResult[i].frequency;
+ singleScanResult.signal_mbm = scanResult[i].rssi;
+ singleScanResult.tsf = scanResult[i].tsf;
+ singleScanResult.capability = scanResult[i].capability;
+ singleScanResult.associated = false;
+ nativeScanResult.emplace_back(singleScanResult);
+ }
+ return nativeScanResult;
+}
+
+} // wificond
+} // android
+
--- /dev/null
+/*
+ * 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>
+
+using android::hardware::wifi::offload::V1_0::ScanResult;
+
+namespace com {
+namespace android {
+namespace server {
+namespace wifi {
+namespace wificond {
+
+class NativeScanResult;
+
+} // 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 std::vector<::com::android::server::wifi::wificond::NativeScanResult>
+ convertToNativeScanResults(const std::vector<ScanResult>&);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_OFFLOAD_SCAN_UTILS_H_
+
--- /dev/null
+/*
+ * 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"
+
+namespace android {
+namespace wificond {
+
+android::sp<IOffload> OffloadServiceUtils::GetOffloadService() {
+ return IOffload::getService();
+}
+
+android::sp<OffloadCallback> OffloadServiceUtils::GetOffloadCallback(
+ OnOffloadScanResultsReadyHandler handler) {
+ return new OffloadCallback(handler);
+}
+
+} // wificond
+} // android
+
--- /dev/null
+/*
+ * 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"
+
+using android::hardware::wifi::offload::V1_0::IOffload;
+
+namespace android {
+namespace wificond {
+
+// Provides methods to get Offload HAL service and create callback
+class OffloadServiceUtils {
+ public:
+ OffloadServiceUtils() = default;
+ virtual ~OffloadServiceUtils() = default;
+ virtual android::sp<IOffload> GetOffloadService();
+ virtual android::sp<OffloadCallback> GetOffloadCallback(
+ OnOffloadScanResultsReadyHandler handler);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_OFFLOAD_SERVICE_UTILS_H
+
#include "wificond/client_interface_impl.h"
#include "wificond/scanning/scan_utils.h"
+#include "wificond/scanning/offload/offload_service_utils.h"
+#include "wificond/scanning/offload/offload_scan_manager.h"
using android::binder::Status;
using android::net::wifi::IPnoScanEvent;
using android::net::wifi::IScanEvent;
+using android::hardware::wifi::offload::V1_0::IOffload;
using android::sp;
using com::android::server::wifi::wificond::NativeScanResult;
using com::android::server::wifi::wificond::PnoSettings;
std::bind(&ScannerImpl::OnSchedScanResultsReady,
this,
_1, _2));
+ offload_scan_manager_.reset(
+ new OffloadScanManager(new OffloadServiceUtils(),
+ std::bind(&ScannerImpl::OnOffloadScanResult,
+ this, _1)));
}
ScannerImpl::~ScannerImpl() {
LOG(WARNING) << prefix << ": " << ssid_list_string;
}
+void ScannerImpl::OnOffloadScanResult(
+ std::vector<NativeScanResult> scanResult) {
+ // TODO: Process scan result
+ if (scan_event_handler_ != nullptr) {
+ scan_event_handler_->OnScanResultReady();
+ } else {
+ LOG(WARNING) << "No scan event handler Offload Scan result";
+ }
+}
+
} // namespace wificond
} // namespace android
#include "android/net/wifi/BnWifiScannerImpl.h"
#include "wificond/net/netlink_utils.h"
+#include "wificond/scanning/offload/offload_scan_manager.h"
namespace android {
namespace wificond {
private:
bool CheckIsValid();
+ void OnOffloadScanResult(
+ std::vector<::com::android::server::wifi::wificond::NativeScanResult>);
void OnScanResultsReady(
uint32_t interface_index,
bool aborted,
ScanUtils* const scan_utils_;
::android::sp<::android::net::wifi::IPnoScanEvent> pno_scan_event_handler_;
::android::sp<::android::net::wifi::IScanEvent> scan_event_handler_;
+ std::unique_ptr<OffloadScanManager> offload_scan_manager_;
DISALLOW_COPY_AND_ASSIGN(ScannerImpl);
};