blob: 7414e890523c891490b8824c5eea32aa0fe39f22 [file] [log] [blame]
Howard Yen9bfb4352019-11-28 21:14:57 +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.1-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_1::IUsbGadget;
30using android::hardware::usb::gadget::V1_1::implementation::UsbGadget;
31
32using android::OK;
33using android::status_t;
34
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}