blob: c874d8b19922293d9ca71c3b04bba154caa949bd [file] [log] [blame]
Gabriel Biren631a8112022-12-01 22:29:32 +00001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android-base/logging.h>
18#include <hidl/HidlLazyUtils.h>
19#include <hidl/HidlTransportSupport.h>
20#include <signal.h>
21#include <utils/Looper.h>
22#include <utils/StrongPointer.h>
23
24#include "wifi.h"
25#include "wifi_feature_flags.h"
26#include "wifi_legacy_hal.h"
27#include "wifi_legacy_hal_factory.h"
28#include "wifi_mode_controller.h"
29
30using android::hardware::configureRpcThreadpool;
31using android::hardware::joinRpcThreadpool;
32using android::hardware::LazyServiceRegistrar;
33using android::hardware::wifi::V1_6::implementation::feature_flags::WifiFeatureFlags;
34using android::hardware::wifi::V1_6::implementation::legacy_hal::WifiLegacyHal;
35using android::hardware::wifi::V1_6::implementation::legacy_hal::WifiLegacyHalFactory;
36using android::hardware::wifi::V1_6::implementation::mode_controller::WifiModeController;
37
38#ifdef LAZY_SERVICE
39const bool kLazyService = true;
40#else
41const bool kLazyService = false;
42#endif
43
44int main(int /*argc*/, char** argv) {
45 signal(SIGPIPE, SIG_IGN);
46 android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM));
47 LOG(INFO) << "Wifi Hal is booting up...";
48
49 configureRpcThreadpool(1, true /* callerWillJoin */);
50
51 const auto iface_tool = std::make_shared<android::wifi_system::InterfaceTool>();
52 const auto legacy_hal_factory = std::make_shared<WifiLegacyHalFactory>(iface_tool);
53
54 // Setup hwbinder service
55 android::sp<android::hardware::wifi::V1_6::IWifi> service =
56 new android::hardware::wifi::V1_6::implementation::Wifi(
57 iface_tool, legacy_hal_factory, std::make_shared<WifiModeController>(),
58 std::make_shared<WifiFeatureFlags>());
59 if (kLazyService) {
60 auto registrar = LazyServiceRegistrar::getInstance();
61 CHECK_EQ(registrar.registerService(service), android::NO_ERROR)
62 << "Failed to register wifi HAL";
63 } else {
64 CHECK_EQ(service->registerAsService(), android::NO_ERROR) << "Failed to register wifi HAL";
65 }
66
67 joinRpcThreadpool();
68
69 LOG(INFO) << "Wifi Hal is terminating...";
70 return 0;
71}