android(bug) USB BUG

android 5.1 插入2个USB设备造成第一个USB设备不能用.

https://issuetracker.google.com/issues/37032363

网上有两个解决方案

我采用了第一个,问题解决了.

index e769bda..56f71c0 100644
--- a/services/usb/java/com/android/server/usb/UsbHostManager.java
+++ b/services/usb/java/com/android/server/usb/UsbHostManager.java

@@ -35,6 +35,8 @@ import java.io.FileNotFoundException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
 
 /**
  * UsbHostManager manages USB state in host mode.
@@ -230,6 +232,9 @@ public class UsbHostManager {
             mNewConfigurations = null;
             mNewInterfaces = null;
             mNewEndpoints = null;
+       mNewConfiguration = null; //mzd fixbug usb
+       mNewInterface = null; //mzd fixbug usb

         }
     }



diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java
index d90e06e..d618c55 100644
--- a/core/java/android/hardware/usb/UsbDevice.java
+++ b/core/java/android/hardware/usb/UsbDevice.java

@@ -18,6 +18,7 @@ package android.hardware.usb;
 
 import android.os.Parcel;
 import android.os.Parcelable;
 
 /**
  * This class represents a USB device attached to the android device with the android device
@@ -283,10 +284,11 @@ public class UsbDevice implements Parcelable {
             String manufacturerName = in.readString();
             String productName = in.readString();
             String serialNumber = in.readString();
-            Parcelable[] configurations = in.readParcelableArray(UsbInterface.class.getClassLoader());
+            Parcelable[] configurations = in.readParcelableArray(UsbConfiguration.class.getClassLoader());

             UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol,
                                  manufacturerName, productName, serialNumber);
             device.setConfigurations(configurations);
             return device;
         }
 
(END)





你可能感兴趣的:(Android)