2017-04-25 02:18:25 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2017 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
|
2018-11-05 21:05:29 +01:00
|
|
|
#ifdef LAZY_SERVICE
|
|
|
|
#define LOG_TAG "android.hardware.cas@1.0-service-lazy"
|
|
|
|
#else
|
2017-04-25 02:18:25 +02:00
|
|
|
#define LOG_TAG "android.hardware.cas@1.0-service"
|
2018-11-05 21:05:29 +01:00
|
|
|
#endif
|
2017-04-25 02:18:25 +02:00
|
|
|
|
|
|
|
#include <binder/ProcessState.h>
|
|
|
|
#include <hidl/HidlTransportSupport.h>
|
|
|
|
#include <hidl/LegacySupport.h>
|
|
|
|
|
|
|
|
#include "MediaCasService.h"
|
|
|
|
|
|
|
|
using android::hardware::configureRpcThreadpool;
|
|
|
|
using android::hardware::joinRpcThreadpool;
|
2018-11-05 21:05:29 +01:00
|
|
|
using android::hardware::LazyServiceRegistrar;
|
2017-04-25 02:18:25 +02:00
|
|
|
using android::hardware::cas::V1_0::IMediaCasService;
|
2018-11-05 21:05:29 +01:00
|
|
|
using android::hardware::cas::V1_0::implementation::MediaCasService;
|
2017-04-25 02:18:25 +02:00
|
|
|
|
2018-11-05 21:05:29 +01:00
|
|
|
#ifdef LAZY_SERVICE
|
|
|
|
const bool kLazyService = true;
|
|
|
|
#else
|
|
|
|
const bool kLazyService = false;
|
|
|
|
#endif
|
2017-04-25 02:18:25 +02:00
|
|
|
|
2018-11-05 21:05:29 +01:00
|
|
|
int main() {
|
2017-04-25 02:18:25 +02:00
|
|
|
configureRpcThreadpool(8, true /* callerWillJoin */);
|
|
|
|
|
|
|
|
// Setup hwbinder service
|
|
|
|
android::sp<IMediaCasService> service = new MediaCasService();
|
2018-11-05 21:05:29 +01:00
|
|
|
android::status_t status;
|
|
|
|
if (kLazyService) {
|
2019-08-14 21:11:57 +02:00
|
|
|
auto serviceRegistrar = LazyServiceRegistrar::getInstance();
|
|
|
|
status = serviceRegistrar.registerService(service);
|
2018-11-05 21:05:29 +01:00
|
|
|
} else {
|
|
|
|
status = service->registerAsService();
|
|
|
|
}
|
|
|
|
LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering cas service: %d", status);
|
|
|
|
|
2017-04-25 02:18:25 +02:00
|
|
|
joinRpcThreadpool();
|
|
|
|
return 0;
|
|
|
|
}
|