summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware/usb
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-03-09 22:03:57 -0500
committerMike Lockwood <lockwood@android.com>2011-03-09 22:12:49 -0500
commitac36d7c715a9cd793b2dce6de547594810101c3a (patch)
tree5f347132f5896785d47519c1ae728af1113db1f0 /core/java/android/hardware/usb
parentb966b9d9e882835691e5adda292d89dd704df71c (diff)
downloadframeworks_base-ac36d7c715a9cd793b2dce6de547594810101c3a.zip
frameworks_base-ac36d7c715a9cd793b2dce6de547594810101c3a.tar.gz
frameworks_base-ac36d7c715a9cd793b2dce6de547594810101c3a.tar.bz2
UsbAccessory: Add URI string, replace type string with description
This is a first step toward adding USB accessory URI support BUG: 4073248 Modified USB accessory matching logic to look only at manufacturer, model and version (description and URI are not considered when matching apps to accessories) Also added test for USB accessory protocol version to accessorytest BUG: 4080288 Change-Id: I992a3433c74efa7a7db37bf030f02c1f0c92f9e2 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.java54
1 files changed, 37 insertions, 17 deletions
diff --git a/core/java/android/hardware/usb/UsbAccessory.java b/core/java/android/hardware/usb/UsbAccessory.java
index 7d66caa..cc174d4 100644
--- a/core/java/android/hardware/usb/UsbAccessory.java
+++ b/core/java/android/hardware/usb/UsbAccessory.java
@@ -30,18 +30,21 @@ public class UsbAccessory implements Parcelable {
private final String mManufacturer;
private final String mModel;
- private final String mType;
+ private final String mDescription;
private final String mVersion;
+ private final String mUri;
/**
* UsbAccessory should only be instantiated by UsbService implementation
* @hide
*/
- public UsbAccessory(String manufacturer, String model, String type, String version) {
+ public UsbAccessory(String manufacturer, String model, String description,
+ String version, String uri) {
mManufacturer = manufacturer;
mModel = model;
- mType = type;
+ mDescription = description;
mVersion = version;
+ mUri = uri;
}
/**
@@ -51,8 +54,9 @@ public class UsbAccessory implements Parcelable {
public UsbAccessory(String[] strings) {
mManufacturer = strings[0];
mModel = strings[1];
- mType = strings[2];
+ mDescription = strings[2];
mVersion = strings[3];
+ mUri = strings[4];
}
/**
@@ -74,12 +78,12 @@ public class UsbAccessory implements Parcelable {
}
/**
- * Returns the type of the accessory.
+ * Returns a user visible description of the accessory.
*
- * @return the accessory type
+ * @return the accessory description
*/
- public String getType() {
- return mType;
+ public String getDescription() {
+ return mDescription;
}
/**
@@ -91,6 +95,17 @@ public class UsbAccessory implements Parcelable {
return mVersion;
}
+ /**
+ * Returns the URI for the accessory.
+ * This is an optional URI that might show information about the accessory
+ * or provide the option to download an application for the accessory
+ *
+ * @return the accessory URI
+ */
+ public String getUri() {
+ return mUri;
+ }
+
private static boolean compare(String s1, String s2) {
if (s1 == null) return (s2 == null);
return s1.equals(s2);
@@ -102,8 +117,9 @@ public class UsbAccessory implements Parcelable {
UsbAccessory accessory = (UsbAccessory)obj;
return (compare(mManufacturer, accessory.getManufacturer()) &&
compare(mModel, accessory.getModel()) &&
- compare(mType, accessory.getType()) &&
- compare(mVersion, accessory.getVersion()));
+ compare(mDescription, accessory.getDescription()) &&
+ compare(mVersion, accessory.getVersion()) &&
+ compare(mUri, accessory.getUri()));
}
return false;
}
@@ -112,16 +128,18 @@ public class UsbAccessory implements Parcelable {
public int hashCode() {
return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^
(mModel == null ? 0 : mModel.hashCode()) ^
- (mType == null ? 0 : mType.hashCode()) ^
- (mVersion == null ? 0 : mVersion.hashCode()));
+ (mDescription == null ? 0 : mDescription.hashCode()) ^
+ (mVersion == null ? 0 : mVersion.hashCode()) ^
+ (mUri == null ? 0 : mUri.hashCode()));
}
@Override
public String toString() {
return "UsbAccessory[mManufacturer=" + mManufacturer +
", mModel=" + mModel +
- ", mType=" + mType +
- ", mVersion=" + mVersion + "]";
+ ", mDescription=" + mDescription +
+ ", mVersion=" + mVersion +
+ ", mUri=" + mUri + "]";
}
public static final Parcelable.Creator<UsbAccessory> CREATOR =
@@ -129,9 +147,10 @@ public class UsbAccessory implements Parcelable {
public UsbAccessory createFromParcel(Parcel in) {
String manufacturer = in.readString();
String model = in.readString();
- String type = in.readString();
+ String description = in.readString();
String version = in.readString();
- return new UsbAccessory(manufacturer, model, type, version);
+ String uri = in.readString();
+ return new UsbAccessory(manufacturer, model, description, version, uri);
}
public UsbAccessory[] newArray(int size) {
@@ -146,7 +165,8 @@ public class UsbAccessory implements Parcelable {
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeString(mManufacturer);
parcel.writeString(mModel);
- parcel.writeString(mType);
+ parcel.writeString(mDescription);
parcel.writeString(mVersion);
+ parcel.writeString(mUri);
}
}