Kenny Root | d0c4f2b | 2019-12-04 07:54:20 -0800 | [diff] [blame] | 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> |
Kenny Root | 7e6f5f9 | 2020-01-24 17:36:47 -0800 | [diff] [blame] | 20 | #include <android-base/properties.h> |
Kenny Root | d0c4f2b | 2019-12-04 07:54:20 -0800 | [diff] [blame] | 21 | #include <android/binder_manager.h> |
| 22 | #include <android/binder_process.h> |
| 23 | |
| 24 | using aidl::android::hardware::rebootescrow::RebootEscrow; |
| 25 | |
Kenny Root | 7e6f5f9 | 2020-01-24 17:36:47 -0800 | [diff] [blame] | 26 | constexpr auto kRebootEscrowDeviceProperty = "ro.rebootescrow.device"; |
| 27 | constexpr auto kRebootEscrowDeviceDefault = "/dev/access-kregistry"; |
| 28 | |
Kenny Root | d0c4f2b | 2019-12-04 07:54:20 -0800 | [diff] [blame] | 29 | int main() { |
| 30 | ABinderProcess_setThreadPoolMaxThreadCount(0); |
| 31 | |
Kenny Root | 7e6f5f9 | 2020-01-24 17:36:47 -0800 | [diff] [blame] | 32 | auto rebootEscrowDevicePath = |
| 33 | android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault); |
| 34 | auto re = ndk::SharedRefBase::make<RebootEscrow>(rebootEscrowDevicePath); |
Kenny Root | d0c4f2b | 2019-12-04 07:54:20 -0800 | [diff] [blame] | 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 | } |