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 <Weaver.h> 26 #include <Weaver.client.h> 27 28 using ::android::OK; 29 using ::android::sp; 30 using ::android::status_t; 31 using ::android::hardware::configureRpcThreadpool; 32 using ::android::hardware::joinRpcThreadpool; 33 34 using ::android::hardware::weaver::Weaver; 35 36 using ::nos::CitadeldProxyClient; 37 using ::nos::AppClient; 38 39 using WeaverClient = ::nugget::app::weaver::Weaver; 40 main()41int main() { 42 LOG(INFO) << "Weaver HAL service starting"; 43 44 // Connect to citadeld 45 CitadeldProxyClient citadeldProxy; 46 citadeldProxy.Open(); 47 if (!citadeldProxy.IsOpen()) { 48 LOG(FATAL) << "Failed to open citadeld client"; 49 } 50 51 // This thread will become the only thread of the daemon 52 constexpr bool thisThreadWillJoinPool = true; 53 configureRpcThreadpool(1, thisThreadWillJoinPool); 54 55 // Start the HAL service 56 WeaverClient weaverClient{citadeldProxy}; 57 sp<Weaver> weaver = new Weaver{weaverClient}; 58 const status_t status = weaver->registerAsService(); 59 if (status != OK) { 60 LOG(FATAL) << "Failed to register Weaver as a service (status: " << status << ")"; 61 } 62 63 joinRpcThreadpool(); 64 return -1; // Should never be reached 65 } 66