blob: c177dd1233208dace650343f9f122acf034ce675 [file] [log] [blame]
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -07001/*
2 * Copyright (C) 2021 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 "hidl-utils.h"
18
19#include <android-base/logging.h>
20#include <android/binder_manager.h>
21#include <android/binder_process.h>
22#include <libradiocompat/RadioConfig.h>
23
24namespace android::hardware::radio::service {
25
26using namespace std::string_literals;
27
28static std::vector<std::shared_ptr<ndk::ICInterface>> gPublishedHals;
29
30static void publishRadioConfig() {
31 auto hidlHal = config::V1_1::IRadioConfig::getService();
32 CHECK(hidlHal) << "HIDL IRadioConfig not present in VINTF";
33
34 hidl_utils::linkDeathToDeath(hidlHal);
35
36 auto aidlHal = ndk::SharedRefBase::make<compat::RadioConfig>(hidlHal);
37 gPublishedHals.push_back(aidlHal);
38 const auto instance = compat::RadioConfig::descriptor + "/default"s;
39 const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str());
40 CHECK_EQ(status, STATUS_OK);
41}
42
43static void main() {
44 base::SetDefaultTag("radiocompat");
45 base::SetMinimumLogSeverity(base::VERBOSE);
46 LOG(DEBUG) << "Radio HAL compat service starting...";
47
48 publishRadioConfig();
49
50 LOG(DEBUG) << "Radio HAL compat service is operational";
51 ABinderProcess_joinThreadPool();
52 LOG(FATAL) << "Radio HAL compat service has stopped";
53}
54
55} // namespace android::hardware::radio::service
56
57int main() {
58 android::hardware::radio::service::main();
59 return EXIT_FAILURE; // should not reach
60}