diff options
author | 2017-08-01 15:35:05 +0000 | |
---|---|---|
committer | 2017-08-01 15:35:05 +0000 | |
commit | 18d64cf8fe4698c35f0f421dba3ab777ffbc8bba (patch) | |
tree | 094c15ca8d98a38e6741f16f599b04fd8266688a | |
parent | 08674f3a25fc36355e296afb61d30e63e5b81928 (diff) | |
parent | f3562ffdfbb31638297c983221626d94e81ab084 (diff) |
Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev
am: f3562ffdfb
Change-Id: I0304bf7c72a340f4bebebea89d2e934ae5830b33
-rw-r--r-- | services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java b/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java index 303a577767ad..d4a0ac4a0da3 100644 --- a/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java +++ b/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java @@ -123,21 +123,27 @@ public class UsbDescriptorParser { ByteStream stream = new ByteStream(descriptors); while (stream.available() > 0) { - UsbDescriptor descriptor = allocDescriptor(stream); + UsbDescriptor descriptor = null; + try { + descriptor = allocDescriptor(stream); + } catch (Exception ex) { + Log.e(TAG, "Exception allocating USB descriptor.", ex); + } + if (descriptor != null) { // Parse try { descriptor.parseRawDescriptors(stream); + + // Its OK to add the invalid descriptor as the postParse() + // routine will mark it as invalid. + mDescriptors.add(descriptor); + + // Clean up + descriptor.postParse(stream); } catch (Exception ex) { Log.e(TAG, "Exception parsing USB descriptors.", ex); } - - // Its OK to add the invalid descriptor as the postParse() - // routine will mark it as invalid. - mDescriptors.add(descriptor); - - // Clean up - descriptor.postParse(stream); } } } |