blob: 0b41d28da9f1495dc1c443c3446a046d5e31a1f8 [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>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070020#include <utils/Looper.h>
21#include <utils/StrongPointer.h>
22
23#include "wifi.h"
Roshan Pius200a17d2017-11-01 13:03:35 -070024#include "wifi_feature_flags.h"
25#include "wifi_legacy_hal.h"
26#include "wifi_mode_controller.h"
Roshan Pius3c4e8a32016-10-03 14:53:58 -070027
Martijn Coenen4faa7f52016-12-28 17:08:07 +010028using android::hardware::configureRpcThreadpool;
29using android::hardware::joinRpcThreadpool;
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080030using android::hardware::LazyServiceRegistrar;
Jong Wook Kimda830c92018-07-23 15:29:38 -070031using android::hardware::wifi::V1_3::implementation::feature_flags::
Roshan Pius200a17d2017-11-01 13:03:35 -070032 WifiFeatureFlags;
Roshan Pius99dab382019-02-14 07:57:10 -080033using android::hardware::wifi::V1_3::implementation::iface_util::WifiIfaceUtil;
Jong Wook Kimda830c92018-07-23 15:29:38 -070034using android::hardware::wifi::V1_3::implementation::legacy_hal::WifiLegacyHal;
35using android::hardware::wifi::V1_3::implementation::mode_controller::
Roshan Pius200a17d2017-11-01 13:03:35 -070036 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) {
Roshan Piusabcf78f2017-10-06 16:30:38 -070045 android::base::InitLogging(
46 argv, android::base::LogdLogger(android::base::SYSTEM));
47 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
Roshan Piusc885df02019-05-21 14:49:05 -070051 const auto iface_tool =
52 std::make_shared<android::wifi_system::InterfaceTool>();
Roshan Piusabcf78f2017-10-06 16:30:38 -070053 // Setup hwbinder service
Jong Wook Kimda830c92018-07-23 15:29:38 -070054 android::sp<android::hardware::wifi::V1_3::IWifi> service =
55 new android::hardware::wifi::V1_3::implementation::Wifi(
Roshan Piusc885df02019-05-21 14:49:05 -070056 iface_tool, std::make_shared<WifiLegacyHal>(iface_tool),
Roshan Pius200a17d2017-11-01 13:03:35 -070057 std::make_shared<WifiModeController>(),
Roshan Piusc885df02019-05-21 14:49:05 -070058 std::make_shared<WifiIfaceUtil>(iface_tool),
Roshan Pius200a17d2017-11-01 13:03:35 -070059 std::make_shared<WifiFeatureFlags>());
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080060 if (kLazyService) {
Peter Kalauskascaed24b2019-08-14 12:11:57 -070061 auto registrar = LazyServiceRegistrar::getInstance();
Peter Kalauskas1f6e6e32019-01-14 17:11:31 -080062 CHECK_EQ(registrar.registerService(service), android::NO_ERROR)
63 << "Failed to register wifi HAL";
64 } else {
65 CHECK_EQ(service->registerAsService(), android::NO_ERROR)
66 << "Failed to register wifi HAL";
67 }
Roshan Pius3c4e8a32016-10-03 14:53:58 -070068
Roshan Piusabcf78f2017-10-06 16:30:38 -070069 joinRpcThreadpool();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070070
Roshan Piusabcf78f2017-10-06 16:30:38 -070071 LOG(INFO) << "Wifi Hal is terminating...";
72 return 0;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070073}