From 88a4d874151c8bd1a9058c99a42539a4f2990153 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Wed, 29 Mar 2017 10:51:17 -0700 Subject: [PATCH] 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 --- usb/1.0/default/service.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/usb/1.0/default/service.cpp b/usb/1.0/default/service.cpp index 4605a4c1..43ab6f0c 100644 --- a/usb/1.0/default/service.cpp +++ b/usb/1.0/default/service.cpp @@ -27,13 +27,21 @@ using android::hardware::joinRpcThreadpool; using android::hardware::usb::V1_0::IUsb; using android::hardware::usb::V1_0::implementation::Usb; +using android::status_t; +using android::OK; + int main() { android::sp service = new Usb(); configureRpcThreadpool(1, true /*callerWillJoin*/); - service->registerAsService(); + status_t status = service->registerAsService(); + + if (status == OK) { + ALOGI("USB HAL Ready."); + joinRpcThreadpool(); + } - ALOGI("USB HAL Ready."); - joinRpcThreadpool(); + ALOGE("Cannot register USB HAL service"); + return 1; } -- 2.11.0