mirror of
https://github.com/Evolution-X-Devices/device_google_wahoo
synced 2026-02-01 07:50:47 +00:00
Offload HAL Service: Invoke Server implementation
Offload HAL service implementation to invoke the OffloadServer API. Bug: 32842314 Test: VTS Change-Id: Iacb77317cc6bdcc453a93e395403cb649eab28b4
This commit is contained in:
@@ -34,6 +34,6 @@ cc_binary {
|
||||
"android.hardware.wifi.offload@1.0",
|
||||
],
|
||||
static_libs: ["chre_client"],
|
||||
proprietary: true,
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "Offload.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "chre_interface_factory.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
@@ -8,45 +11,47 @@ namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Offload::Offload()
|
||||
: mOffloadEnabled(false), mSubscriptionTimeMs(0), mSubscriptionDelayMs(0) {
|
||||
// TODO: Load Nano app
|
||||
Offload::Offload() : mOffloadServer(new OffloadServer(new ChreInterfaceFactory())) {
|
||||
LOG(android::base::INFO) << "Wifi Offload HAL impl";
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::wifi::offload::V1_0::IOffload follow.
|
||||
Return<void> Offload::configureScans(const ScanParam& param,
|
||||
const ScanFilter& filter) {
|
||||
mScanParam = param;
|
||||
mScanFilter = filter;
|
||||
// TODO: implement Wifi Nano app scan configuration
|
||||
Return<void> Offload::configureScans(const ScanParam& param, const ScanFilter& filter) {
|
||||
if (!mOffloadServer->configureScans(param, filter)) {
|
||||
LOG(ERROR) << "Failure configuring scans";
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Offload::getScanStats(getScanStats_cb offloadScanStatsCallback) {
|
||||
ScanStats* pScanStats = new ScanStats();
|
||||
// TODO: implement getting scan stats from Wifi Nano app
|
||||
offloadScanStatsCallback(*pScanStats);
|
||||
ScanStats stats;
|
||||
bool success;
|
||||
std::tie(stats, success) = mOffloadServer->getScanStats();
|
||||
if (!success) {
|
||||
LOG(ERROR) << "Invalid results reported";
|
||||
}
|
||||
offloadScanStatsCallback(stats);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Offload::subscribeScanResults(uint32_t delayMs) {
|
||||
mOffloadEnabled = true;
|
||||
// TODO: get current system time
|
||||
mSubscriptionTimeMs = 0;
|
||||
mSubscriptionDelayMs = delayMs;
|
||||
// TODO implement informing Wifi Nano App
|
||||
if (!mOffloadServer->subscribeScanResults(delayMs)) {
|
||||
LOG(ERROR) << "Unable to subscribe scans";
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Offload::unsubscribeScanResults() {
|
||||
mOffloadEnabled = false;
|
||||
// TODO: implement updating Wifi Nano app
|
||||
if (!mOffloadServer->unsubscribeScanResults()) {
|
||||
LOG(ERROR) << "Unable to unsubscribe";
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Offload::setEventCallback(const sp<IOffloadCallback>& cb) {
|
||||
Offload::mScanEventCallback = cb;
|
||||
if (!mOffloadServer->setEventCallback(cb)) {
|
||||
LOG(ERROR) << "No callback set";
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include "offload_server.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
@@ -32,14 +34,9 @@ class Offload : public IOffload {
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
private:
|
||||
bool mOffloadEnabled;
|
||||
uint64_t mSubscriptionTimeMs;
|
||||
uint32_t mSubscriptionDelayMs;
|
||||
ScanParam mScanParam;
|
||||
ScanFilter mScanFilter;
|
||||
sp<IOffloadCallback> mScanEventCallback;
|
||||
std::unique_ptr<OffloadServer> mOffloadServer;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Offload);
|
||||
DISALLOW_COPY_AND_ASSIGN(Offload);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace implementation {
|
||||
|
||||
class OffloadServer;
|
||||
|
||||
OffloadServer::OffloadServer() : mChreInterfaceCallbacks(new ChreInterfaceCallbacksImpl(this)) {
|
||||
OffloadServer::OffloadServer(ChreInterfaceFactory* factory)
|
||||
: mChreInterfaceCallbacks(new ChreInterfaceCallbacksImpl(this)),
|
||||
mChreInterface(factory->getChreInterface(mChreInterfaceCallbacks.get())) {
|
||||
LOG(VERBOSE) << "Wifi Offload HAL impl";
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
|
||||
#include "chre_interface_callbacks.h"
|
||||
#include "chre_interface_factory.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -31,7 +31,7 @@ class ChreInterfaceCallbacksImpl : public ChreInterfaceCallbacks {
|
||||
*/
|
||||
class OffloadServer {
|
||||
public:
|
||||
OffloadServer();
|
||||
OffloadServer(ChreInterfaceFactory* factory);
|
||||
|
||||
bool configureScans(const ScanParam& param, const ScanFilter& filter);
|
||||
std::pair<ScanStats, bool> getScanStats();
|
||||
@@ -42,6 +42,7 @@ class OffloadServer {
|
||||
private:
|
||||
ScanStats mScanStats;
|
||||
std::unique_ptr<ChreInterfaceCallbacksImpl> mChreInterfaceCallbacks;
|
||||
std::unique_ptr<ChreInterface> mChreInterface;
|
||||
sp<IOffloadCallback> mEventCallback;
|
||||
|
||||
friend class ChreInterfaceCallbacksImpl;
|
||||
|
||||
Reference in New Issue
Block a user