1 /* 2 * Copyright (C) 2016 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 #define LOG_TAG "android.hardware.boot@1.0-service" 17 18 #include <log/log.h> 19 #include <hidl/HidlTransportSupport.h> 20 #include <hidl/Status.h> 21 #include <android/hardware/boot/1.0/IBootControl.h> 22 #include "BootControl.h" 23 24 using ::android::status_t; 25 26 using ::android::hardware::boot::V1_0::IBootControl; 27 28 using ::android::hardware::boot::V1_0::implementation::BootControl; 29 main(int,char * [])30int main (int /* argc */, char * /* argv */ []) { 31 // This function must be called before you join to ensure the proper 32 // number of threads are created. The threadpool will never exceed 33 // size one because of this call. 34 ::android::hardware::configureRpcThreadpool(1 /*threads*/, true /*willJoin*/); 35 36 ::android::sp bootctrl = new BootControl(); 37 const status_t status = bootctrl->registerAsService(); 38 if (status != ::android::OK) { 39 return 1; // or handle error 40 } 41 42 // Adds this thread to the threadpool, resulting in one total 43 // thread in the threadpool. We could also do other things, but 44 // would have to specify 'false' to willJoin in configureRpcThreadpool. 45 ::android::hardware::joinRpcThreadpool(); 46 return 1; // joinRpcThreadpool should never return 47 } 48