diff options
author | Mike Lockwood <lockwood@android.com> | 2011-03-14 18:24:35 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-03-14 20:10:47 -0400 |
commit | 015b1ecaec27b7cf5f1a78099d9ae34a0c3169f2 (patch) | |
tree | 3b7a7bca14b9579c6fe647696d4623ad8acb8c71 /core/java/android/hardware/usb | |
parent | 9f3f36c95b87aab2c5f7cd6b6e18927f8ebfa9c4 (diff) | |
download | frameworks_base-015b1ecaec27b7cf5f1a78099d9ae34a0c3169f2.zip frameworks_base-015b1ecaec27b7cf5f1a78099d9ae34a0c3169f2.tar.gz frameworks_base-015b1ecaec27b7cf5f1a78099d9ae34a0c3169f2.tar.bz2 |
Add support for USB accessory serial numbers
Change-Id: I47b79f091b300ced60bfc61eff2f771139663aae
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core/java/android/hardware/usb')
-rw-r--r-- | core/java/android/hardware/usb/UsbAccessory.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/core/java/android/hardware/usb/UsbAccessory.java b/core/java/android/hardware/usb/UsbAccessory.java index cc174d4..5e9ead0 100644 --- a/core/java/android/hardware/usb/UsbAccessory.java +++ b/core/java/android/hardware/usb/UsbAccessory.java @@ -33,18 +33,20 @@ public class UsbAccessory implements Parcelable { private final String mDescription; private final String mVersion; private final String mUri; + private final String mSerial; /** * UsbAccessory should only be instantiated by UsbService implementation * @hide */ public UsbAccessory(String manufacturer, String model, String description, - String version, String uri) { + String version, String uri, String serial) { mManufacturer = manufacturer; mModel = model; mDescription = description; mVersion = version; mUri = uri; + mSerial = serial; } /** @@ -57,6 +59,7 @@ public class UsbAccessory implements Parcelable { mDescription = strings[2]; mVersion = strings[3]; mUri = strings[4]; + mSerial = strings[5]; } /** @@ -106,6 +109,17 @@ public class UsbAccessory implements Parcelable { return mUri; } + /** + * Returns the unique serial number for the accessory. + * This is an optional serial number that can be used to differentiate + * between individual accessories of the same model and manufacturer + * + * @return the unique serial number + */ + public String getSerial() { + return mSerial; + } + private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); @@ -119,7 +133,8 @@ public class UsbAccessory implements Parcelable { compare(mModel, accessory.getModel()) && compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && - compare(mUri, accessory.getUri())); + compare(mUri, accessory.getUri()) && + compare(mSerial, accessory.getSerial())); } return false; } @@ -130,7 +145,8 @@ public class UsbAccessory implements Parcelable { (mModel == null ? 0 : mModel.hashCode()) ^ (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ - (mUri == null ? 0 : mUri.hashCode())); + (mUri == null ? 0 : mUri.hashCode()) ^ + (mSerial == null ? 0 : mSerial.hashCode())); } @Override @@ -139,7 +155,8 @@ public class UsbAccessory implements Parcelable { ", mModel=" + mModel + ", mDescription=" + mDescription + ", mVersion=" + mVersion + - ", mUri=" + mUri + "]"; + ", mUri=" + mUri + + ", mSerial=" + mSerial + "]"; } public static final Parcelable.Creator<UsbAccessory> CREATOR = @@ -150,7 +167,8 @@ public class UsbAccessory implements Parcelable { String description = in.readString(); String version = in.readString(); String uri = in.readString(); - return new UsbAccessory(manufacturer, model, description, version, uri); + String serial = in.readString(); + return new UsbAccessory(manufacturer, model, description, version, uri, serial); } public UsbAccessory[] newArray(int size) { @@ -168,5 +186,6 @@ public class UsbAccessory implements Parcelable { parcel.writeString(mDescription); parcel.writeString(mVersion); parcel.writeString(mUri); + parcel.writeString(mSerial); } } |