blob: 7bbc09e45c122e1fbae12623db319e774337f964 [file] [log] [blame]
Amy126ee922019-08-09 16:25:12 -07001/*
2 * Copyright 2019 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.0-service-lazy"
20#else
21#define LOG_TAG "android.hardware.tv.tuner@1.0-service"
22#endif
23
Amy126ee922019-08-09 16:25:12 -070024#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::ITuner;
33using android::hardware::tv::tuner::V1_0::implementation::Tuner;
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) {
Peter Kalauskas600809e2019-08-14 12:11:57 -070048 auto serviceRegistrar = LazyServiceRegistrar::getInstance();
49 status = serviceRegistrar.registerService(service);
Amy126ee922019-08-09 16:25:12 -070050 } 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}