1 /* 2 * Copyright (C) 2017 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 #include <android-base/logging.h> 18 #include <hidl/HidlTransportSupport.h> 19 #include <utils/StrongPointer.h> 20 21 #include <application.h> 22 #include <nos/AppClient.h> 23 #include <nos/CitadeldProxyClient.h> 24 25 #include <OemLock.h> 26 27 using ::android::OK; 28 using ::android::sp; 29 using ::android::status_t; 30 using ::android::hardware::configureRpcThreadpool; 31 using ::android::hardware::joinRpcThreadpool; 32 33 using ::android::hardware::oemlock::OemLock; 34 35 using ::nos::CitadeldProxyClient; 36 using ::nos::AppClient; 37 38 using AvbClient = ::nugget::app::avb::Avb; 39 main()40int main() { 41 LOG(INFO) << "OemLock HAL service starting"; 42 43 // Connect to Citadel 44 CitadeldProxyClient citadeldProxy; 45 citadeldProxy.Open(); 46 if (!citadeldProxy.IsOpen()) { 47 LOG(FATAL) << "Failed to open citadeld client"; 48 } 49 50 // This thread will become the only thread of the daemon 51 constexpr bool thisThreadWillJoinPool = true; 52 configureRpcThreadpool(1, thisThreadWillJoinPool); 53 54 // Start the HAL service 55 AvbClient avbClient{citadeldProxy}; 56 sp<OemLock> oemlock = new OemLock{avbClient}; 57 const status_t status = oemlock->registerAsService(); 58 if (status != OK) { 59 LOG(FATAL) << "Failed to register OemLock as a service (status: " << status << ")"; 60 } 61 62 joinRpcThreadpool(); 63 return -1; // Should never be reached 64 } 65