blob: 232030850d420f2dc39a124dff77c1aac50d534b [file] [log] [blame]
Amy Zhangbb94eeb2020-07-09 22:48:04 -07001/*
2 * Copyright 2020 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//#define LOG_NDEBUG 0
18#ifdef LAZY_SERVICE
19#define LOG_TAG "android.hardware.tv.tuner@1.1-service-lazy"
20#else
21#define LOG_TAG "android.hardware.tv.tuner@1.1-service"
22#endif
23
24#include <hidl/HidlTransportSupport.h>
25#include <hidl/LegacySupport.h>
26
27#include "Tuner.h"
28
29using android::hardware::configureRpcThreadpool;
30using android::hardware::joinRpcThreadpool;
31using android::hardware::LazyServiceRegistrar;
32using android::hardware::tv::tuner::V1_0::implementation::Tuner;
33using android::hardware::tv::tuner::V1_1::ITuner;
34
35#ifdef LAZY_SERVICE
36const bool kLazyService = true;
37#else
38const bool kLazyService = false;
39#endif
40
41int main() {
42 configureRpcThreadpool(8, true /* callerWillJoin */);
43
44 // Setup hwbinder service
45 android::sp<ITuner> service = new Tuner();
46 android::status_t status;
47 if (kLazyService) {
48 auto serviceRegistrar = LazyServiceRegistrar::getInstance();
49 status = serviceRegistrar.registerService(service);
50 } else {
51 status = service->registerAsService();
52 }
53 LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering tuner service: %d", status);
54
55 joinRpcThreadpool();
56 return 0;
57}