diff options
author | Kamen Kirov <knk@pupil-labs.com> | 2019-02-13 14:20:35 +0200 |
---|---|---|
committer | Emilian Peev <epeev@google.com> | 2019-03-29 18:10:27 +0000 |
commit | b83cf0c7f14a05a4ba9fef5aa0f95cdb75bc9b28 (patch) | |
tree | 7aa273455c024f15a0a8db24afee4cdf30068cc5 /services/usb/java | |
parent | 32bfd77b794d88ce6225189d9a8c48321a21c63f (diff) |
Fix incorrect parsing of UVC interface descriptor
Every USB device that has CS_INTERFACE descriptor was incorrectly
assumed to be an UAC device, without checking the device class.
This led to incorrect parsing of UVC devices, which also have
CS_INTERFACE type descriptors. For some devices the parsing worked
by coincidence, for others it lead to incorrect device data (wrong
vid, pid, etc).
This change parses every CS_INTERFACE descriptor that does not belong
to an UAC device as type 'Unknown'.
Test: Connect a UVC camera, observe logcat. Before this change, there
were lots of parsing errors in logcat, now the device is added cleanly.
Bug: 124374863
Change-Id: Ic076438625a733cffa9ae51ba803e353fd064ceb
Signed-off-by: Kamen Kirov <knk@pupil-labs.com>
Diffstat (limited to 'services/usb/java')
-rw-r--r-- | services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java | 8 |
1 files changed, 6 insertions, 2 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 e61542824083..6a3469c5fa24 100644 --- a/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java +++ b/services/usb/java/com/android/server/usb/descriptors/UsbDescriptorParser.java @@ -177,11 +177,15 @@ public final class UsbDescriptorParser { * Audio Class Specific */ case UsbDescriptor.DESCRIPTORTYPE_AUDIO_INTERFACE: - descriptor = UsbACInterface.allocDescriptor(this, stream, length, type); + if (mDeviceDescriptor.getDevClass() == UsbDescriptor.CLASSID_AUDIO) { + descriptor = UsbACInterface.allocDescriptor(this, stream, length, type); + } break; case UsbDescriptor.DESCRIPTORTYPE_AUDIO_ENDPOINT: - descriptor = UsbACEndpoint.allocDescriptor(this, length, type); + if (mDeviceDescriptor.getDevClass() == UsbDescriptor.CLASSID_AUDIO) { + descriptor = UsbACEndpoint.allocDescriptor(this, length, type); + } break; default: |