blob: c874d8b19922293d9ca71c3b04bba154caa949bd [file] [log] [blame]
Roshan Pius3c4e8a32016-10-03 14:53:58 -07001/*
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>
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080018#include <hidl/HidlLazyUtils.h>
Martijn Coenen4faa7f52016-12-28 17:08:07 +010019#include <hidl/HidlTransportSupport.h>
lesl75915c32020-11-30 19:09:31 +080020#include <signal.h>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070021#include <utils/Looper.h>
22#include <utils/StrongPointer.h>
23
24#include "wifi.h"
Roshan Pius200a17d2017-11-01 13:03:35 -070025#include "wifi_feature_flags.h"
26#include "wifi_legacy_hal.h"
Jimmy Chen2dddd792019-12-23 17:50:39 +020027#include "wifi_legacy_hal_factory.h"
Roshan Pius200a17d2017-11-01 13:03:35 -070028#include "wifi_mode_controller.h"
Roshan Pius3c4e8a32016-10-03 14:53:58 -070029
Martijn Coenen4faa7f52016-12-28 17:08:07 +010030using android::hardware::configureRpcThreadpool;
31using android::hardware::joinRpcThreadpool;
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080032using android::hardware::LazyServiceRegistrar;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080033using 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;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070037
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080038#ifdef LAZY_SERVICE
39const bool kLazyService = true;
40#else
41const bool kLazyService = false;
42#endif
43
Roshan Pius3c4e8a32016-10-03 14:53:58 -070044int main(int /*argc*/, char** argv) {
lesl75915c32020-11-30 19:09:31 +080045 signal(SIGPIPE, SIG_IGN);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080046 android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM));
Roshan Piusabcf78f2017-10-06 16:30:38 -070047 LOG(INFO) << "Wifi Hal is booting up...";
Roshan Pius3c4e8a32016-10-03 14:53:58 -070048
Roshan Piusabcf78f2017-10-06 16:30:38 -070049 configureRpcThreadpool(1, true /* callerWillJoin */);
Roshan Pius3c4e8a32016-10-03 14:53:58 -070050
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080051 const auto iface_tool = std::make_shared<android::wifi_system::InterfaceTool>();
52 const auto legacy_hal_factory = std::make_shared<WifiLegacyHalFactory>(iface_tool);
Jimmy Chen2dddd792019-12-23 17:50:39 +020053
Roshan Piusabcf78f2017-10-06 16:30:38 -070054 // Setup hwbinder service
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080055 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>());
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080059 if (kLazyService) {
Peter Kalauskascaed24b2019-08-14 12:11:57 -070060 auto registrar = LazyServiceRegistrar::getInstance();
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080061 CHECK_EQ(registrar.registerService(service), android::NO_ERROR)
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080062 << "Failed to register wifi HAL";
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080063 } else {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080064 CHECK_EQ(service->registerAsService(), android::NO_ERROR) << "Failed to register wifi HAL";
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080065 }
Roshan Pius3c4e8a32016-10-03 14:53:58 -070066
Roshan Piusabcf78f2017-10-06 16:30:38 -070067 joinRpcThreadpool();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070068
Roshan Piusabcf78f2017-10-06 16:30:38 -070069 LOG(INFO) << "Wifi Hal is terminating...";
70 return 0;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070071}