mirror of
https://github.com/Evolution-X-Devices/device_google_wahoo
synced 2026-02-01 15:09:54 +00:00
wifi_offload: Remove offload HAL server code
This is unused currently & there are no concrete plans to use it
in the future.
Bug: 130080335
Test: Device boots up & connects to networks.
Test: Will send for regression tests
Change-Id: Iaec2427603992e70a4ca1cef2f7cb96504d1374d
Merged-In: Iaec2427603992e70a4ca1cef2f7cb96504d1374d
(cherry picked from commit 2143fad65a)
This commit is contained in:
3
sepolicy/vendor/hal_wifi_offload_default.te
vendored
3
sepolicy/vendor/hal_wifi_offload_default.te
vendored
@@ -1,3 +0,0 @@
|
||||
# Allow Wifi Offload HAL to communicate with daemon via socket
|
||||
allow hal_wifi_offload_default chre:unix_stream_socket connectto;
|
||||
allow hal_wifi_offload_default chre_socket:sock_file write;
|
||||
@@ -1,99 +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.
|
||||
|
||||
cc_library_static {
|
||||
name: "android.hardware.wifi.offload@1.0-lib",
|
||||
vendor: true,
|
||||
srcs: ["Offload.cpp",
|
||||
"chre_constants.cpp",
|
||||
"chre_interface.cpp",
|
||||
"offload_server.cpp",
|
||||
"chre_interface_factory.cpp",
|
||||
"offload_status_util.cpp",
|
||||
"offload_utils.cpp",
|
||||
],
|
||||
cflags: ["-Wall", "-Wextra", "-Werror"],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.wifi.offload@1.0",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"chre_client",
|
||||
"wifi_offload_types",
|
||||
]
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.wifi.offload@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.wifi.offload@1.0-service.rc"],
|
||||
srcs: ["service.cpp"],
|
||||
cflags: ["-Wall", "-Wextra"],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.wifi.offload@1.0",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.wifi.offload@1.0-lib",
|
||||
],
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "wifi-offload-service-unit-tests",
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"test/main.cpp",
|
||||
"test/mock_chre_interface_callbacks.cpp",
|
||||
"test/mock_chre_interface_factory.cpp",
|
||||
"test/mock_chre_interface.cpp",
|
||||
"test/offload_server_test.cpp",
|
||||
"test/chre_interface_test.cpp",
|
||||
"test/offload_utils_test.cpp",
|
||||
"test/offload_hal_test_constants.cpp",
|
||||
"test/offload_hal_test_utils.cpp",
|
||||
],
|
||||
local_include_dirs: [
|
||||
"test",
|
||||
".",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libutils",
|
||||
"liblog",
|
||||
"android.hardware.wifi.offload@1.0",
|
||||
],
|
||||
static_libs: [
|
||||
"libgmock",
|
||||
"libgtest",
|
||||
"android.hardware.wifi.offload@1.0-lib",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"wifi_offload_types",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<configuration description="Config for wifi-offload-service-unit-tests">
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push" value="wifi-offload-service-unit-tests->/data/local/tmp/wifi-offload-service-unit-tests" />
|
||||
</target_preparer>
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="wifi-offload-service-unit-tests" />
|
||||
</test>
|
||||
</configuration>
|
||||
@@ -1,82 +0,0 @@
|
||||
#include "Offload.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "chre_interface_factory.h"
|
||||
#include "hidl_return_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using hidl_return_util::validateAndCall;
|
||||
|
||||
Offload::Offload()
|
||||
: mOffloadServer(new OffloadServer(new ChreInterfaceFactory())), cookie_(0),
|
||||
death_handler_(new HidlDeathHandler<IOffloadCallback>(
|
||||
std::bind(&Offload::onObjectDeath, this, std::placeholders::_1))) {
|
||||
LOG(android::base::INFO) << "Wifi Offload HAL impl";
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::wifi::offload::V1_0::IOffload follow.
|
||||
Return<void> Offload::configureScans(const ScanParam ¶m, const ScanFilter &filter,
|
||||
configureScans_cb _hidl_cb) {
|
||||
return validateAndCall(this, &Offload::configureScansInternal, _hidl_cb, param, filter);
|
||||
}
|
||||
|
||||
Return<void> Offload::getScanStats(getScanStats_cb _hidl_cb) {
|
||||
return validateAndCall(this, &Offload::getScanStatsInternal, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> Offload::subscribeScanResults(uint32_t delayMs, subscribeScanResults_cb _hidl_cb) {
|
||||
return validateAndCall(this, &Offload::subscribeScanResultsInternal, _hidl_cb, delayMs);
|
||||
}
|
||||
|
||||
Return<void> Offload::unsubscribeScanResults() {
|
||||
if (!mOffloadServer->unsubscribeScanResults()) {
|
||||
LOG(ERROR) << "Unable to unsubscribe";
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Offload::setEventCallback(const sp<IOffloadCallback>& cb) {
|
||||
if (!mOffloadServer->setEventCallback(cb)) {
|
||||
LOG(ERROR) << "No callback set";
|
||||
return Void();
|
||||
}
|
||||
cookie_ = reinterpret_cast<uint64_t>(cb.get());
|
||||
death_handler_->setCallback(cb);
|
||||
cb->linkToDeath(death_handler_, cookie_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
OffloadStatus Offload::configureScansInternal(const ScanParam ¶m, const ScanFilter &filter) {
|
||||
return mOffloadServer->configureScans(param, filter);
|
||||
}
|
||||
|
||||
std::pair<OffloadStatus, ScanStats> Offload::getScanStatsInternal() {
|
||||
return mOffloadServer->getScanStats();
|
||||
}
|
||||
|
||||
OffloadStatus Offload::subscribeScanResultsInternal(uint32_t delayMs) {
|
||||
return mOffloadServer->subscribeScanResults(delayMs);
|
||||
}
|
||||
|
||||
void Offload::onObjectDeath(uint64_t cookie) {
|
||||
if (cookie == cookie_) {
|
||||
LOG(DEBUG) << "OffloadCallback death notification received";
|
||||
mOffloadServer->clearEventCallback();
|
||||
cookie_ = 0;
|
||||
}
|
||||
}
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,87 +0,0 @@
|
||||
#ifndef ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H
|
||||
#define ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
|
||||
#include <android-base/macros.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include "offload_server.h"
|
||||
|
||||
namespace {
|
||||
// Type of callback invoked by the death handler.
|
||||
using on_death_cb_function = std::function<void(uint64_t)>;
|
||||
|
||||
// Private class used to keep track of death of callbacks
|
||||
template<typename CallbackType>
|
||||
class HidlDeathHandler : public android::hardware::hidl_death_recipient {
|
||||
public:
|
||||
HidlDeathHandler(const on_death_cb_function &user_cb_function)
|
||||
: cb_function_(user_cb_function) {
|
||||
}
|
||||
~HidlDeathHandler() = default;
|
||||
|
||||
// Death notification for callbacks.
|
||||
void serviceDied(uint64_t cookie,
|
||||
const android::wp<android::hidl::base::V1_0::IBase>& /* who */) override {
|
||||
cb_.clear();
|
||||
cb_function_(cookie);
|
||||
}
|
||||
|
||||
void setCallback(android::wp<CallbackType> cb) {
|
||||
cb_ = cb;
|
||||
}
|
||||
|
||||
private:
|
||||
android::wp<CallbackType> cb_;
|
||||
on_death_cb_function cb_function_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(HidlDeathHandler);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
/**
|
||||
* Interface object to communicate with Offload HAL
|
||||
*/
|
||||
class Offload : public IOffload {
|
||||
public:
|
||||
Offload();
|
||||
|
||||
// Methods from ::android::hardware::wifi::offload::V1_0::IOffload follow.
|
||||
Return<void> configureScans(const ScanParam ¶m, const ScanFilter &filter,
|
||||
configureScans_cb _hidl_cb) override;
|
||||
Return<void> getScanStats(getScanStats_cb _hidl_cb) override;
|
||||
Return<void> subscribeScanResults(uint32_t delayMs, subscribeScanResults_cb _hidl_cb) override;
|
||||
Return<void> unsubscribeScanResults() override;
|
||||
Return<void> setEventCallback(const sp<IOffloadCallback>& cb) override;
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
private:
|
||||
OffloadStatus configureScansInternal(const ScanParam ¶m, const ScanFilter &filter);
|
||||
std::pair<OffloadStatus, ScanStats> getScanStatsInternal();
|
||||
OffloadStatus subscribeScanResultsInternal(uint32_t delayMs);
|
||||
void onObjectDeath(uint64_t cookie);
|
||||
|
||||
std::unique_ptr<OffloadServer> mOffloadServer;
|
||||
uint64_t cookie_;
|
||||
sp<HidlDeathHandler<IOffloadCallback>> death_handler_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Offload);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H
|
||||
@@ -1,4 +0,0 @@
|
||||
service vendor.offload-hal-1-0 /vendor/bin/hw/android.hardware.wifi.offload@1.0-service
|
||||
class hal
|
||||
user wifi
|
||||
group wifi system
|
||||
@@ -1,27 +0,0 @@
|
||||
#include "chre_constants.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace chre_constants {
|
||||
|
||||
const char kSocketName[] = "chre";
|
||||
const uint64_t kWifiOffloadNanoAppId = 5147455389092024332;
|
||||
const uint32_t kMaxMessageLen = 2048;
|
||||
const uint32_t kHubInfoRequestBufLen = 64;
|
||||
const uint32_t kNanoAppListRequestBufLen = 64;
|
||||
const uint32_t kSubscriptionDelayMsBufLen = 4;
|
||||
const uint32_t kNanosecondsPerMillisecond = 1e6;
|
||||
const size_t kBssidLen = 6;
|
||||
const size_t kHistogramChannels = 256;
|
||||
|
||||
} // namespace chre_constants
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef WIFI_OFFLOAD_CHRE_CONSTANTS_H_
|
||||
#define WIFI_OFFLOAD_CHRE_CONSTANTS_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace chre_constants {
|
||||
|
||||
extern const char kSocketName[];
|
||||
extern const uint64_t kWifiOffloadNanoAppId;
|
||||
extern const uint32_t kMaxMessageLen;
|
||||
extern const uint32_t kHubInfoRequestBufLen;
|
||||
extern const uint32_t kNanoAppListRequestBufLen;
|
||||
extern const uint32_t kSubscriptionDelayMsBufLen;
|
||||
extern const uint32_t kNanosecondsPerMillisecond;
|
||||
extern const size_t kHistogramChannels;
|
||||
extern const size_t kBssidLen;
|
||||
|
||||
} // namespace chre_constants
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_CHRE_CONSTANTS_H_
|
||||
@@ -1,209 +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 "chre_interface.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "chre_host/host_protocol_host.h"
|
||||
|
||||
using android::chre::getStringFromByteVector;
|
||||
using android::chre::HostProtocolHost;
|
||||
using flatbuffers::FlatBufferBuilder;
|
||||
|
||||
namespace chre_constants = android::hardware::wifi::offload::V1_0::implementation::chre_constants;
|
||||
|
||||
namespace fbs = ::chre::fbs;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
SocketCallbacks::SocketCallbacks(ChreInterface* parent) : mParent(parent) {
|
||||
}
|
||||
|
||||
void SocketCallbacks::onMessageReceived(const void* data, size_t length) {
|
||||
LOG(VERBOSE) << "Message received from CHRE socket";
|
||||
if (!HostProtocolHost::decodeMessageFromChre(data, length, *this)) {
|
||||
LOG(WARNING) << "Failed to decode message";
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCallbacks::onConnected() {
|
||||
LOG(INFO) << "Connected to CHRE socket";
|
||||
mParent->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTED);
|
||||
}
|
||||
|
||||
void SocketCallbacks::onConnectionAborted() {
|
||||
LOG(WARNING) << "Connection to CHRE socket Aborted";
|
||||
mParent->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTION_ABORT);
|
||||
}
|
||||
|
||||
void SocketCallbacks::onDisconnected() {
|
||||
LOG(WARNING) << "Disconnected from CHRE socket";
|
||||
mParent->reportConnectionEvent(ChreInterfaceCallbacks::DISCONNECTED);
|
||||
}
|
||||
|
||||
void SocketCallbacks::handleNanoappMessage(const fbs::NanoappMessageT& message) {
|
||||
LOG(VERBOSE) << "handleNanoappMessage from appId: " << message.app_id;
|
||||
LOG(VERBOSE) << "HostEndPoint: " << message.host_endpoint;
|
||||
if (message.app_id == chre_constants::kWifiOffloadNanoAppId) {
|
||||
mParent->handleMessage(message.message_type, message.message.data(), message.message.size());
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCallbacks::handleHubInfoResponse(const fbs::HubInfoResponseT& response) {
|
||||
LOG(VERBOSE) << "Hub Info response";
|
||||
LOG(VERBOSE) << "Hub Info name: " << getStringFromByteVector(response.name);
|
||||
LOG(VERBOSE) << "Version : " << response.chre_platform_version;
|
||||
LOG(VERBOSE) << "Legacy Platform Version: " << response.platform_version;
|
||||
LOG(VERBOSE) << "Legacy Toolchain Version: " << response.toolchain_version;
|
||||
LOG(VERBOSE) << "Peak Mips: " << response.peak_mips;
|
||||
LOG(VERBOSE) << "Stopped Power: " << response.stopped_power;
|
||||
LOG(VERBOSE) << "Sleep Power: " << response.sleep_power;
|
||||
LOG(VERBOSE) << "Peak Power: " << response.peak_power;
|
||||
LOG(VERBOSE) << "Platform ID: " << response.platform_id;
|
||||
LOG(VERBOSE) << "Vendor : " << getStringFromByteVector(response.vendor);
|
||||
LOG(VERBOSE) << "Toolchain : " << getStringFromByteVector(response.toolchain);
|
||||
LOG(VERBOSE) << "maxMessageLen : " << response.max_msg_len;
|
||||
if (response.max_msg_len < chre_constants::kMaxMessageLen) {
|
||||
LOG(WARNING) << "Incorrect max message length";
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCallbacks::handleNanoappListResponse(const fbs::NanoappListResponseT& response) {
|
||||
LOG(VERBOSE) << "handleNanoAppListResponse";
|
||||
for (const std::unique_ptr<fbs::NanoappListEntryT>& nanoapp : response.nanoapps) {
|
||||
if (nanoapp == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (nanoapp->app_id == chre_constants::kWifiOffloadNanoAppId && nanoapp->enabled) {
|
||||
LOG(INFO) << "Wifi Offload Nano app found";
|
||||
LOG(INFO) << "Version: " << nanoapp->version;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCallbacks::handleLoadNanoappResponse(const fbs::LoadNanoappResponseT& response) {
|
||||
LOG(VERBOSE) << "Load Nano app response";
|
||||
LOG(VERBOSE) << "Transaction ID: " << response.transaction_id;
|
||||
LOG(VERBOSE) << "Status: " << response.success;
|
||||
}
|
||||
|
||||
void SocketCallbacks::handleUnloadNanoappResponse(const fbs::UnloadNanoappResponseT& response) {
|
||||
LOG(VERBOSE) << "Unload Nano app response";
|
||||
LOG(VERBOSE) << "Transaction ID: " << response.transaction_id;
|
||||
LOG(VERBOSE) << "Status: " << response.success;
|
||||
}
|
||||
|
||||
ChreInterface::ChreInterface(ChreInterfaceCallbacks* callback)
|
||||
: mSocketCallbacks(new SocketCallbacks(this)), mServerCallbacks(callback),
|
||||
mSocketConnected(false) {
|
||||
if (!mClient.connectInBackground(chre_constants::kSocketName, mSocketCallbacks)) {
|
||||
LOG(ERROR) << "Offload HAL is not connected to Chre";
|
||||
}
|
||||
}
|
||||
|
||||
ChreInterface::~ChreInterface() {
|
||||
mClient.disconnect();
|
||||
}
|
||||
|
||||
bool ChreInterface::isConnected() {
|
||||
std::lock_guard<std::mutex> lock(mChreInterfaceLock);
|
||||
return mSocketConnected;
|
||||
}
|
||||
|
||||
void ChreInterface::reportConnectionEvent(ChreInterfaceCallbacks::ConnectionEvent event) {
|
||||
bool connectionStatus = false;
|
||||
switch (event) {
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTED:
|
||||
connectionStatus = true;
|
||||
if (!getHubInfo() || !getNanoAppList()) {
|
||||
LOG(WARNING) << "Unable to get platform and nano app info";
|
||||
}
|
||||
break;
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::DISCONNECTED:
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTION_ABORT:
|
||||
break;
|
||||
default:
|
||||
LOG(WARNING) << "Invalid connection event recieved";
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mChreInterfaceLock);
|
||||
mSocketConnected = connectionStatus;
|
||||
}
|
||||
mServerCallbacks->handleConnectionEvents(event);
|
||||
}
|
||||
|
||||
bool ChreInterface::sendCommandToApp(uint32_t messageType, const std::vector<uint8_t>& message) {
|
||||
FlatBufferBuilder builder(chre_constants::kMaxMessageLen);
|
||||
void* messageData = nullptr;
|
||||
size_t messageDataLen = message.size();
|
||||
if (messageDataLen > 0) {
|
||||
messageData = (void*)message.data();
|
||||
}
|
||||
HostProtocolHost::encodeNanoappMessage(builder, chre_constants::kWifiOffloadNanoAppId,
|
||||
messageType, 0, messageData, messageDataLen);
|
||||
if (!mClient.sendMessage(builder.GetBufferPointer(), builder.GetSize())) {
|
||||
LOG(WARNING) << "Failed to send message to Nano app";
|
||||
return false;
|
||||
}
|
||||
LOG(VERBOSE) << "Command sent " << messageType;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChreInterface::handleMessage(uint32_t messageType, const void* messageData,
|
||||
size_t messageDataLen) {
|
||||
const uint8_t* messageBuf = reinterpret_cast<const uint8_t*>(messageData);
|
||||
std::vector<uint8_t> message(messageBuf, messageBuf + messageDataLen);
|
||||
mServerCallbacks->handleMessage(messageType, message);
|
||||
}
|
||||
|
||||
bool ChreInterface::getHubInfo() {
|
||||
LOG(VERBOSE) << "getHubInfo";
|
||||
|
||||
FlatBufferBuilder builder(chre_constants::kHubInfoRequestBufLen);
|
||||
HostProtocolHost::encodeHubInfoRequest(builder);
|
||||
if (!mClient.sendMessage(builder.GetBufferPointer(), builder.GetSize())) {
|
||||
LOG(WARNING) << "Failed to send Hub Info request";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChreInterface::getNanoAppList() {
|
||||
LOG(VERBOSE) << "getNanoAppList";
|
||||
FlatBufferBuilder builder(chre_constants::kNanoAppListRequestBufLen);
|
||||
HostProtocolHost::encodeNanoappListRequest(builder);
|
||||
|
||||
if (!mClient.sendMessage(builder.GetBufferPointer(), builder.GetSize())) {
|
||||
LOG(WARNING) << "Unable to send Nano app List request";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,87 +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 WIFI_OFFLOAD_CHRE_INTERFACE_H_
|
||||
#define WIFI_OFFLOAD_CHRE_INTERFACE_H_
|
||||
|
||||
#include "chre_constants.h"
|
||||
#include "chre_host/host_protocol_host.h"
|
||||
#include "chre_host/socket_client.h"
|
||||
#include "chre_interface_callbacks.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class ChreInterface;
|
||||
|
||||
class SocketCallbacks
|
||||
: public ::android::chre::SocketClient::ICallbacks,
|
||||
public ::android::chre::IChreMessageHandlers {
|
||||
public:
|
||||
SocketCallbacks(ChreInterface* parent);
|
||||
void onMessageReceived(const void* data, size_t length) override;
|
||||
void onConnected() override;
|
||||
void onConnectionAborted() override;
|
||||
void onDisconnected() override;
|
||||
void handleNanoappMessage(const ::chre::fbs::NanoappMessageT& message) override;
|
||||
void handleHubInfoResponse(const ::chre::fbs::HubInfoResponseT& response) override;
|
||||
void handleNanoappListResponse(const ::chre::fbs::NanoappListResponseT& response) override;
|
||||
void handleLoadNanoappResponse(const ::chre::fbs::LoadNanoappResponseT& response) override;
|
||||
void handleUnloadNanoappResponse(const ::chre::fbs::UnloadNanoappResponseT& response) override;
|
||||
|
||||
private:
|
||||
/* Requests Hub Information, returns true if Hub Info request was sent */
|
||||
bool getHubInfo();
|
||||
/* Request list of Nano apps, returns true if Nano app List request was sent */
|
||||
bool getNanoAppList();
|
||||
ChreInterface* mParent;
|
||||
};
|
||||
|
||||
class ChreInterface {
|
||||
public:
|
||||
ChreInterface(ChreInterfaceCallbacks* callback);
|
||||
~ChreInterface();
|
||||
/* Return the status of socket connection */
|
||||
bool isConnected();
|
||||
/* Send a message to the Nano app, returns true if send successful */
|
||||
bool sendCommandToApp(uint32_t messageType, const std::vector<uint8_t>& message);
|
||||
/* Connected or connection restart handling method */
|
||||
void reportConnectionEvent(ChreInterfaceCallbacks::ConnectionEvent /* event */);
|
||||
/* Requests Hub Information, returns true if Hub Info request was sent */
|
||||
bool getHubInfo();
|
||||
/* Request list of Nano apps, returns true if Nano app List request was sent */
|
||||
bool getNanoAppList();
|
||||
/* Invoked by the socket callbacks when a message is recieved from Nano app */
|
||||
void handleMessage(uint32_t messageType, const void* messageData, size_t messageDataLen);
|
||||
|
||||
private:
|
||||
::android::chre::SocketClient mClient;
|
||||
sp<SocketCallbacks> mSocketCallbacks;
|
||||
ChreInterfaceCallbacks* mServerCallbacks;
|
||||
std::mutex mChreInterfaceLock;
|
||||
bool mSocketConnected;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
#endif // WIFI_OFFLOAD_CHRE_INTERFACE_H_
|
||||
@@ -1,45 +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 WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H
|
||||
#define WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class ChreInterfaceCallbacks {
|
||||
public:
|
||||
enum ConnectionEvent { CONNECTED, DISCONNECTED, CONNECTION_ABORT };
|
||||
virtual ~ChreInterfaceCallbacks() {}
|
||||
|
||||
/* Invoked by the Chre interface when connection events are received */
|
||||
virtual void handleConnectionEvents(ConnectionEvent event) = 0;
|
||||
/* Invoked by the Chre interface when a message is recieved from Nano app */
|
||||
virtual void handleMessage(uint32_t messageType, const std::vector<uint8_t>& message) = 0;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
#endif // WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H
|
||||
@@ -1,36 +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 "chre_interface_factory.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
ChreInterface* ChreInterfaceFactory::getChreInterface(ChreInterfaceCallbacks* serverCallbacks) {
|
||||
return new ChreInterface(serverCallbacks);
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,43 +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 WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_
|
||||
#define WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_
|
||||
|
||||
#include "chre_interface.h"
|
||||
#include "chre_interface_callbacks.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class ChreInterfaceFactory {
|
||||
public:
|
||||
ChreInterfaceFactory() = default;
|
||||
virtual ~ChreInterfaceFactory() = default;
|
||||
virtual ChreInterface* getChreInterface(ChreInterfaceCallbacks* server);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* hidl interface for wpa_supplicant daemon
|
||||
* Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef HIDL_RETURN_UTIL_H_
|
||||
#define HIDL_RETURN_UTIL_H_
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace hidl_return_util {
|
||||
|
||||
/**
|
||||
* These utility functions are used to invoke a method on the provided
|
||||
* HIDL interface object.
|
||||
* It then invokes the HIDL continuation callback with the status and
|
||||
* any returned values.
|
||||
*/
|
||||
// Use for HIDL methods which return only an instance of OffloadStatus.
|
||||
template<typename ObjT, typename WorkFuncT, typename... Args>
|
||||
Return<void> validateAndCall(ObjT* obj, WorkFuncT&& work,
|
||||
const std::function<void(const OffloadStatus&)>& hidl_cb,
|
||||
Args&&... args) {
|
||||
hidl_cb((obj->*work)(std::forward<Args>(args)...));
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Use for HIDL methods which return instance of OffloadStatus and a single
|
||||
// return value.
|
||||
template<typename ObjT, typename WorkFuncT, typename ReturnT, typename... Args>
|
||||
Return<void> validateAndCall(ObjT* obj, WorkFuncT&& work,
|
||||
const std::function<void(const OffloadStatus&, ReturnT)>& hidl_cb,
|
||||
Args&&... args) {
|
||||
const auto& ret_pair = (obj->*work)(std::forward<Args>(args)...);
|
||||
const OffloadStatus& status = std::get<0>(ret_pair);
|
||||
const auto& ret_value = std::get<1>(ret_pair);
|
||||
hidl_cb(status, ret_value);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Use for HIDL methods which return instance of OffloadStatus and 2 return
|
||||
// values.
|
||||
template<typename ObjT, typename WorkFuncT, typename ReturnT1, typename ReturnT2, typename... Args>
|
||||
Return<void>
|
||||
validateAndCall(ObjT* obj, WorkFuncT&& work,
|
||||
const std::function<void(const OffloadStatus&, ReturnT1, ReturnT2)>& hidl_cb,
|
||||
Args&&... args) {
|
||||
const auto& ret_tuple = (obj->*work)(std::forward<Args>(args)...);
|
||||
const OffloadStatus& status = std::get<0>(ret_tuple);
|
||||
const auto& ret_value1 = std::get<1>(ret_tuple);
|
||||
const auto& ret_value2 = std::get<2>(ret_tuple);
|
||||
hidl_cb(status, ret_value1, ret_value2);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace hidl_return_util
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
#endif // HIDL_RETURN_UTIL_H_
|
||||
@@ -1,249 +0,0 @@
|
||||
#include "offload_server.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <chre/apps/wifi_offload/flatbuffers_serialization.h>
|
||||
#include <chre/apps/wifi_offload/host_message_types.h>
|
||||
|
||||
#include "offload_status_util.h"
|
||||
#include "offload_utils.h"
|
||||
|
||||
using namespace android::hardware::wifi::offload::V1_0::implementation::chre_constants;
|
||||
using android::hardware::wifi::offload::V1_0::OffloadStatus;
|
||||
|
||||
namespace {
|
||||
constexpr auto kScanStatsTimeout = std::chrono::milliseconds(500);
|
||||
}
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class OffloadServer;
|
||||
|
||||
OffloadServer::OffloadServer(ChreInterfaceFactory* factory)
|
||||
: mChreInterfaceCallbacks(new ChreInterfaceCallbacksImpl(this)),
|
||||
mChreInterface(factory->getChreInterface(mChreInterfaceCallbacks.get())) {
|
||||
LOG(VERBOSE) << "Wifi Offload HAL impl";
|
||||
}
|
||||
|
||||
OffloadStatus OffloadServer::configureScans(const ScanParam& param, const ScanFilter& filter) {
|
||||
LOG(INFO) << "configureScans";
|
||||
if (!mChreInterface->isConnected()) {
|
||||
return createOffloadStatus(OffloadStatusCode::NO_CONNECTION,
|
||||
"Not connected to hardware implementation");
|
||||
}
|
||||
wifi_offload::ScanConfig scanConfig;
|
||||
if (!offload_utils::ToChreScanConfig(param, filter, &scanConfig)) {
|
||||
return createOffloadStatus(OffloadStatusCode::ERROR,
|
||||
"Unable to convert scan configuration");
|
||||
}
|
||||
uint8_t buffer[kMaxMessageLen];
|
||||
size_t result_size = wifi_offload::fbs::Serialize(scanConfig, buffer, kMaxMessageLen);
|
||||
if (result_size <= 0) {
|
||||
return createOffloadStatus(OffloadStatusCode::ERROR, "Scan config serialization failed");
|
||||
}
|
||||
std::vector<uint8_t> message(buffer, buffer + result_size);
|
||||
if (!mChreInterface->sendCommandToApp(wifi_offload::HostMessageType::HOST_CMD_CONFIG_SCANS,
|
||||
message)) {
|
||||
return createOffloadStatus(OffloadStatusCode::ERROR, "Unable to send config message");
|
||||
}
|
||||
return createOffloadStatus(OffloadStatusCode::OK);
|
||||
}
|
||||
|
||||
std::pair<OffloadStatus, ScanStats> OffloadServer::getScanStats() {
|
||||
LOG(INFO) << "getScanStats";
|
||||
mScanStatsStatus = createOffloadStatus(OffloadStatusCode::OK);
|
||||
if (!mChreInterface->isConnected()) {
|
||||
return {createOffloadStatus(OffloadStatusCode::NO_CONNECTION, "Unable to send scan stats"),
|
||||
{}};
|
||||
}
|
||||
if (!mChreInterface->sendCommandToApp(wifi_offload::HostMessageType::HOST_CMD_GET_SCAN_STATS,
|
||||
{})) {
|
||||
return {createOffloadStatus(OffloadStatusCode::ERROR, "Unable to send scan stats command"),
|
||||
{}};
|
||||
}
|
||||
LOG(VERBOSE) << "Sent getScanStats command";
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mScanStatsLock);
|
||||
auto timeout_status = mScanStatsCond.wait_for(lock, kScanStatsTimeout);
|
||||
if (timeout_status == std::cv_status::timeout) {
|
||||
std::lock_guard<std::mutex> lock(mOffloadLock);
|
||||
LOG(WARNING) << "Timeout waiting for scan stats";
|
||||
return {createOffloadStatus(OffloadStatusCode::TIMEOUT, "Scan stats not received"), {}};
|
||||
}
|
||||
}
|
||||
return std::make_pair(mScanStatsStatus, mScanStats);
|
||||
}
|
||||
|
||||
OffloadStatus OffloadServer::subscribeScanResults(uint32_t delayMs) {
|
||||
LOG(INFO) << "subscribeScanResults with delay:" << delayMs;
|
||||
if (!mChreInterface->isConnected()) {
|
||||
return createOffloadStatus(OffloadStatusCode::NO_CONNECTION, "Not connected to hardware");
|
||||
}
|
||||
uint32_t* buffer = &delayMs;
|
||||
std::vector<uint8_t> message(reinterpret_cast<uint8_t*>(buffer),
|
||||
reinterpret_cast<uint8_t*>(buffer) + kSubscriptionDelayMsBufLen);
|
||||
if (!mChreInterface->sendCommandToApp(
|
||||
wifi_offload::HostMessageType::HOST_CMD_SUBSCRIBE_SCAN_RESULTS, message)) {
|
||||
return createOffloadStatus(OffloadStatusCode::ERROR, "Unable to request scans");
|
||||
}
|
||||
return createOffloadStatus(OffloadStatusCode::OK);
|
||||
}
|
||||
|
||||
void OffloadServer::resetNanoApp() {
|
||||
LOG(INFO) << "resetting Nano app";
|
||||
if (!mChreInterface->isConnected()) {
|
||||
LOG(WARNING) << "Unable to reset nano app, not connected";
|
||||
return;
|
||||
}
|
||||
if (!mChreInterface->sendCommandToApp(wifi_offload::HostMessageType::HOST_CMD_RESET, {})) {
|
||||
LOG(ERROR) << "Unable to send Reset command to Nano app";
|
||||
}
|
||||
}
|
||||
|
||||
bool OffloadServer::unsubscribeScanResults() {
|
||||
LOG(INFO) << "unsubscribeScanResults";
|
||||
if (!mChreInterface->isConnected()) {
|
||||
LOG(WARNING) << "Failed to send unsubscribe scan results message";
|
||||
return false;
|
||||
}
|
||||
if (!mChreInterface->sendCommandToApp(
|
||||
wifi_offload::HostMessageType::HOST_CMD_UNSUBSCRIBE_SCAN_RESULTS, {})) {
|
||||
LOG(WARNING) << "Failed to send unsubscribe scan results message";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffloadServer::setEventCallback(const sp<IOffloadCallback>& cb) {
|
||||
LOG(INFO) << "Set Event callback";
|
||||
if (cb == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mOffloadLock);
|
||||
mEventCallback = cb;
|
||||
return true;
|
||||
}
|
||||
|
||||
void OffloadServer::clearEventCallback() {
|
||||
std::lock_guard<std::mutex> lock(mOffloadLock);
|
||||
if (mEventCallback != nullptr) {
|
||||
mEventCallback.clear();
|
||||
}
|
||||
LOG(INFO) << "Event callback cleared";
|
||||
}
|
||||
|
||||
void OffloadServer::invokeErrorCallbackAndResetIfNeeded(const OffloadStatus& status) {
|
||||
if (status.code != OffloadStatusCode::OK) {
|
||||
resetNanoApp();
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mOffloadLock);
|
||||
if (mEventCallback != nullptr) {
|
||||
mEventCallback->onError(status);
|
||||
}
|
||||
}
|
||||
|
||||
ChreInterfaceCallbacksImpl::ChreInterfaceCallbacksImpl(OffloadServer* server) : mServer(server) {
|
||||
}
|
||||
|
||||
ChreInterfaceCallbacksImpl::~ChreInterfaceCallbacksImpl() {
|
||||
}
|
||||
|
||||
void ChreInterfaceCallbacksImpl::handleConnectionEvents(
|
||||
ChreInterfaceCallbacks::ConnectionEvent event) {
|
||||
switch (event) {
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::DISCONNECTED:
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTION_ABORT: {
|
||||
LOG(ERROR) << "Connection to socket lost";
|
||||
mServer->invokeErrorCallbackAndResetIfNeeded(
|
||||
createOffloadStatus(OffloadStatusCode::NO_CONNECTION, "Connection to socket lost"));
|
||||
} break;
|
||||
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTED: {
|
||||
LOG(INFO) << "Connected to socket";
|
||||
mServer->invokeErrorCallbackAndResetIfNeeded(
|
||||
createOffloadStatus(OffloadStatusCode::OK));
|
||||
} break;
|
||||
default:
|
||||
LOG(WARNING) << "Invalid connection event received " << (int)event;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OffloadServer::handleScanResult(const std::vector<uint8_t>& message) {
|
||||
std::vector<wifi_offload::ScanResult> scanResults;
|
||||
std::vector<ScanResult> hidlScanResults;
|
||||
std::string errorMessage;
|
||||
if (!wifi_offload::fbs::Deserialize((uint8_t*)message.data(), message.size(), &scanResults)) {
|
||||
invokeErrorCallbackAndResetIfNeeded(
|
||||
createOffloadStatus(OffloadStatusCode::ERROR, "Cannot deserialize scan results"));
|
||||
return;
|
||||
}
|
||||
if (!offload_utils::ToHidlScanResults(scanResults, &hidlScanResults)) {
|
||||
invokeErrorCallbackAndResetIfNeeded(createOffloadStatus(
|
||||
OffloadStatusCode::ERROR, "Cannot convert scan results to HIDL format"));
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mOffloadLock);
|
||||
if (mEventCallback != nullptr) {
|
||||
mEventCallback->onScanResult(hidlScanResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OffloadServer::handleScanStats(const std::vector<uint8_t>& message) {
|
||||
std::lock_guard<std::mutex> lock(mScanStatsLock);
|
||||
wifi_offload::ScanStats stats;
|
||||
OffloadStatus status;
|
||||
// Deserialize scan stats
|
||||
status = createOffloadStatus(OffloadStatusCode::OK);
|
||||
LOG(VERBOSE) << "Received scan stats";
|
||||
if (!wifi_offload::fbs::Deserialize((uint8_t*)message.data(), message.size(), &stats)) {
|
||||
status = createOffloadStatus(OffloadStatusCode::ERROR, "Cannot deserailize scan stats");
|
||||
} else if (!offload_utils::ToHidlScanStats(stats, &mScanStats)) {
|
||||
status = createOffloadStatus(OffloadStatusCode::ERROR,
|
||||
"Cannot convert Scan stats to HIDL format");
|
||||
}
|
||||
mScanStatsStatus = status;
|
||||
mScanStatsCond.notify_all();
|
||||
}
|
||||
|
||||
void ChreInterfaceCallbacksImpl::handleMessage(uint32_t messageType,
|
||||
const std::vector<uint8_t>& message) {
|
||||
LOG(VERBOSE) << "Message from Nano app " << messageType;
|
||||
switch (messageType) {
|
||||
case wifi_offload::HostMessageType::HOST_MSG_SCAN_RESULTS: {
|
||||
LOG(INFO) << "Received scan results";
|
||||
mServer->handleScanResult(message);
|
||||
} break;
|
||||
case wifi_offload::HostMessageType::HOST_MSG_SCAN_STATS:
|
||||
LOG(VERBOSE) << "Received scan stats from Nano app";
|
||||
mServer->handleScanStats(message);
|
||||
break;
|
||||
case wifi_offload::HostMessageType::HOST_MSG_ERROR:
|
||||
LOG(VERBOSE) << "Received error message from Nano app";
|
||||
{
|
||||
std::string errorMessage;
|
||||
if (offload_utils::ToHidlErrorMessage(message[0], &errorMessage)) {
|
||||
mServer->invokeErrorCallbackAndResetIfNeeded(
|
||||
createOffloadStatus(OffloadStatusCode::ERROR, errorMessage));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG(WARNING) << "Unknown message received" << messageType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,70 +0,0 @@
|
||||
#ifndef WIFI_OFFLOAD_SERVER_H_
|
||||
#define WIFI_OFFLOAD_SERVER_H_
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
|
||||
#include "chre_interface_factory.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class OffloadServer;
|
||||
|
||||
class ChreInterfaceCallbacksImpl : public ChreInterfaceCallbacks {
|
||||
public:
|
||||
ChreInterfaceCallbacksImpl(OffloadServer* server);
|
||||
~ChreInterfaceCallbacksImpl() override;
|
||||
|
||||
void handleConnectionEvents(ChreInterfaceCallbacks::ConnectionEvent event);
|
||||
void handleMessage(uint32_t messageType, const std::vector<uint8_t>& message);
|
||||
|
||||
private:
|
||||
OffloadServer* mServer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface object to communicate with Offload HAL
|
||||
*/
|
||||
class OffloadServer {
|
||||
public:
|
||||
OffloadServer(ChreInterfaceFactory* factory);
|
||||
|
||||
OffloadStatus configureScans(const ScanParam& param, const ScanFilter& filter);
|
||||
std::pair<OffloadStatus, ScanStats> getScanStats();
|
||||
OffloadStatus subscribeScanResults(uint32_t delayMs);
|
||||
bool unsubscribeScanResults();
|
||||
bool setEventCallback(const sp<IOffloadCallback>& cb);
|
||||
void clearEventCallback();
|
||||
|
||||
private:
|
||||
void invokeErrorCallbackAndResetIfNeeded(
|
||||
const android::hardware::wifi::offload::V1_0::OffloadStatus& status);
|
||||
void handleScanResult(const std::vector<uint8_t>& message);
|
||||
void handleScanStats(const std::vector<uint8_t>& message);
|
||||
void resetNanoApp();
|
||||
|
||||
ScanStats mScanStats;
|
||||
std::mutex mScanStatsLock;
|
||||
std::condition_variable mScanStatsCond;
|
||||
std::mutex mOffloadLock;
|
||||
OffloadStatus mScanStatsStatus;
|
||||
|
||||
std::unique_ptr<ChreInterfaceCallbacksImpl> mChreInterfaceCallbacks;
|
||||
std::unique_ptr<ChreInterface> mChreInterface;
|
||||
sp<IOffloadCallback> mEventCallback;
|
||||
|
||||
friend class ChreInterfaceCallbacksImpl;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_SERVER_H_
|
||||
@@ -1,39 +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_status_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
OffloadStatus createOffloadStatus(OffloadStatusCode code, const std::string &description) {
|
||||
return {code, description};
|
||||
}
|
||||
|
||||
OffloadStatus createOffloadStatus(OffloadStatusCode code) {
|
||||
return createOffloadStatus(code, "");
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,39 +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 OFFLOAD_STATUS_UTIL_H_
|
||||
#define OFFLOAD_STATUS_UTIL_H_
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
OffloadStatus createOffloadStatus(OffloadStatusCode code, const std::string &description);
|
||||
OffloadStatus createOffloadStatus(OffloadStatusCode code);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // OFFLOAD_STATUS_UTIL_H_
|
||||
@@ -1,285 +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 "offload_utils.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <chre/apps/wifi_offload/error_codes.h>
|
||||
|
||||
namespace {
|
||||
|
||||
bool ToHidlRecordName(const wifi_offload::RpcLogRecord::RpcLogRecordType& chreRecordType,
|
||||
android::hardware::wifi::offload::V1_0::RecordName* hidlRecordName) {
|
||||
bool result = true;
|
||||
switch (chreRecordType) {
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_INIT:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::CMD_INT;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_CONFIG_SCANS:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::CMD_CONFIG_SCANS;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_SUBSCRIBE_SCAN_RESULTS:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_SUBSCRIBE_SCAN_RESULTS;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_UNSUBSCRIBE_SCAN_RESULTS:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_UNSUBSCRIBE_SCAN_RESULTS;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_GET_SCAN_STATS:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_GET_SCAN_STATS;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_RESET:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::CMD_RESET;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_RECVD_SCAN_RESULT_ASYNC:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::EVENT_RECVD_SCAN_RESULT_ASYNC;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_RECVD_SCAN_RESULT:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::EVENT_RECVD_SCAN_RESULT;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_SENT_SCAN_RESULT:
|
||||
*hidlRecordName =
|
||||
android::hardware::wifi::offload::V1_0::RecordName::EVENT_SENT_SCAN_RESULT;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_SENT_ABORT:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::EVENT_SENT_ABORT;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_SENT_ERROR:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::EVENT_SENT_ERROR;
|
||||
break;
|
||||
case wifi_offload::RpcLogRecord::RpcLogRecordType::REQ_SCAN:
|
||||
*hidlRecordName = android::hardware::wifi::offload::V1_0::RecordName::REQ_SCAN;
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t ToChreSecurityMode(uint8_t hidlSecurityMode) {
|
||||
uint8_t chreSecurityMode = 0;
|
||||
if (hidlSecurityMode & android::hardware::wifi::offload::V1_0::SecurityMode::OPEN) {
|
||||
chreSecurityMode |= wifi_offload::SecurityMode::OPEN;
|
||||
}
|
||||
if (hidlSecurityMode & android::hardware::wifi::offload::V1_0::SecurityMode::WEP) {
|
||||
chreSecurityMode |= wifi_offload::SecurityMode::WEP;
|
||||
}
|
||||
if (hidlSecurityMode & android::hardware::wifi::offload::V1_0::SecurityMode::PSK) {
|
||||
chreSecurityMode |= wifi_offload::SecurityMode::PSK;
|
||||
}
|
||||
if (hidlSecurityMode & android::hardware::wifi::offload::V1_0::SecurityMode::EAP) {
|
||||
chreSecurityMode |= wifi_offload::SecurityMode::EAP;
|
||||
}
|
||||
return chreSecurityMode;
|
||||
}
|
||||
|
||||
uint8_t ToHidlSecurityMode(uint8_t chreSecurityMode) {
|
||||
uint8_t hidlSecurityMode = 0;
|
||||
if (chreSecurityMode & wifi_offload::SecurityMode::OPEN) {
|
||||
hidlSecurityMode |= android::hardware::wifi::offload::V1_0::SecurityMode::OPEN;
|
||||
}
|
||||
if (chreSecurityMode & wifi_offload::SecurityMode::WEP) {
|
||||
hidlSecurityMode |= android::hardware::wifi::offload::V1_0::SecurityMode::WEP;
|
||||
}
|
||||
if (chreSecurityMode & wifi_offload::SecurityMode::PSK) {
|
||||
hidlSecurityMode |= android::hardware::wifi::offload::V1_0::SecurityMode::PSK;
|
||||
}
|
||||
if (chreSecurityMode & wifi_offload::SecurityMode::EAP) {
|
||||
hidlSecurityMode |= android::hardware::wifi::offload::V1_0::SecurityMode::EAP;
|
||||
}
|
||||
return hidlSecurityMode;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace offload_utils {
|
||||
|
||||
bool ToHidlScanResult(const wifi_offload::ScanResult& chreScanResult, ScanResult* hidlScanResult) {
|
||||
if (hidlScanResult == nullptr) {
|
||||
return false;
|
||||
}
|
||||
hidlScanResult->tsf = chreScanResult.tsf_;
|
||||
hidlScanResult->capability = chreScanResult.capability_;
|
||||
hidlScanResult->rssi = chreScanResult.rssi_dbm_;
|
||||
hidlScanResult->frequency = chreScanResult.frequency_scanned_mhz_;
|
||||
memcpy(&hidlScanResult->bssid[0], &chreScanResult.bssid_[0],
|
||||
wifi_offload::ScanResult::kBssidSize);
|
||||
chreWifiSsidListItem chreWifiSsid;
|
||||
chreScanResult.ssid_.ToChreWifiSsidListItem(&chreWifiSsid);
|
||||
std::vector<uint8_t> ssid;
|
||||
for (size_t i = 0; i < chreWifiSsid.ssidLen; i++) {
|
||||
ssid.push_back(chreWifiSsid.ssid[i]);
|
||||
}
|
||||
hidlScanResult->networkInfo.ssid = ssid;
|
||||
hidlScanResult->networkInfo.flags = ToHidlSecurityMode(chreScanResult.security_modes_);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToHidlScanResults(const std::vector<wifi_offload::ScanResult>& chreScanResults,
|
||||
std::vector<ScanResult>* hidlScanResults) {
|
||||
LOG(VERBOSE) << "ScanResults from CHRE, size=" << chreScanResults.size();
|
||||
for (const auto& scan_result_from_nano_app : chreScanResults) {
|
||||
ScanResult hidl_scan_result;
|
||||
if (!ToHidlScanResult(scan_result_from_nano_app, &hidl_scan_result)) {
|
||||
return false;
|
||||
}
|
||||
hidlScanResults->push_back(hidl_scan_result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToHidlScanStats(const wifi_offload::ScanStats& chreScanStats, ScanStats* hidlScanStats) {
|
||||
hidlScanStats->subscriptionDurationMs = chreScanStats.last_subscription_duration_ms_;
|
||||
hidlScanStats->numScansRequestedByWifi = chreScanStats.num_scans_requested_by_nanoapp_;
|
||||
hidlScanStats->numScansServicedByWifi = chreScanStats.num_scans_serviced_by_hardware_;
|
||||
hidlScanStats->numScansServicedbyCache = chreScanStats.num_scans_serviced_by_cache_;
|
||||
std::vector<ScanRecord> hidlScanRecords;
|
||||
for (const auto& chreScanRecord : chreScanStats.scan_records_) {
|
||||
ScanRecord hidlScanRecord;
|
||||
hidlScanRecord.durationMs = chreScanRecord.time_spent_scanning_ms_;
|
||||
hidlScanRecord.numChannelsScanned = chreScanRecord.num_channels_scanned_;
|
||||
hidlScanRecord.numEntriesAggregated = chreScanRecord.num_entries_aggregated_;
|
||||
hidlScanRecords.push_back(hidlScanRecord);
|
||||
}
|
||||
hidlScanStats->scanRecord = hidlScanRecords;
|
||||
std::vector<LogRecord> logRecords;
|
||||
for (const auto& chreLogRecord : chreScanStats.rpc_log_records_) {
|
||||
LogRecord logRecord;
|
||||
if (!ToHidlRecordName(chreLogRecord.record_type_, &logRecord.recordName)) {
|
||||
return false;
|
||||
}
|
||||
logRecord.logTimeMs = chreLogRecord.timestamp_chre_ms_;
|
||||
logRecords.push_back(logRecord);
|
||||
}
|
||||
hidlScanStats->logRecord = logRecords;
|
||||
for (size_t i = 0; i < hidlScanStats->histogramChannelsScanned.elementCount(); i++) {
|
||||
hidlScanStats->histogramChannelsScanned[i] =
|
||||
chreScanStats.channel_histogram_.GetChannelScanCount(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToChreScanConfig(const ScanParam& param, const ScanFilter& filter,
|
||||
wifi_offload::ScanConfig* scanConfig) {
|
||||
scanConfig->scan_params_.disconnected_mode_scan_interval_ms_ =
|
||||
param.disconnectedModeScanIntervalMs;
|
||||
for (const auto& ssid : param.ssidList) {
|
||||
wifi_offload::Ssid chreSsid;
|
||||
chreSsid.SetData(ssid.data(), ssid.size());
|
||||
scanConfig->scan_params_.ssids_to_scan_.push_back(chreSsid);
|
||||
}
|
||||
for (const auto& freq : param.frequencyList) {
|
||||
scanConfig->scan_params_.frequencies_to_scan_mhz_.push_back(freq);
|
||||
}
|
||||
scanConfig->scan_filter_.min_rssi_threshold_dbm_ = filter.rssiThreshold;
|
||||
for (const auto& nwInfo : filter.preferredNetworkInfoList) {
|
||||
wifi_offload::PreferredNetwork chreNwInfo;
|
||||
chreNwInfo.security_modes_ = ToChreSecurityMode(nwInfo.flags);
|
||||
chreNwInfo.ssid_.SetData(nwInfo.ssid.data(), nwInfo.ssid.size());
|
||||
scanConfig->scan_filter_.networks_to_match_.push_back(std::move(chreNwInfo));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToHidlErrorMessage(uint32_t errorCode, std::string* errorMessage) {
|
||||
bool reportError = true;
|
||||
switch (errorCode) {
|
||||
case wifi_offload::ErrorCode::FAILED_TO_ALLOCATE_MESSAGE_BUFFER:
|
||||
*errorMessage = "Failed to allocate message buffer";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SERIALIZE_MESSAGE:
|
||||
*errorMessage = "Failed to serialize message";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SEND_MESSAGE:
|
||||
*errorMessage = "Failed to send message";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_DESERIALIZE_SCAN_CONFIG:
|
||||
*errorMessage = "Failed to deserialize scan config";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::INVALID_SUBSCRIBE_MESSAGE_SIZE:
|
||||
*errorMessage = "Invalid subscribe message size";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::SCAN_CONFIG_NOT_INITIALIZED:
|
||||
*errorMessage = "Scan config not initialized";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::UNSPECIFIED_HOST_ENDPOINT:
|
||||
*errorMessage = "Unspecified host end point";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SEND_SCAN_RESULTS:
|
||||
*errorMessage = "Failed to send scan results";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SEND_SCAN_STATS:
|
||||
*errorMessage = "Failed to send scan stats";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::ONDEMAND_SCAN_NOT_SUPPORTED:
|
||||
*errorMessage = "On demand scans not supported";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SEND_ONDEMAND_SCAN_REQUEST:
|
||||
*errorMessage = "Failed to send on demand scan request";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SEND_ONDEMAND_SCAN_REQUEST_ASYNC:
|
||||
*errorMessage = "Failed to send on demand scan request async";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::OUT_OF_ORDER_SCAN_RESULTS:
|
||||
*errorMessage = "Out of order scan results";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::INCOMPLETE_SCAN_RESULTS_BEFORE_SCAN_REQUEST:
|
||||
*errorMessage = "Incomplete scan results before scan request";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_SET_SCAN_TIMER:
|
||||
*errorMessage = "Failed to set scan timer";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::SCAN_MONITORING_NOT_SUPPORTED:
|
||||
*errorMessage = "Scan Monitoring not supported";
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_START_SCAN_MONITORING:
|
||||
*errorMessage = "Failed to start scan monitoring";
|
||||
reportError = false;
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_STOP_SCAN_MONITORING:
|
||||
*errorMessage = "Failed to stop scan monitoring";
|
||||
reportError = false;
|
||||
break;
|
||||
case wifi_offload::ErrorCode::FAILED_TO_CONFIGURE_SCAN_MONITORING_ASYNC:
|
||||
*errorMessage = "Failed to configure scan monitoring async";
|
||||
reportError = false;
|
||||
break;
|
||||
default:
|
||||
*errorMessage = "Invalid error code";
|
||||
reportError = false;
|
||||
break;
|
||||
}
|
||||
return reportError;
|
||||
}
|
||||
|
||||
} // namespace offload_utils
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef WIFI_OFFLOAD_SERVER_UTILS_H_
|
||||
#define WIFI_OFFLOAD_SERVER_UTILS_H_
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
#include <chre/apps/wifi_offload/flatbuffers_serialization.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace offload_utils {
|
||||
|
||||
bool ToHidlScanResults(const std::vector<wifi_offload::ScanResult>& chreScanResults,
|
||||
std::vector<ScanResult>* hidlScanResults);
|
||||
bool ToHidlScanStats(const wifi_offload::ScanStats& chreScanStats, ScanStats* hildScanStats);
|
||||
bool ToChreScanConfig(const ScanParam& param, const ScanFilter& filter,
|
||||
wifi_offload::ScanConfig* scanConfig);
|
||||
bool ToHidlErrorMessage(uint32_t errorCode, std::string* errorMessage);
|
||||
|
||||
} // namespace offload_utils
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_SERVER_UTILS_H_
|
||||
@@ -1,49 +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 <hidl/HidlTransportSupport.h>
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
#include "Offload.h"
|
||||
|
||||
// libhwbinder
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
using android::hardware::wifi::offload::V1_0::IOffload;
|
||||
using android::hardware::wifi::offload::V1_0::implementation::Offload;
|
||||
|
||||
int main(int /*argc*/, char **argv) {
|
||||
android::base::InitLogging(
|
||||
argv, android::base::LogdLogger(android::base::SYSTEM));
|
||||
LOG(android::base::INFO) << "Wifi Offload HAL service start ";
|
||||
|
||||
// Setup hwbinder
|
||||
configureRpcThreadpool(1, true /* callerWillJoin */);
|
||||
|
||||
// Register service
|
||||
android::sp<IOffload> service = new Offload();
|
||||
CHECK_EQ(service->registerAsService(), android::NO_ERROR)
|
||||
<< "Failed to register Wifi Offload HAL";
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
LOG(android::base::INFO) << "Wifi Offload HAL service exit";
|
||||
return 0;
|
||||
}
|
||||
@@ -1,83 +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 <gtest/gtest.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "mock_chre_interface_callbacks.h"
|
||||
|
||||
#include "chre_interface.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t kBufSize = 256;
|
||||
const uint8_t kDefaultValue = 0xaa;
|
||||
const uint32_t kDefaultMessageType = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class ChreInterfaceTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
chre_interface_.reset(new ChreInterface(chre_interface_callback_.get()));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
|
||||
std::unique_ptr<testing::NiceMock<MockChreInterfaceCallbacks>> chre_interface_callback_{
|
||||
new testing::NiceMock<MockChreInterfaceCallbacks>()};
|
||||
std::unique_ptr<ChreInterface> chre_interface_;
|
||||
};
|
||||
|
||||
TEST_F(ChreInterfaceTest, ChreInterfaceConnectionEventTest) {
|
||||
EXPECT_CALL(*chre_interface_callback_, handleConnectionEvents(testing::_));
|
||||
chre_interface_->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTED);
|
||||
EXPECT_TRUE(chre_interface_->isConnected());
|
||||
}
|
||||
|
||||
TEST_F(ChreInterfaceTest, ChreInterfaceHandleMessageTest) {
|
||||
EXPECT_CALL(*chre_interface_callback_, handleMessage(testing::_, testing::_));
|
||||
uint32_t messageType;
|
||||
std::vector<uint8_t> buffer_recvd;
|
||||
ON_CALL(*chre_interface_callback_, handleMessage(testing::_, testing::_))
|
||||
.WillByDefault(
|
||||
DoAll(testing::SaveArg<0>(&messageType), testing::SaveArg<1>(&buffer_recvd)));
|
||||
uint8_t buffer_sent[kBufSize];
|
||||
for (size_t j = 0; j < kBufSize; j++) {
|
||||
buffer_sent[j] = kDefaultValue;
|
||||
}
|
||||
chre_interface_->handleMessage(kDefaultMessageType, (void*)&buffer_sent[0], kBufSize);
|
||||
EXPECT_EQ(messageType, kDefaultMessageType);
|
||||
EXPECT_EQ(buffer_recvd.size(), kBufSize);
|
||||
for (size_t i = 0; i < buffer_recvd.size(); i++) {
|
||||
EXPECT_EQ(buffer_recvd[i], buffer_sent[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -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 <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
// Force ourselves to always log to stderr
|
||||
android::base::InitLogging(argv, android::base::StderrLogger);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -1,34 +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 "mock_chre_interface.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
MockChreInterface::MockChreInterface(ChreInterfaceCallbacks* callback) : ChreInterface(callback) {
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,54 +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 WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_
|
||||
#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "chre_interface.h"
|
||||
#include "chre_interface_callbacks.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class MockChreInterface : public ChreInterface {
|
||||
public:
|
||||
MockChreInterface(ChreInterfaceCallbacks* callback);
|
||||
~MockChreInterface() = default;
|
||||
|
||||
MOCK_METHOD0(isConnected, bool());
|
||||
MOCK_METHOD2(sendCommandToApp, bool(uint32_t messageType, const std::vector<uint8_t>& message));
|
||||
MOCK_METHOD1(reportConnectionEvent, void(ChreInterfaceCallbacks::ConnectionEvent event));
|
||||
MOCK_METHOD0(getHubInfo, bool());
|
||||
MOCK_METHOD0(getNanoAppList, bool());
|
||||
MOCK_METHOD3(handleMessage,
|
||||
void(uint32_t messageType, const void* messageData, size_t messageDataLen));
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_
|
||||
@@ -1,33 +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 "mock_chre_interface_callbacks.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
MockChreInterfaceCallbacks::MockChreInterfaceCallbacks() {
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,47 +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 WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_
|
||||
#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "chre_interface_callbacks.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class MockChreInterfaceCallbacks : public ChreInterfaceCallbacks {
|
||||
public:
|
||||
MockChreInterfaceCallbacks();
|
||||
~MockChreInterfaceCallbacks() override = default;
|
||||
|
||||
MOCK_METHOD1(handleConnectionEvents, void(ChreInterfaceCallbacks::ConnectionEvent event));
|
||||
MOCK_METHOD2(handleMessage, void(uint32_t messageType, const std::vector<uint8_t>& message));
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_
|
||||
@@ -1,34 +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 "mock_chre_interface_factory.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
MockChreInterfaceFactory::MockChreInterfaceFactory() {
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,48 +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 WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_
|
||||
#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "chre_interface_callbacks.h"
|
||||
#include "chre_interface_factory.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class MockChreInterfaceFactory : public ChreInterfaceFactory {
|
||||
public:
|
||||
MockChreInterfaceFactory();
|
||||
~MockChreInterfaceFactory() override = default;
|
||||
|
||||
MOCK_METHOD1(getChreInterface, ChreInterface*(ChreInterfaceCallbacks* handlers));
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_
|
||||
@@ -1,91 +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 hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
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[] = {1, 2};
|
||||
const uint8_t kChannelNotScanned = 0;
|
||||
const uint32_t kDefaultNumScansRequestedByWifi = 2;
|
||||
const uint32_t kDefaultNumScansServicedByWifi = 2;
|
||||
const uint64_t kScanDurationTotalMs = 2000;
|
||||
const uint32_t kNumChannelsTotalScanned = 3;
|
||||
const uint32_t kNumChannelsInHistogram = 256;
|
||||
const uint8_t kTestChannels[] = {1, 6, 11};
|
||||
const uint32_t kNumTimesChannelScanned[] = {1, 1, 255};
|
||||
const uint32_t kSystemStartTime = 32164;
|
||||
const uint32_t kIncrementBetweenEvents = 10;
|
||||
const size_t kRecordLength = 8;
|
||||
const size_t kInvalidRecordLength = 4;
|
||||
|
||||
const wifi_offload::RpcLogRecord::RpcLogRecordType kChreRecordTypeList[] = {
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_INIT,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_CONFIG_SCANS,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_SUBSCRIBE_SCAN_RESULTS,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::REQ_SCAN,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_RECVD_SCAN_RESULT,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_SENT_SCAN_RESULT,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_UNSUBSCRIBE_SCAN_RESULTS,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_GET_SCAN_STATS,
|
||||
};
|
||||
|
||||
const wifi_offload::RpcLogRecord::RpcLogRecordType kInvalidChreRecordTypeLog[] = {
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::CMD_LAST_ITEM,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::REQ_LAST_ITEM,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_RECVD_LAST_ITEM,
|
||||
wifi_offload::RpcLogRecord::RpcLogRecordType::EVENT_SENT_LAST_ITEM,
|
||||
};
|
||||
|
||||
const android::hardware::wifi::offload::V1_0::RecordName kHidlRecordNameList[] = {
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_INT,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_CONFIG_SCANS,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_SUBSCRIBE_SCAN_RESULTS,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::REQ_SCAN,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::EVENT_RECVD_SCAN_RESULT,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::EVENT_SENT_SCAN_RESULT,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_UNSUBSCRIBE_SCAN_RESULTS,
|
||||
android::hardware::wifi::offload::V1_0::RecordName::CMD_GET_SCAN_STATS,
|
||||
};
|
||||
|
||||
} // namespace offload_hal_test_constants
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,74 +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 OFFLOAD_HAL_TEST_CONSTANTS_
|
||||
#define OFFLOAD_HAL_TEST_CONSTANTS_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "offload_utils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
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[];
|
||||
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;
|
||||
extern const uint8_t kTestChannels[];
|
||||
extern const uint32_t kNumTimesChannelScanned[];
|
||||
extern const uint32_t kSystemStartTime;
|
||||
extern const uint32_t kIncrementBetweenEvents;
|
||||
extern const size_t kRecordLength;
|
||||
extern const size_t kInvalidRecordLength;
|
||||
extern const wifi_offload::RpcLogRecord::RpcLogRecordType kChreRecordTypeList[];
|
||||
extern const wifi_offload::RpcLogRecord::RpcLogRecordType kInvalidChreRecordTypeLog[];
|
||||
extern const android::hardware::wifi::offload::V1_0::RecordName kHidlRecordNameList[];
|
||||
|
||||
} // namespace offload_hal_test_constants
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // OFFLOAD_HAL_TEST_CONSTANTS_
|
||||
@@ -1,200 +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_utils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace offload_hal_test_utils {
|
||||
|
||||
using namespace offload_hal_test_constants;
|
||||
|
||||
void createChreScanResultsForTest(std::vector<wifi_offload::ScanResult>* chreScanResults) {
|
||||
wifi_offload::ScanResult chreScanResult;
|
||||
chreScanResult.security_modes_ = kNetworkFlags;
|
||||
chreScanResult.capability_ = kCapability;
|
||||
chreScanResult.frequency_scanned_mhz_ = kFrequency1;
|
||||
chreScanResult.rssi_dbm_ = kRssi;
|
||||
chreScanResult.tsf_ = kTsf;
|
||||
chreScanResult.ssid_.SetData(&kSsid1[0], kSsid1_size);
|
||||
memcpy(&chreScanResult.bssid_[0], &kBssid[0], kBssidSize);
|
||||
chreScanResults->push_back(chreScanResult);
|
||||
}
|
||||
|
||||
void createChreScanStatsForTest(wifi_offload::ScanStats* chreScanStats) {
|
||||
chreScanStats->num_scans_requested_by_nanoapp_ = kDefaultNumScansRequestedByWifi;
|
||||
chreScanStats->num_scans_serviced_by_hardware_ = kDefaultNumScansServicedByWifi;
|
||||
chreScanStats->num_scans_serviced_by_cache_ =
|
||||
(kDefaultNumScansRequestedByWifi - kDefaultNumScansServicedByWifi);
|
||||
for (size_t j = 0; j < kNumChannelsScanned[0] + kNumChannelsScanned[1]; j++) {
|
||||
chreScanStats->channel_histogram_.IncrementScanCountForChannelForTest(
|
||||
kTestChannels[j], static_cast<uint32_t>(kNumTimesChannelScanned[j]));
|
||||
}
|
||||
chreScanStats->last_subscription_duration_ms_ = kSubscriptionDurationMs;
|
||||
wifi_offload::ScanRecord scanRecord1;
|
||||
scanRecord1.time_spent_scanning_ms_ = kScanDurationMs[0];
|
||||
scanRecord1.num_channels_scanned_ = kNumChannelsScanned[0];
|
||||
scanRecord1.num_entries_aggregated_ = 1;
|
||||
chreScanStats->scan_records_.push_back(scanRecord1);
|
||||
wifi_offload::ScanRecord scanRecord2;
|
||||
scanRecord2.time_spent_scanning_ms_ = kScanDurationMs[1];
|
||||
scanRecord2.num_channels_scanned_ = kNumChannelsScanned[1];
|
||||
scanRecord2.num_entries_aggregated_ = 1;
|
||||
chreScanStats->scan_records_.push_back(scanRecord2);
|
||||
|
||||
for (size_t i = 0; i < kRecordLength; i++) {
|
||||
wifi_offload::RpcLogRecord logRecord;
|
||||
logRecord.record_type_ = kChreRecordTypeList[i];
|
||||
logRecord.timestamp_chre_ms_ = kSystemStartTime + i * kIncrementBetweenEvents;
|
||||
chreScanStats->rpc_log_records_.push_back(logRecord);
|
||||
}
|
||||
}
|
||||
|
||||
void createHidlScanFilterForTest(ScanFilter* scanFilter) {
|
||||
std::vector<NetworkInfo> nw_info_list;
|
||||
NetworkInfo nwInfo1;
|
||||
std::vector<uint8_t> ssid1(kSsid1, kSsid1 + kSsid1_size);
|
||||
nwInfo1.ssid = ssid1;
|
||||
nwInfo1.flags = kNetworkFlags;
|
||||
NetworkInfo nwInfo2;
|
||||
std::vector<uint8_t> ssid2(kSsid2, kSsid2 + kSsid2_size);
|
||||
nwInfo2.ssid = ssid2;
|
||||
nwInfo2.flags = kNetworkFlags;
|
||||
nw_info_list.push_back(nwInfo1);
|
||||
nw_info_list.push_back(nwInfo2);
|
||||
scanFilter->preferredNetworkInfoList = nw_info_list;
|
||||
scanFilter->rssiThreshold = kRssiThreshold;
|
||||
}
|
||||
|
||||
void createHidlScanParamForTest(ScanParam* scanParam) {
|
||||
scanParam->disconnectedModeScanIntervalMs = kDisconnectedModeScanIntervalMs;
|
||||
std::vector<uint32_t> frequencyList{kFrequency1, kFrequency2};
|
||||
scanParam->frequencyList = frequencyList;
|
||||
std::vector<hidl_vec<uint8_t>> ssidList;
|
||||
std::vector<uint8_t> ssid1(kSsid1, kSsid1 + kSsid1_size);
|
||||
std::vector<uint8_t> ssid2(kSsid2, kSsid2 + kSsid2_size);
|
||||
ssidList.push_back(ssid1);
|
||||
ssidList.push_back(ssid2);
|
||||
scanParam->ssidList = ssidList;
|
||||
}
|
||||
|
||||
void createChreScanConfigForTest(wifi_offload::ScanConfig* scanConfig) {
|
||||
scanConfig->scan_params_.disconnected_mode_scan_interval_ms_ = kDisconnectedModeScanIntervalMs;
|
||||
wifi_offload::Ssid chreSsid1;
|
||||
chreSsid1.SetData(&kSsid1[0], kSsid1_size);
|
||||
wifi_offload::Ssid chreSsid2;
|
||||
chreSsid2.SetData(&kSsid2[0], kSsid2_size);
|
||||
scanConfig->scan_params_.ssids_to_scan_.push_back(chreSsid1);
|
||||
scanConfig->scan_params_.ssids_to_scan_.push_back(chreSsid2);
|
||||
scanConfig->scan_params_.frequencies_to_scan_mhz_.push_back(kFrequency1);
|
||||
scanConfig->scan_params_.frequencies_to_scan_mhz_.push_back(kFrequency2);
|
||||
scanConfig->scan_filter_.min_rssi_threshold_dbm_ = kRssiThreshold;
|
||||
wifi_offload::PreferredNetwork chreNwInfo1;
|
||||
chreNwInfo1.security_modes_ = kNetworkFlags;
|
||||
chreNwInfo1.ssid_.SetData(&kSsid1[0], kSsid1_size);
|
||||
scanConfig->scan_filter_.networks_to_match_.push_back(std::move(chreNwInfo1));
|
||||
wifi_offload::PreferredNetwork chreNwInfo2;
|
||||
chreNwInfo2.security_modes_ = kNetworkFlags;
|
||||
chreNwInfo2.ssid_.SetData(&kSsid2[0], kSsid2_size);
|
||||
scanConfig->scan_filter_.networks_to_match_.push_back(std::move(chreNwInfo2));
|
||||
}
|
||||
|
||||
bool validateScanResult(const std::vector<ScanResult>& hidlScanResultsTest,
|
||||
const std::vector<wifi_offload::ScanResult> chreScanResults) {
|
||||
if (hidlScanResultsTest.size() != chreScanResults.size())
|
||||
return false;
|
||||
uint32_t i = 0;
|
||||
for (const auto& hidlScanResult : hidlScanResultsTest) {
|
||||
if (hidlScanResult.tsf != chreScanResults[i].tsf_)
|
||||
return false;
|
||||
if (hidlScanResult.rssi != chreScanResults[i].rssi_dbm_)
|
||||
return false;
|
||||
if (hidlScanResult.capability != chreScanResults[i].capability_)
|
||||
return false;
|
||||
if (hidlScanResult.frequency != chreScanResults[i].frequency_scanned_mhz_)
|
||||
return false;
|
||||
for (int j = 0; j < kBssidSize; j++) {
|
||||
if (hidlScanResult.bssid[j] != chreScanResults[i].bssid_[j])
|
||||
return false;
|
||||
}
|
||||
chreWifiSsidListItem chreWifiSsid;
|
||||
chreScanResults[i].ssid_.ToChreWifiSsidListItem(&chreWifiSsid);
|
||||
for (size_t k = 0; k < chreWifiSsid.ssidLen; k++) {
|
||||
if (hidlScanResult.networkInfo.ssid[k] != chreWifiSsid.ssid[k])
|
||||
return false;
|
||||
}
|
||||
if (hidlScanResult.networkInfo.flags != kNetworkFlags) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool validateScanStats(const ScanStats& hidlScanStats,
|
||||
const wifi_offload::ScanStats& chreScanStats) {
|
||||
if (hidlScanStats.subscriptionDurationMs != chreScanStats.last_subscription_duration_ms_)
|
||||
return false;
|
||||
if (hidlScanStats.numScansRequestedByWifi != chreScanStats.num_scans_requested_by_nanoapp_)
|
||||
return false;
|
||||
if (hidlScanStats.numScansServicedByWifi != chreScanStats.num_scans_serviced_by_hardware_)
|
||||
return false;
|
||||
if (hidlScanStats.numScansServicedbyCache != chreScanStats.num_scans_serviced_by_cache_)
|
||||
return false;
|
||||
for (uint32_t i = 0; i < kNumChannelsInHistogram; i++) {
|
||||
if (hidlScanStats.histogramChannelsScanned[i] !=
|
||||
chreScanStats.channel_histogram_.GetChannelScanCount(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (hidlScanStats.scanRecord.size() != chreScanStats.scan_records_.size())
|
||||
return false;
|
||||
uint32_t i = 0;
|
||||
for (const auto& scanRecord : hidlScanStats.scanRecord) {
|
||||
if (scanRecord.durationMs != chreScanStats.scan_records_[i].time_spent_scanning_ms_)
|
||||
return false;
|
||||
if (scanRecord.numChannelsScanned != chreScanStats.scan_records_[i].num_channels_scanned_)
|
||||
return false;
|
||||
if (scanRecord.numEntriesAggregated !=
|
||||
chreScanStats.scan_records_[i].num_entries_aggregated_)
|
||||
return false;
|
||||
i++;
|
||||
}
|
||||
if (hidlScanStats.logRecord.size() != chreScanStats.rpc_log_records_.size())
|
||||
return false;
|
||||
i = 0;
|
||||
|
||||
for (const auto& logRecord : hidlScanStats.logRecord) {
|
||||
if (logRecord.recordName != kHidlRecordNameList[i]) {
|
||||
return false;
|
||||
}
|
||||
if (logRecord.logTimeMs != chreScanStats.rpc_log_records_[i].timestamp_chre_ms_)
|
||||
return false;
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace offload_hal_test_utils
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,47 +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 OFFLOAD_HAL_TEST_UTILS_
|
||||
#define OFFLOAD_HAL_TEST_UTILS_
|
||||
|
||||
#include "offload_hal_test_constants.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
namespace offload_hal_test_utils {
|
||||
|
||||
void createChreScanResultsForTest(std::vector<wifi_offload::ScanResult>* chreScanResults);
|
||||
void createChreScanStatsForTest(wifi_offload::ScanStats* chreScanStats);
|
||||
void createHidlScanFilterForTest(ScanFilter* scanFilter);
|
||||
void createHidlScanParamForTest(ScanParam* scanParam);
|
||||
void createChreScanConfigForTest(wifi_offload::ScanConfig* scanConfig);
|
||||
bool validateScanResult(const std::vector<ScanResult>& hidlScanResultsTest,
|
||||
const std::vector<wifi_offload::ScanResult> chreScanResults);
|
||||
bool validateScanStats(const ScanStats& hidlScanStats,
|
||||
const wifi_offload::ScanStats& chreScanStats);
|
||||
} // namespace offload_hal_test_utils
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // OFFLOAD_HAL_TEST_UTILS_
|
||||
@@ -1,78 +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 <gtest/gtest.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "mock_chre_interface.h"
|
||||
#include "mock_chre_interface_factory.h"
|
||||
|
||||
#include "chre_interface_callbacks.h"
|
||||
#include "offload_server.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using android::hardware::wifi::offload::V1_0::implementation::ChreInterfaceCallbacks;
|
||||
using android::hardware::wifi::offload::V1_0::implementation::MockChreInterface;
|
||||
using android::hardware::wifi::offload::V1_0::implementation::ChreInterface;
|
||||
|
||||
ChreInterface*
|
||||
CaptureCallback(ChreInterfaceCallbacks* callback,
|
||||
std::unique_ptr<ChreInterfaceCallbacks>* chre_interface_callback,
|
||||
std::unique_ptr<testing::NiceMock<MockChreInterface>>* chre_interface) {
|
||||
chre_interface->reset(new testing::NiceMock<MockChreInterface>(callback));
|
||||
chre_interface_callback->reset(callback);
|
||||
return chre_interface->get();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class OffloadServerTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
ON_CALL(*chre_interface_factory_, getChreInterface(testing::_))
|
||||
.WillByDefault(testing::Invoke(std::bind(CaptureCallback, std::placeholders::_1,
|
||||
&chre_interface_callback_, &chre_interface_)));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
|
||||
std::unique_ptr<testing::NiceMock<MockChreInterfaceFactory>> chre_interface_factory_{
|
||||
new testing::NiceMock<MockChreInterfaceFactory>()};
|
||||
std::unique_ptr<testing::NiceMock<MockChreInterface>> chre_interface_;
|
||||
std::unique_ptr<ChreInterfaceCallbacks> chre_interface_callback_;
|
||||
};
|
||||
|
||||
TEST_F(OffloadServerTest, createOffloadServerTest) {
|
||||
EXPECT_CALL(*chre_interface_factory_, getChreInterface(testing::_));
|
||||
OffloadServer* server = new OffloadServer(chre_interface_factory_.get());
|
||||
EXPECT_FALSE(chre_interface_callback_.get() == nullptr);
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,73 +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 <gtest/gtest.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include "offload_hal_test_utils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using namespace offload_hal_test_constants;
|
||||
|
||||
class OffloadUtilsTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(OffloadUtilsTest, ConvertScanResultToHidlTest) {
|
||||
std::vector<ScanResult> hidlScanResultsTest;
|
||||
std::vector<wifi_offload::ScanResult> chreScanResultsTest;
|
||||
offload_hal_test_utils::createChreScanResultsForTest(&chreScanResultsTest);
|
||||
EXPECT_TRUE(offload_utils::ToHidlScanResults(chreScanResultsTest, &hidlScanResultsTest));
|
||||
EXPECT_TRUE(
|
||||
offload_hal_test_utils::validateScanResult(hidlScanResultsTest, chreScanResultsTest));
|
||||
}
|
||||
|
||||
TEST_F(OffloadUtilsTest, ConvertScanStatsToHidlTest) {
|
||||
ScanStats hidlScanStatsTest;
|
||||
wifi_offload::ScanStats chreScanStatsTest;
|
||||
offload_hal_test_utils::createChreScanStatsForTest(&chreScanStatsTest);
|
||||
EXPECT_TRUE(offload_utils::ToHidlScanStats(chreScanStatsTest, &hidlScanStatsTest));
|
||||
EXPECT_TRUE(offload_hal_test_utils::validateScanStats(hidlScanStatsTest, chreScanStatsTest));
|
||||
}
|
||||
|
||||
TEST_F(OffloadUtilsTest, ConvertScanConfigToChreTest) {
|
||||
wifi_offload::ScanConfig scanConfigTest;
|
||||
wifi_offload::ScanConfig scanConfig;
|
||||
ScanParam scanParamTest;
|
||||
ScanFilter scanFilterTest;
|
||||
offload_hal_test_utils::createHidlScanParamForTest(&scanParamTest);
|
||||
offload_hal_test_utils::createHidlScanFilterForTest(&scanFilterTest);
|
||||
offload_hal_test_utils::createChreScanConfigForTest(&scanConfig);
|
||||
EXPECT_TRUE(offload_utils::ToChreScanConfig(scanParamTest, scanFilterTest, &scanConfigTest));
|
||||
EXPECT_TRUE(scanConfig == scanConfigTest);
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
if [ -z $ANDROID_BUILD_TOP ]; then
|
||||
echo "You need to source and lunch before you can use this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Running tests"
|
||||
set -e # fail early
|
||||
|
||||
# NOTE We can't actually run these commands, since they rely on functions added by
|
||||
# build/envsetup.sh to the bash shell environment.
|
||||
echo "+ mmma -j32 $ANDROID_BUILD_TOP/device/google/wahoo"
|
||||
make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk \
|
||||
MODULES-IN-device-google-wahoo-wifi_offload
|
||||
|
||||
set -x # print commands
|
||||
|
||||
adb root
|
||||
adb wait-for-device
|
||||
adb remount
|
||||
adb sync
|
||||
|
||||
adb shell /data/nativetest/vendor/wifi-offload-service-unit-tests/wifi-offload-service-unit-tests
|
||||
adb shell /data/nativetest64/vendor/wifi-offload-service-unit-tests/wifi-offload-service-unit-tests
|
||||
Reference in New Issue
Block a user