mirror of
https://github.com/Evolution-X-Devices/device_google_wahoo
synced 2026-02-01 03:40:35 +00:00
Offload HAL Service: Implements Offload HAL
Define OffloadServer class that implements the Offload HAL service and the callback interface to the CHRE platform. This is where the communication to the CHRE interface will take place and this class is created to be testable for unit testing. Bug: 32842314 Test: VTS Change-Id: I9c259ab2b721d7d1ac8cb16083c464002c237a16
This commit is contained in:
@@ -21,6 +21,7 @@ cc_binary {
|
||||
"service.cpp",
|
||||
"chre_constants.cpp",
|
||||
"chre_interface.cpp",
|
||||
"offload_server.cpp",
|
||||
],
|
||||
cflags: ["-Wall", "-Wextra"],
|
||||
shared_libs: [
|
||||
|
||||
75
wifi_offload/offload_server.cpp
Normal file
75
wifi_offload/offload_server.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "offload_server.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace offload {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
class OffloadServer;
|
||||
|
||||
OffloadServer::OffloadServer() : mChreInterfaceCallbacks(new ChreInterfaceCallbacksImpl(this)) {
|
||||
LOG(VERBOSE) << "Wifi Offload HAL impl";
|
||||
}
|
||||
|
||||
bool OffloadServer::configureScans(const ScanParam& param, const ScanFilter& filter) {
|
||||
LOG(INFO) << "configureScans";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<ScanStats, bool> OffloadServer::getScanStats() {
|
||||
LOG(INFO) << "getScanStats";
|
||||
return std::make_pair(mScanStats, true);
|
||||
}
|
||||
|
||||
bool OffloadServer::subscribeScanResults(uint32_t delayMs) {
|
||||
LOG(INFO) << "subscribeScanResults with delay:" << delayMs;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffloadServer::unsubscribeScanResults() {
|
||||
LOG(INFO) << "unsubscribeScanResults";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffloadServer::setEventCallback(const sp<IOffloadCallback>& cb) {
|
||||
LOG(INFO) << "Set Event callback";
|
||||
bool result = false;
|
||||
if (cb != nullptr) {
|
||||
mEventCallback = cb;
|
||||
result = true;
|
||||
} else {
|
||||
LOG(WARNING) << "Invalid callback object";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ChreInterfaceCallbacksImpl::ChreInterfaceCallbacksImpl(OffloadServer* server) : mServer(server) {
|
||||
}
|
||||
|
||||
ChreInterfaceCallbacksImpl::~ChreInterfaceCallbacksImpl() {
|
||||
}
|
||||
|
||||
void ChreInterfaceCallbacksImpl::handleConnectionEvents(
|
||||
ChreInterfaceCallbacks::ConnectionEvent event) {
|
||||
LOG(VERBOSE) << "Connection event received " << (int)event;
|
||||
}
|
||||
|
||||
void ChreInterfaceCallbacksImpl::handleMessage(uint32_t messageType,
|
||||
const std::vector<uint8_t>& message) {
|
||||
LOG(VERBOSE) << "Message from Nano app " << messageType;
|
||||
}
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
57
wifi_offload/offload_server.h
Normal file
57
wifi_offload/offload_server.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef WIFI_OFFLOAD_SERVER_H_
|
||||
#define WIFI_OFFLOAD_SERVER_H_
|
||||
|
||||
#include <android/hardware/wifi/offload/1.0/IOffload.h>
|
||||
|
||||
#include "chre_interface_callbacks.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();
|
||||
|
||||
bool configureScans(const ScanParam& param, const ScanFilter& filter);
|
||||
std::pair<ScanStats, bool> getScanStats();
|
||||
bool subscribeScanResults(uint32_t delayMs);
|
||||
bool unsubscribeScanResults();
|
||||
bool setEventCallback(const sp<IOffloadCallback>& cb);
|
||||
|
||||
private:
|
||||
ScanStats mScanStats;
|
||||
std::unique_ptr<ChreInterfaceCallbacksImpl> mChreInterfaceCallbacks;
|
||||
sp<IOffloadCallback> mEventCallback;
|
||||
|
||||
friend class ChreInterfaceCallbacksImpl;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace offload
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_OFFLOAD_SERVER_H_
|
||||
Reference in New Issue
Block a user