Merge 93576eea98913301f18386035eefcb23935cc32c on remote branch

Change-Id: I5f6f0048e61ba486392e061aa4a3f5216c0fba4d
diff --git a/hal/Usb.cpp b/hal/Usb.cpp
index e522979..14a9d5f 100644
--- a/hal/Usb.cpp
+++ b/hal/Usb.cpp
@@ -1024,9 +1024,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
diff --git a/hal/UsbGadget.cpp b/hal/UsbGadget.cpp
index 3757671..78e73d5 100644
--- a/hal/UsbGadget.cpp
+++ b/hal/UsbGadget.cpp
@@ -233,6 +233,8 @@
 
 Return<void> UsbGadget::getCurrentUsbFunctions(
     const sp<V1_0::IUsbGadgetCallback> &callback) {
+  if (!callback) return Void();
+
   Return<void> ret = callback->getCurrentUsbFunctionsCb(
       mCurrentUsbFunctions, mCurrentUsbFunctionsApplied
                                 ? Status::FUNCTIONS_APPLIED