diff options
| author | Badhri Jagan Sridharan <Badhri@google.com> | 2017-03-29 12:25:10 -0700 |
|---|---|---|
| committer | Badhri Jagan Sridharan <badhri@google.com> | 2017-04-04 20:06:04 +0000 |
| commit | a9b62bae81f00d60e5c131c1b9bfde8650f1cffb (patch) | |
| tree | 85cbb4e6ab124a18e3d00ba012a98629230d26fe /usb | |
| parent | 7127355462e2c24eb7a12e1292f9f342701f6c64 (diff) | |
USB: HIDL: check the status of registerAsService
registerAsService call could fail. Hence check the return value.
Bug: 36704362
Test: Manually checked to see if usb hal service is running.
Change-Id: I46dcd74dbee6aba72cf344f10854e5d4b1b6de18
Diffstat (limited to 'usb')
| -rw-r--r-- | usb/service.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usb/service.cpp b/usb/service.cpp index 4605a4c1..b52a36fd 100644 --- a/usb/service.cpp +++ b/usb/service.cpp @@ -27,13 +27,23 @@ using android::hardware::joinRpcThreadpool; using android::hardware::usb::V1_0::IUsb; using android::hardware::usb::V1_0::implementation::Usb; -int main() { +using android::status_t; +using android::OK; +int main() { android::sp<IUsb> service = new Usb(); configureRpcThreadpool(1, true /*callerWillJoin*/); - service->registerAsService(); + status_t status = service->registerAsService(); + + if (status != OK) { + ALOGE("Cannot register USB HAL service"); + return 1; + } ALOGI("USB HAL Ready."); joinRpcThreadpool(); + // Under noraml cases, execution will not reach this line. + ALOGI("USB HAL failed to join thread pool."); + return 1; } |
