From 575ca85c147f1521480ea98aca13aa3b1ec38884 Mon Sep 17 00:00:00 2001 From: Robin Cutshaw Date: Tue, 1 May 2012 19:45:25 -0400 Subject: Added missing USB device descriptor fields needed for intent filters The UsbDevice object is missing the ManufacturerName, ProductName, and SerialNumber fields. These are needed by intent filters to further qualify a USB device that is plugged in while in host mode. These fields have been added in the jni UsbHostManager implementation and propagated through UsbHostManager and UsbDevice implementations. The UsbSettingsManager implementation has been modified to allow manufacturer-name, product-name, and serial-number tags in intents. File changes: modified: api/current.txt modified: core/java/android/hardware/usb/UsbDevice.java modified: services/java/com/android/server/usb/UsbHostManager.java modified: services/java/com/android/server/usb/UsbSettingsManager.java modified: services/jni/com_android_server_UsbHostManager.cpp Change-Id: I386884715d1b732b06a63feb77790be6b59b6fe6 Signed-off-by: Robin Cutshaw --- core/java/android/hardware/usb/UsbDevice.java | 49 +++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'core/java') diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java index 9bd38f9..d1e63f6 100644 --- a/core/java/android/hardware/usb/UsbDevice.java +++ b/core/java/android/hardware/usb/UsbDevice.java @@ -46,6 +46,9 @@ public class UsbDevice implements Parcelable { private static final String TAG = "UsbDevice"; private final String mName; + private final String mManufacturerName; + private final String mProductName; + private final String mSerialNumber; private final int mVendorId; private final int mProductId; private final int mClass; @@ -58,13 +61,18 @@ public class UsbDevice implements Parcelable { * @hide */ public UsbDevice(String name, int vendorId, int productId, - int Class, int subClass, int protocol, Parcelable[] interfaces) { + int Class, int subClass, int protocol, + String manufacturerName, String productName, String serialNumber, + Parcelable[] interfaces) { mName = name; mVendorId = vendorId; mProductId = productId; mClass = Class; mSubclass = subClass; mProtocol = protocol; + mManufacturerName = manufacturerName; + mProductName = productName; + mSerialNumber = serialNumber; mInterfaces = interfaces; } @@ -80,6 +88,33 @@ public class UsbDevice implements Parcelable { } /** + * Returns the manufacturer name of the device. + * + * @return the manufacturer name + */ + public String getManufacturerName() { + return mManufacturerName; + } + + /** + * Returns the product name of the device. + * + * @return the product name + */ + public String getProductName() { + return mProductName; + } + + /** + * Returns the serial number of the device. + * + * @return the serial number name + */ + public String getSerialNumber() { + return mSerialNumber; + } + + /** * Returns a unique integer ID for the device. * This is a convenience for clients that want to use an integer to represent * the device, rather than the device name. @@ -176,7 +211,8 @@ public class UsbDevice implements Parcelable { return "UsbDevice[mName=" + mName + ",mVendorId=" + mVendorId + ",mProductId=" + mProductId + ",mClass=" + mClass + ",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol + - ",mInterfaces=" + mInterfaces + "]"; + ",mManufacturerName=" + mManufacturerName + ",mProductName=" + mProductName + + ",mSerialNumber=" + mSerialNumber + ",mInterfaces=" + mInterfaces + "]"; } public static final Parcelable.Creator CREATOR = @@ -188,8 +224,12 @@ public class UsbDevice implements Parcelable { int clasz = in.readInt(); int subClass = in.readInt(); int protocol = in.readInt(); + String manufacturerName = in.readString(); + String productName = in.readString(); + String serialNumber = in.readString(); Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader()); - return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, interfaces); + return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, + manufacturerName, productName, serialNumber, interfaces); } public UsbDevice[] newArray(int size) { @@ -208,6 +248,9 @@ public class UsbDevice implements Parcelable { parcel.writeInt(mClass); parcel.writeInt(mSubclass); parcel.writeInt(mProtocol); + parcel.writeString(mManufacturerName); + parcel.writeString(mProductName); + parcel.writeString(mSerialNumber); parcel.writeParcelableArray(mInterfaces, 0); } -- cgit v1.1