Wifi Offload HAL implementation for V1.0 interface

Implements Offload HAL HIDL service for Wifi Offload v1.0 interface

Bug: 32842314
Test: Unit tests and Mannual test to ensure service is running
Change-Id: I9612ec28b9b042be10b7e022362124de906649ab
This commit is contained in:
Sohani Rao
2017-04-03 17:48:32 -07:00
parent 8a611aeffe
commit a25b59e448
6 changed files with 200 additions and 0 deletions

View File

@@ -348,6 +348,7 @@ PRODUCT_PACKAGES += $(WPA)
PRODUCT_PACKAGES += \
android.hardware.wifi@1.0-service \
android.hardware.wifi.offload@1.0-service \
wificond \
wifilogd

35
wifi_offload/Android.mk Normal file
View File

@@ -0,0 +1,35 @@
# 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.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.wifi.offload@1.0-service
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
LOCAL_SRC_FILES := \
Offload.cpp \
service.cpp
LOCAL_SHARED_LIBRARIES := \
android.hardware.wifi.offload@1.0 \
libbase \
libcutils \
libhidlbase \
libhidltransport \
liblog \
libutils
LOCAL_INIT_RC := android.hardware.wifi.offload@1.0-service.rc
include $(BUILD_EXECUTABLE)

60
wifi_offload/Offload.cpp Normal file
View File

@@ -0,0 +1,60 @@
#include "Offload.h"
#include <android-base/logging.h>
namespace android {
namespace hardware {
namespace wifi {
namespace offload {
namespace V1_0 {
namespace implementation {
Offload::Offload()
: mOffloadEnabled(false), mSubscriptionTimeMs(0), mSubscriptionDelayMs(0) {
// TODO: Load Nano app
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();
}
Return<void> Offload::getScanStats(getScanStats_cb offloadScanStatsCallback) {
ScanStats* pScanStats = new ScanStats();
// TODO: implement getting scan stats from Wifi Nano app
offloadScanStatsCallback(*pScanStats);
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
return Void();
}
Return<void> Offload::unsubscribeScanResults() {
mOffloadEnabled = false;
// TODO: implement updating Wifi Nano app
return Void();
}
Return<void> Offload::setEventCallback(const sp<IOffloadCallback>& cb) {
Offload::mScanEventCallback = cb;
return Void();
}
// Methods from ::android::hidl::base::V1_0::IBase follow.
} // namespace implementation
} // namespace V1_0
} // namespace offload
} // namespace wifi
} // namespace hardware
} // namespace android

51
wifi_offload/Offload.h Normal file
View File

@@ -0,0 +1,51 @@
#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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
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& param,
const ScanFilter& filter) override;
Return<void> getScanStats(
getScanStats_cb offloadScanStatsCallback) override;
Return<void> subscribeScanResults(uint32_t delayMs) override;
Return<void> unsubscribeScanResults() override;
Return<void> setEventCallback(const sp<IOffloadCallback>& cb) override;
// 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;
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

View File

@@ -0,0 +1,4 @@
service offload-hal-1-0 /vendor/bin/hw/android.hardware.wifi.offload@1.0-service
class hal
user wifi
group wifi

49
wifi_offload/service.cpp Normal file
View File

@@ -0,0 +1,49 @@
/*
* 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;
}