From abc92991ead7e48b409d898f2c11a33016ee4a47 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Thu, 20 Jun 2019 11:14:35 -0700 Subject: [PATCH] usbd: Exit in case of charger mode. UsbGadget hal is not expected run in charger mode. This should fix the following errors in charger mode: [ 86.609578] c4 612 init: Received control message 'interface_start' for 'android.hardware.usb.gadget@1.0::IUsbGadget/default' from pid: 565 (/system/bin/hwservicemanager) [ 86.618236] c7 1 init: Could not find 'android.hardware.usb.gadget@1.0::IUsbGadget/default' for ctl.interface_start Bug: 135566354 Test: Manually verified that usbd exits early in charger mode. Change-Id: I3ba5be883c49e5ca3e4dad4443528e4eee8b25b9 --- usbd/usbd.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usbd/usbd.cpp b/usbd/usbd.cpp index 191fb92fb..6e24d8e78 100644 --- a/usbd/usbd.cpp +++ b/usbd/usbd.cpp @@ -24,8 +24,6 @@ #include -#define PERSISTENT_USB_CONFIG "persist.sys.usb.config" - using android::base::GetProperty; using android::base::SetProperty; using android::hardware::configureRpcThreadpool; @@ -34,14 +32,15 @@ using android::hardware::usb::gadget::V1_0::IUsbGadget; using android::hardware::Return; int main(int /*argc*/, char** /*argv*/) { - configureRpcThreadpool(1, true /*callerWillJoin*/); + if (GetProperty("ro.bootmode", "") == "charger") exit(0); + configureRpcThreadpool(1, true /*callerWillJoin*/); android::sp gadget = IUsbGadget::getService(); Return ret; if (gadget != nullptr) { LOG(INFO) << "Usb HAL found."; - std::string function = GetProperty(PERSISTENT_USB_CONFIG, ""); + std::string function = GetProperty("persist.sys.usb.config", ""); if (function == "adb") { LOG(INFO) << "peristent prop is adb"; SetProperty("ctl.start", "adbd");