diff options
| author | 2017-08-01 16:08:59 +0000 | |
|---|---|---|
| committer | 2017-08-01 16:08:59 +0000 | |
| commit | 827a5a256346881b84f95b86e362382a8da12ba0 (patch) | |
| tree | 725d3147692214de3189ee778209b75f7a8e3190 | |
| parent | bdd6289ad32cd1574940ec1be9679d25849264c6 (diff) | |
| parent | a7e1dbbed74712972b1ebf8d2563f5b06a89b4b5 (diff) | |
Merge "Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev am: f3562ffdfb am: 3e62b611f0" into oc-mr1-dev-plus-aosp
am: a7e1dbbed7
Change-Id: I004ea8867a4dd6fd33078285ac4fc0d7b6202cc7
| -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); } } } |