blob: 8a8086b498b513fd028a9e4693423b13f336d1e7 [file] [log] [blame]
Kenny Rootd0c4f2b2019-12-04 07:54:20 -08001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.1 (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.1
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#include "rebootescrow-impl/RebootEscrow.h"
18
19#include <android-base/logging.h>
Kenny Root7e6f5f92020-01-24 17:36:47 -080020#include <android-base/properties.h>
Kenny Rootd0c4f2b2019-12-04 07:54:20 -080021#include <android/binder_manager.h>
22#include <android/binder_process.h>
23
24using aidl::android::hardware::rebootescrow::RebootEscrow;
25
Kenny Root7e6f5f92020-01-24 17:36:47 -080026constexpr auto kRebootEscrowDeviceProperty = "ro.rebootescrow.device";
27constexpr auto kRebootEscrowDeviceDefault = "/dev/access-kregistry";
28
Kenny Rootd0c4f2b2019-12-04 07:54:20 -080029int main() {
30 ABinderProcess_setThreadPoolMaxThreadCount(0);
31
Kenny Root7e6f5f92020-01-24 17:36:47 -080032 auto rebootEscrowDevicePath =
33 android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault);
34 auto re = ndk::SharedRefBase::make<RebootEscrow>(rebootEscrowDevicePath);
Kenny Rootd0c4f2b2019-12-04 07:54:20 -080035 const std::string instance = std::string() + RebootEscrow::descriptor + "/default";
36 binder_status_t status = AServiceManager_addService(re->asBinder().get(), instance.c_str());
37 CHECK(status == STATUS_OK);
38
39 ABinderProcess_joinThreadPool();
40 return EXIT_FAILURE;
41}