1 /* 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> 20 #include <android-base/properties.h> 21 #include <android/binder_manager.h> 22 #include <android/binder_process.h> 23 24 using aidl::android::hardware::rebootescrow::RebootEscrow; 25 26 constexpr auto kRebootEscrowDeviceProperty = "ro.rebootescrow.device"; 27 constexpr auto kRebootEscrowDeviceDefault = "/dev/access-kregistry"; 28 main()29int main() { 30 ABinderProcess_setThreadPoolMaxThreadCount(0); 31 32 auto rebootEscrowDevicePath = 33 android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault); 34 auto re = ndk::SharedRefBase::make<RebootEscrow>(rebootEscrowDevicePath); 35 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 } 42