public final class UsbPort extends Object implements Parcelable
This object is immutable.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<UsbPort> |
CREATOR |
static int |
DATA_ROLE_DEVICE
Data role: This USB port can act as a device (offer data services).
|
static int |
DATA_ROLE_HOST
Data role: This USB port can act as a host (access data services).
|
static int |
MODE_DFP
Mode bit: This USB port can act as a downstream facing port (host).
|
static int |
MODE_DUAL
Mode bit: This USB port can act either as an downstream facing port (host) or as
an upstream facing port (device).
|
static int |
MODE_UFP
Mode bit: This USB port can act as an upstream facing port (device).
|
static int |
POWER_ROLE_SINK
Power role: This USB port can act as a sink (receive power).
|
static int |
POWER_ROLE_SOURCE
Power role: This USB port can act as a source (provide power).
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
static void |
checkRoles(int powerRole,
int dataRole) |
static int |
combineRolesAsBit(int powerRole,
int dataRole)
Combines one power and one data role together into a unique value with
exactly one bit set.
|
static String |
dataRoleToString(int role) |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
String |
getId()
Gets the unique id of the port.
|
int |
getSupportedModes()
Gets the supported modes of the port.
|
static String |
modeToString(int mode) |
static String |
powerRoleToString(int role) |
static String |
roleCombinationsToString(int combo) |
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final int MODE_DFP
Implies that the port supports the POWER_ROLE_SOURCE
and DATA_ROLE_HOST
combination of roles (and possibly others as well).
public static final int MODE_UFP
Implies that the port supports the POWER_ROLE_SINK
and DATA_ROLE_DEVICE
combination of roles (and possibly others as well).
public static final int MODE_DUAL
Implies that the port supports the POWER_ROLE_SOURCE
and DATA_ROLE_HOST
combination of roles and the POWER_ROLE_SINK
and DATA_ROLE_DEVICE
combination of roles (and possibly others as well).
public static final int POWER_ROLE_SOURCE
public static final int POWER_ROLE_SINK
public static final int DATA_ROLE_HOST
public static final int DATA_ROLE_DEVICE
public static final Parcelable.Creator<UsbPort> CREATOR
public UsbPort(String id, int supportedModes)
public String getId()
public int getSupportedModes()
The actual mode of the port may vary depending on what is plugged into it.
public static int combineRolesAsBit(int powerRole, int dataRole)
powerRole
- The desired power role: POWER_ROLE_SOURCE
or POWER_ROLE_SINK
, or 0 if no power role.dataRole
- The desired data role: DATA_ROLE_HOST
or DATA_ROLE_DEVICE
, or 0 if no data role.public static String modeToString(int mode)
public static String powerRoleToString(int role)
public static String dataRoleToString(int role)
public static String roleCombinationsToString(int combo)
public static void checkRoles(int powerRole, int dataRole)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- 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
.