blob: 076c7bb84a48ee2872e620a44733264a43187802 [file] [log] [blame]
Shraddha Basantwani6545b4e2022-09-21 16:26:19 +05301/*
2 * Copyright 2022 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#ifdef LAZY_SERVICE
18const bool kLazyService = true;
19#define LOG_TAG "android.hardware.cas-service.example-lazy"
20#else
21const bool kLazyService = false;
22#define LOG_TAG "android.hardware.cas-service.example"
23#endif
24
25#include <android/binder_manager.h>
26#include <android/binder_process.h>
27
28#include "MediaCasService.h"
29
30using aidl::android::hardware::cas::MediaCasService;
31
32int main() {
33 ABinderProcess_setThreadPoolMaxThreadCount(8);
Venkatarama Avadhania6710292023-11-07 20:26:31 +053034 ABinderProcess_startThreadPool();
Shraddha Basantwani6545b4e2022-09-21 16:26:19 +053035
36 // Setup hwbinder service
37 std::shared_ptr<MediaCasService> service = ::ndk::SharedRefBase::make<MediaCasService>();
38
39 const std::string instance = std::string() + MediaCasService::descriptor + "/default";
40 binder_status_t status;
41
42 if (kLazyService) {
43 status = AServiceManager_registerLazyService(service->asBinder().get(), instance.c_str());
44 } else {
45 status = AServiceManager_addService(service->asBinder().get(), instance.c_str());
46 }
47 LOG_ALWAYS_FATAL_IF(status != STATUS_OK, "Error while registering cas service: %d", status);
48
49 ABinderProcess_joinThreadPool();
50 return 0;
51}