Merge 1543dba93c82e5ade2e8f9875096a778a214b0bb on remote branch
Change-Id: I0711c4a5d30fc6df3b39e685e1e400dc21fb34ac
diff --git a/hal/Usb.cpp b/hal/Usb.cpp
index 1cf2a5a..083ad73 100644
--- a/hal/Usb.cpp
+++ b/hal/Usb.cpp
@@ -1064,9 +1064,16 @@
static bool checkUsbInterfaceAutoSuspend(const std::string& devicePath,
const std::string &intf) {
std::string bInterfaceClass;
- int interfaceClass, ret = -1;
+ int interfaceClass, ret = -1, retry = 3;
- readFile(devicePath + "/" + intf + "/bInterfaceClass", &bInterfaceClass);
+ do {
+ readFile(devicePath + "/" + intf + "/bInterfaceClass",
+ &bInterfaceClass);
+ } while ((--retry > 0) && (bInterfaceClass.length() == 0));
+
+ if (bInterfaceClass.length() == 0) {
+ return false;
+ }
interfaceClass = std::stoi(bInterfaceClass, 0, 16);
// allow autosuspend for certain class devices