public class UsbDevice extends Object implements Parcelable
UsbInterface
s, each of which contains a number of
UsbEndpoint
s (the channels via which data is transmitted over USB).
This class contains information (along with UsbInterface
and UsbEndpoint
)
that describes the capabilities of the USB device.
To communicate with the device, you open a UsbDeviceConnection
for the device
and use UsbRequest
to send and receive data on an endpoint.
UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)
is used for control requests on endpoint zero.
For more information about communicating with USB hardware, read the USB developer guide.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<UsbDevice> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
UsbDevice(String name,
int vendorId,
int productId,
int Class,
int subClass,
int protocol,
Parcelable[] interfaces)
UsbDevice should only be instantiated by UsbService implementation
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
|
boolean |
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
int |
getDeviceClass()
Returns the devices's class field.
|
int |
getDeviceId()
Returns a unique integer ID for the device.
|
static int |
getDeviceId(String name) |
String |
getDeviceName()
Returns the name of the device.
|
static String |
getDeviceName(int id) |
int |
getDeviceProtocol()
Returns the device's protocol field.
|
int |
getDeviceSubclass()
Returns the device's subclass field.
|
UsbInterface |
getInterface(int index)
Returns the
UsbInterface at the given index. |
int |
getInterfaceCount()
Returns the number of
UsbInterface s this device contains. |
int |
getProductId()
Returns a product ID for the device.
|
int |
getVendorId()
Returns a vendor ID for the device.
|
int |
hashCode()
Returns an integer hash code for this object.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel.
|
public static final Parcelable.Creator<UsbDevice> CREATOR
public UsbDevice(String name, int vendorId, int productId, int Class, int subClass, int protocol, Parcelable[] interfaces)
public String getDeviceName()
public int getDeviceId()
public int getVendorId()
public int getProductId()
public int getDeviceClass()
UsbConstants
.public int getDeviceSubclass()
public int getDeviceProtocol()
public int getInterfaceCount()
UsbInterface
s this device contains.public UsbInterface getInterface(int index)
UsbInterface
at the given index.public boolean equals(Object o)
Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
o
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public int describeContents()
Parcelable
describeContents
in interface Parcelable
public void writeToParcel(Parcel parcel, int flags)
Parcelable
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public static int getDeviceId(String name)
public static String getDeviceName(int id)