blob: 75a4479e774f4949b51042e2b5e296ac8a31ed48 [file] [log] [blame]
Ilya Matyukhin09166982020-10-12 13:41:03 -07001/*
2 * Copyright (C) 2020 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
Jeff Pua3c57362024-06-10 15:03:50 +000017#undef LOG_TAG
18#define LOG_TAG "FaceVirtualHal"
19
Ilya Matyukhin09166982020-10-12 13:41:03 -070020#include "Face.h"
Jeff Pua3c57362024-06-10 15:03:50 +000021#include "VirtualHal.h"
Ilya Matyukhin09166982020-10-12 13:41:03 -070022
23#include <android-base/logging.h>
24#include <android/binder_manager.h>
25#include <android/binder_process.h>
26
27using aidl::android::hardware::biometrics::face::Face;
Jeff Pua3c57362024-06-10 15:03:50 +000028using aidl::android::hardware::biometrics::face::VirtualHal;
Ilya Matyukhin09166982020-10-12 13:41:03 -070029
Jeff Pua3c57362024-06-10 15:03:50 +000030int main(int argc, char** argv) {
31 if (argc < 2) {
32 LOG(ERROR) << "Missing argument -> exiting, Valid arguments:[default|virtual]";
33 return EXIT_FAILURE;
34 }
35 LOG(INFO) << "Face HAL started: " << argv[1];
Ilya Matyukhin09166982020-10-12 13:41:03 -070036 ABinderProcess_setThreadPoolMaxThreadCount(0);
37 std::shared_ptr<Face> hal = ndk::SharedRefBase::make<Face>();
Jeff Pua3c57362024-06-10 15:03:50 +000038 std::shared_ptr<VirtualHal> hal_vhal = ndk::SharedRefBase::make<VirtualHal>(hal);
Ilya Matyukhin09166982020-10-12 13:41:03 -070039
Jeff Pua3c57362024-06-10 15:03:50 +000040 if (strcmp(argv[1], "default") == 0) {
41 const std::string instance = std::string(Face::descriptor) + "/default";
42 auto binder = hal->asBinder();
43 binder_status_t status =
44 AServiceManager_registerLazyService(binder.get(), instance.c_str());
45 CHECK_EQ(status, STATUS_OK);
46 LOG(INFO) << "started IFace/default";
47 } else if (strcmp(argv[1], "virtual") == 0) {
48 const std::string instance = std::string(VirtualHal::descriptor) + "/virtual";
49 auto binder = hal_vhal->asBinder();
50 binder_status_t status =
51 AServiceManager_registerLazyService(binder.get(), instance.c_str());
52 CHECK_EQ(status, STATUS_OK);
53 LOG(INFO) << "started IVirtualHal/virtual";
54 } else {
55 LOG(ERROR) << "Unexpected argument: " << argv[1];
56 return EXIT_FAILURE;
57 }
Jeff Pu4b5e5ce2023-09-06 14:47:49 +000058 AServiceManager_forceLazyServicesPersist(true);
Ilya Matyukhin09166982020-10-12 13:41:03 -070059
60 ABinderProcess_joinThreadPool();
Jeff Pua3c57362024-06-10 15:03:50 +000061 return EXIT_FAILURE; // should not reach here
Ilya Matyukhin09166982020-10-12 13:41:03 -070062}