1 /* 2 * Copyright (C) 2020 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 #define LOG_TAG "[email protected]" 18 19 #include <hidl/HidlTransportSupport.h> 20 #include "UsbGadget.h" 21 22 using android::sp; 23 24 // libhwbinder: 25 using android::hardware::configureRpcThreadpool; 26 using android::hardware::joinRpcThreadpool; 27 28 // Generated HIDL files 29 using android::hardware::usb::gadget::V1_1::IUsbGadget; 30 using android::hardware::usb::gadget::V1_1::implementation::UsbGadget; 31 32 using android::OK; 33 using android::status_t; 34 main()35int main() { 36 configureRpcThreadpool(1, true /*callerWillJoin*/); 37 38 android::sp<IUsbGadget> service2 = new UsbGadget(); 39 40 status_t status = service2->registerAsService(); 41 42 if (status != OK) { 43 ALOGE("Cannot register USB Gadget HAL service"); 44 return 1; 45 } 46 47 ALOGI("USB Gadget HAL Ready."); 48 joinRpcThreadpool(); 49 // Under noraml cases, execution will not reach this line. 50 ALOGI("USB Gadget HAL failed to join thread pool."); 51 return 1; 52 } 53