blob: 80c56a653f15bb3e0ec74f18330cf84d35cb6835 [file] [log] [blame]
raychie96a2a82020-10-07 23:23:56 +08001/*
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 "android.hardware.usb.gadget@1.2-service"
18
19#include <hidl/HidlTransportSupport.h>
20#include "UsbGadget.h"
21
22using android::sp;
23
24// libhwbinder:
25using android::hardware::configureRpcThreadpool;
26using android::hardware::joinRpcThreadpool;
27
28// Generated HIDL files
29using android::hardware::usb::gadget::V1_2::IUsbGadget;
30using android::hardware::usb::gadget::V1_2::implementation::UsbGadget;
31
32using android::OK;
33using android::status_t;
34
35int main() {
36 configureRpcThreadpool(1, true /*callerWillJoin*/);
37
38 android::sp<IUsbGadget> service = new UsbGadget();
39
40 status_t status = service->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}