Interestingly, I downloaded the USBHostManager.java filefrom Android 6.0 and it is identical the 5.1.1 version I was working with except the changes shown below.
In Summary (add the two lines below that have "+") to endUsbDeviceAdded(): /frameworks/base/services/usb/java/com/android/server/usb/UsbHostManager.java
/* Called from JNI in monitorUsbHostBus() to finish adding a new device */ privatevoid endUsbDeviceAdded() { if (DEBUG) { Slog.d(TAG, "usb:UsbHostManager.endUsbDeviceAdded()"); } if (mNewInterface != null) { mNewInterface.setEndpoints( mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()])); } if (mNewConfiguration != null) { mNewConfiguration.setInterfaces( mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()])); } synchronized (mLock) { if (mNewDevice != null) { mNewDevice.setConfigurations( mNewConfigurations.toArray(new UsbConfiguration[mNewConfigurations.size()])); mDevices.put(mNewDevice.getDeviceName(), mNewDevice); Slog.d(TAG, "Added device " + mNewDevice); getCurrentSettings().deviceAttached(mNewDevice); mUsbAudioManager.deviceAdded(mNewDevice); } else { Slog.e(TAG, "mNewDevice is null in endUsbDeviceAdded"); } mNewDevice = null; mNewConfigurations = null; mNewInterfaces = null; mNewEndpoints = null; + mNewConfiguration = null; + mNewInterface = null; } }
https://issuetracker.google.com/issues/37032363
本文标题:On Lollipop USBDevice object does not return the correct number of USBInterface