platform_hardware_interfaces/tv/tuner/1.1/default/service.cpp
Amy Zhang bb94eeb456 Add default implementation of Tuner HAL 1.1
This CL enables the android.hardware.tv.tuner@1.1-service
with the default implementation of Tuner HAL 1.1

The 1.0 Tuner HAL interface implementation are identical to the 1.0
default implementation.
The 1.1 new API implementation are added with *_1_1 suffix.

Note that we cast all the uint32_t id in the 1.0 Hal implementation
into uint64_t even calling the old 1.0 APIs. This makes sure
the 1.1 default implementation internally only record 64-bit ids.

Test: atest VtsHalTvTunerV1_1TargetTest
Bug: b/159058358
Change-Id: Ic506376e520f03235010bc503e337c02d5735ec3
2020-07-21 22:43:06 -07:00

57 lines
1.7 KiB
C++

/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//#define LOG_NDEBUG 0
#ifdef LAZY_SERVICE
#define LOG_TAG "android.hardware.tv.tuner@1.1-service-lazy"
#else
#define LOG_TAG "android.hardware.tv.tuner@1.1-service"
#endif
#include <hidl/HidlTransportSupport.h>
#include <hidl/LegacySupport.h>
#include "Tuner.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::LazyServiceRegistrar;
using android::hardware::tv::tuner::V1_0::implementation::Tuner;
using android::hardware::tv::tuner::V1_1::ITuner;
#ifdef LAZY_SERVICE
const bool kLazyService = true;
#else
const bool kLazyService = false;
#endif
int main() {
configureRpcThreadpool(8, true /* callerWillJoin */);
// Setup hwbinder service
android::sp<ITuner> service = new Tuner();
android::status_t status;
if (kLazyService) {
auto serviceRegistrar = LazyServiceRegistrar::getInstance();
status = serviceRegistrar.registerService(service);
} else {
status = service->registerAsService();
}
LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering tuner service: %d", status);
joinRpcThreadpool();
return 0;
}