UsbAccessorypublic class UsbAccessory extends Object implements android.os.ParcelableA class representing a USB accessory, which is an external hardware component
that communicates with an android application over USB.
The accessory is the USB host and android the device side of the USB connection.
When the accessory connects, it reports its manufacturer and model names,
the version of the accessory, and a user visible description of the accessory to the device.
The manufacturer, model and version strings are used by the USB Manager to choose
an appropriate application for the accessory.
The accessory may optionally provide a unique serial number
and a URL to for the accessory's website to the device as well.
An instance of this class is sent to the application via the
{@link UsbManager#ACTION_USB_ACCESSORY_ATTACHED} Intent.
The application can then call {@link UsbManager#openAccessory} to open a file descriptor
for reading and writing data to and from the accessory.
Developer Guides
For more information about communicating with USB hardware, read the
USB developer guide.
|
Fields Summary |
---|
private static final String | TAG | private final String | mManufacturer | private final String | mModel | private final String | mDescription | private final String | mVersion | private final String | mUri | private final String | mSerial | public static final int | MANUFACTURER_STRING | public static final int | MODEL_STRING | public static final int | DESCRIPTION_STRING | public static final int | VERSION_STRING | public static final int | URI_STRING | public static final int | SERIAL_STRING | public static final Parcelable.Creator | CREATOR |
Constructors Summary |
---|
public UsbAccessory(String manufacturer, String model, String description, String version, String uri, String serial)UsbAccessory should only be instantiated by UsbService implementation
mManufacturer = manufacturer;
mModel = model;
mDescription = description;
mVersion = version;
mUri = uri;
mSerial = serial;
| public UsbAccessory(String[] strings)UsbAccessory should only be instantiated by UsbService implementation
mManufacturer = strings[MANUFACTURER_STRING];
mModel = strings[MODEL_STRING];
mDescription = strings[DESCRIPTION_STRING];
mVersion = strings[VERSION_STRING];
mUri = strings[URI_STRING];
mSerial = strings[SERIAL_STRING];
|
Methods Summary |
---|
private static boolean | compare(java.lang.String s1, java.lang.String s2)
if (s1 == null) return (s2 == null);
return s1.equals(s2);
| public int | describeContents()
return 0;
| public boolean | equals(java.lang.Object obj)
if (obj instanceof UsbAccessory) {
UsbAccessory accessory = (UsbAccessory)obj;
return (compare(mManufacturer, accessory.getManufacturer()) &&
compare(mModel, accessory.getModel()) &&
compare(mDescription, accessory.getDescription()) &&
compare(mVersion, accessory.getVersion()) &&
compare(mUri, accessory.getUri()) &&
compare(mSerial, accessory.getSerial()));
}
return false;
| public java.lang.String | getDescription()Returns a user visible description of the accessory.
return mDescription;
| public java.lang.String | getManufacturer()Returns the manufacturer name of the accessory.
return mManufacturer;
| public java.lang.String | getModel()Returns the model name of the accessory.
return mModel;
| public java.lang.String | getSerial()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 mSerial;
| public java.lang.String | getUri()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 mUri;
| public java.lang.String | getVersion()Returns the version of the accessory.
return mVersion;
| public int | hashCode()
return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^
(mModel == null ? 0 : mModel.hashCode()) ^
(mDescription == null ? 0 : mDescription.hashCode()) ^
(mVersion == null ? 0 : mVersion.hashCode()) ^
(mUri == null ? 0 : mUri.hashCode()) ^
(mSerial == null ? 0 : mSerial.hashCode()));
| public java.lang.String | toString()
return "UsbAccessory[mManufacturer=" + mManufacturer +
", mModel=" + mModel +
", mDescription=" + mDescription +
", mVersion=" + mVersion +
", mUri=" + mUri +
", mSerial=" + mSerial + "]";
| public void | writeToParcel(android.os.Parcel parcel, int flags)
parcel.writeString(mManufacturer);
parcel.writeString(mModel);
parcel.writeString(mDescription);
parcel.writeString(mVersion);
parcel.writeString(mUri);
parcel.writeString(mSerial);
|
|