blob: 6bf20d5dbb1c8b634f79269a95a108d0d77d30b4 [file] [log] [blame]
Weilin Xub2a6ca62022-05-08 23:47:04 +00001/*
2 * Copyright (C) 2022 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 "BroadcastRadio.h"
18#include "VirtualRadio.h"
19
20#include <android-base/logging.h>
21#include <android/binder_manager.h>
22#include <android/binder_process.h>
23
24using ::aidl::android::hardware::broadcastradio::BroadcastRadio;
25using ::aidl::android::hardware::broadcastradio::VirtualRadio;
26
27int main() {
28 android::base::SetDefaultTag("BcRadioAidlDef");
29 ABinderProcess_setThreadPoolMaxThreadCount(4);
30 ABinderProcess_startThreadPool();
31
32 const VirtualRadio& amFmRadioMock = VirtualRadio::getAmFmRadio();
33 std::shared_ptr<BroadcastRadio> broadcastRadio =
34 ::ndk::SharedRefBase::make<BroadcastRadio>(amFmRadioMock);
35 const std::string instanceAmFm = std::string() + BroadcastRadio::descriptor + "/amfm";
36 binder_status_t statusAmFm =
37 AServiceManager_addService(broadcastRadio->asBinder().get(), instanceAmFm.c_str());
38 CHECK_EQ(statusAmFm, STATUS_OK)
39 << "Failed to register Broadcast Radio AM/FM HAL implementation";
40
41 const VirtualRadio& dabRadioMock = VirtualRadio::getDabRadio();
42 std::shared_ptr<BroadcastRadio> dabRadio =
43 ::ndk::SharedRefBase::make<BroadcastRadio>(dabRadioMock);
44 const std::string instanceDab = std::string() + BroadcastRadio::descriptor + "/dab";
45 binder_status_t statusDab =
46 AServiceManager_addService(dabRadio->asBinder().get(), instanceDab.c_str());
47 CHECK_EQ(statusDab, STATUS_OK) << "Failed to register Broadcast Radio DAB HAL implementation";
48
49 ABinderProcess_joinThreadPool();
50 return EXIT_FAILURE; // should not reach
51}