UsbDevice
open class UsbDevice : Parcelable
kotlin.Any | |
↳ | android.hardware.usb.UsbDevice |
This class represents a USB device attached to the android device with the android device acting as the USB host. Each device contains one or more 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. android.hardware.usb.UsbDeviceConnection#controlTransfer is used for control requests on endpoint zero.
Summary
Inherited constants | |
---|---|
Public methods | |
---|---|
open Int | |
open Boolean |
Indicates whether some other object is "equal to" this one. |
open UsbConfiguration |
getConfiguration(index: Int) Returns the |
open Int |
Returns the number of |
open Int |
Returns the devices's class field. |
open Int |
Returns a unique integer ID for the device. |
open static Int |
getDeviceId(name: String!) |
open String |
Returns the name of the device. |
open static String! |
getDeviceName(id: Int) |
open Int |
Returns the device's protocol field. |
open Int |
Returns the device's subclass field. |
open UsbInterface |
getInterface(index: Int) Returns the |
open Int |
Returns the number of |
open String? |
Returns the manufacturer name of the device. |
open Int |
Returns a product ID for the device. |
open String? |
Returns the product name of the device. |
open String? |
Returns the serial number of the device. |
open Int |
Returns a vendor ID for the device. |
open String |
Returns the version number of the device. |
open Int |
hashCode() |
open String |
toString() |
open Unit |
writeToParcel(parcel: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<UsbDevice!> |
Public methods
describeContents
open fun describeContents(): Int
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
equals
open fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
Parameters | |
---|---|
obj |
the reference object with which to compare. |
o |
This value may be null . |
Return | |
---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getConfiguration
open fun getConfiguration(index: Int): UsbConfiguration
Returns the UsbConfiguration
at the given index.
Return | |
---|---|
UsbConfiguration |
the configuration This value cannot be null . |
getConfigurationCount
open fun getConfigurationCount(): Int
Returns the number of UsbConfiguration
s this device contains.
Return | |
---|---|
Int |
the number of configurations |
getDeviceClass
open fun getDeviceClass(): Int
Returns the devices's class field. Some useful constants for USB device classes can be found in UsbConstants
.
Return | |
---|---|
Int |
the devices's class |
getDeviceId
open fun getDeviceId(): Int
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. IDs are not persistent across USB disconnects.
Return | |
---|---|
Int |
the device ID |
getDeviceName
open fun getDeviceName(): String
Returns the name of the device. In the standard implementation, this is the path of the device file for the device in the usbfs file system.
Return | |
---|---|
String |
the device name This value cannot be null . |
getDeviceProtocol
open fun getDeviceProtocol(): Int
Returns the device's protocol field.
Return | |
---|---|
Int |
the device's protocol |
getDeviceSubclass
open fun getDeviceSubclass(): Int
Returns the device's subclass field.
Return | |
---|---|
Int |
the device's subclass |
getInterface
open fun getInterface(index: Int): UsbInterface
Returns the UsbInterface
at the given index. For devices with multiple configurations, you will probably want to use UsbConfiguration.getInterface
instead.
Return | |
---|---|
UsbInterface |
the interface This value cannot be null . |
getInterfaceCount
open fun getInterfaceCount(): Int
Returns the number of UsbInterface
s this device contains. For devices with multiple configurations, you will probably want to use UsbConfiguration.getInterfaceCount
instead.
Return | |
---|---|
Int |
the number of interfaces |
getManufacturerName
open fun getManufacturerName(): String?
Returns the manufacturer name of the device.
Return | |
---|---|
String? |
the manufacturer name, or null if the property could not be read |
getProductId
open fun getProductId(): Int
Returns a product ID for the device.
Return | |
---|---|
Int |
the device product ID |
getProductName
open fun getProductName(): String?
Returns the product name of the device.
Return | |
---|---|
String? |
the product name, or null if the property could not be read |
getSerialNumber
open fun getSerialNumber(): String?
Returns the serial number of the device.
Return | |
---|---|
String? |
the serial number name, or null if the property could not be read |
Exceptions | |
---|---|
java.lang.SecurityException |
if the app targets SDK >= {@value android.os.Build.VERSION_CODES#Q} and the app does not have permission to read from the device. |
getVendorId
open fun getVendorId(): Int
Returns a vendor ID for the device.
Return | |
---|---|
Int |
the device vendor ID |
getVersion
open fun getVersion(): String
Returns the version number of the device.
Return | |
---|---|
String |
the device version This value cannot be null . |
hashCode
open fun hashCode(): Int
Return | |
---|---|
Int |
a hash code value for this object. |
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
parcel: Parcel,
flags: Int
): Unit
Parameters | |
---|---|
dest |
The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |