blob: 516acfbfc6fb5d763b58d20a9bf0aa93f7ea8a50 [file] [log] [blame]
Chong Zhanga4f67512017-04-24 17:18:25 -07001/*
2 * Copyright 2017 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
Peter Kalauskasf646be02018-11-05 12:05:29 -080018#ifdef LAZY_SERVICE
19#define LOG_TAG "android.hardware.cas@1.0-service-lazy"
20#else
Chong Zhanga4f67512017-04-24 17:18:25 -070021#define LOG_TAG "android.hardware.cas@1.0-service"
Peter Kalauskasf646be02018-11-05 12:05:29 -080022#endif
Chong Zhanga4f67512017-04-24 17:18:25 -070023
24#include <binder/ProcessState.h>
25#include <hidl/HidlTransportSupport.h>
26#include <hidl/LegacySupport.h>
27
28#include "MediaCasService.h"
29
30using android::hardware::configureRpcThreadpool;
31using android::hardware::joinRpcThreadpool;
Peter Kalauskasf646be02018-11-05 12:05:29 -080032using android::hardware::LazyServiceRegistrar;
Chong Zhanga4f67512017-04-24 17:18:25 -070033using android::hardware::cas::V1_0::IMediaCasService;
Peter Kalauskasf646be02018-11-05 12:05:29 -080034using android::hardware::cas::V1_0::implementation::MediaCasService;
35
36#ifdef LAZY_SERVICE
37const bool kLazyService = true;
38#else
39const bool kLazyService = false;
40#endif
Chong Zhanga4f67512017-04-24 17:18:25 -070041
42int main() {
Chong Zhanga4f67512017-04-24 17:18:25 -070043 configureRpcThreadpool(8, true /* callerWillJoin */);
44
45 // Setup hwbinder service
46 android::sp<IMediaCasService> service = new MediaCasService();
Peter Kalauskasf646be02018-11-05 12:05:29 -080047 android::status_t status;
48 if (kLazyService) {
49 auto serviceRegistrar = std::make_shared<LazyServiceRegistrar>();
Peter Kalauskasb4abef92019-01-03 15:23:12 -080050 status = serviceRegistrar->registerService(service);
Peter Kalauskasf646be02018-11-05 12:05:29 -080051 } else {
52 status = service->registerAsService();
53 }
54 LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering cas service: %d", status);
55
Chong Zhanga4f67512017-04-24 17:18:25 -070056 joinRpcThreadpool();
57 return 0;
58}