Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f6e6e3a authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Add new lazy wifi HAL target

Devices can use the lazy wifi HAL to allow it to exit when wifi is not
in use.

Test: Flash walleye_svelte-userdebug and check that HAL only runs when
      wifi is on.
Bug: 123307146
Change-Id: If20120f902a7e102372666447b39cf9fdad7d352
parent 67bd9eb9
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -97,6 +97,37 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc
include $(BUILD_EXECUTABLE)

###
### android.hardware.wifi daemon
###
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.wifi@1.0-service-lazy
LOCAL_OVERRIDES_MODULES := android.hardware.wifi@1.0-service
LOCAL_CFLAGS := -DLAZY_SERVICE
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
LOCAL_SRC_FILES := \
    service.cpp
LOCAL_SHARED_LIBRARIES := \
    libbase \
    libcutils \
    libhidlbase \
    libhidltransport \
    liblog \
    libnl \
    libutils \
    libwifi-hal \
    libwifi-system-iface \
    android.hardware.wifi@1.0 \
    android.hardware.wifi@1.1 \
    android.hardware.wifi@1.2 \
    android.hardware.wifi@1.3
LOCAL_STATIC_LIBRARIES := \
    android.hardware.wifi@1.0-service-lib
LOCAL_INIT_RC := android.hardware.wifi@1.0-service-lazy.rc
include $(BUILD_EXECUTABLE)

###
### android.hardware.wifi unit tests.
###
+8 −0
Original line number Diff line number Diff line
service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service-lazy
    interface android.hardware.wifi@1.0::IWifi default
    oneshot
    disabled
    class hal
    capabilities NET_ADMIN NET_RAW SYS_MODULE
    user wifi
    group wifi gps
+16 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include <android-base/logging.h>
#include <hidl/HidlLazyUtils.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/Looper.h>
#include <utils/StrongPointer.h>
@@ -26,12 +27,19 @@

using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::LazyServiceRegistrar;
using android::hardware::wifi::V1_3::implementation::feature_flags::
    WifiFeatureFlags;
using android::hardware::wifi::V1_3::implementation::legacy_hal::WifiLegacyHal;
using android::hardware::wifi::V1_3::implementation::mode_controller::
    WifiModeController;

#ifdef LAZY_SERVICE
const bool kLazyService = true;
#else
const bool kLazyService = false;
#endif

int main(int /*argc*/, char** argv) {
    android::base::InitLogging(
        argv, android::base::LogdLogger(android::base::SYSTEM));
@@ -45,8 +53,14 @@ int main(int /*argc*/, char** argv) {
            std::make_shared<WifiLegacyHal>(),
            std::make_shared<WifiModeController>(),
            std::make_shared<WifiFeatureFlags>());
    if (kLazyService) {
        LazyServiceRegistrar registrar;
        CHECK_EQ(registrar.registerService(service), android::NO_ERROR)
            << "Failed to register wifi HAL";
    } else {
        CHECK_EQ(service->registerAsService(), android::NO_ERROR)
            << "Failed to register wifi HAL";
    }

    joinRpcThreadpool();