FileDocCategorySizeDatePackage
UsbInterface.javaAPI DocAndroid 5.1 API5909Thu Mar 12 22:22:10 GMT 2015android.hardware.usb

UsbInterface

public class UsbInterface extends Object implements android.os.Parcelable
A class representing an interface on a {@link UsbDevice}. USB devices can have one or more interfaces, each one providing a different piece of functionality, separate from the other interfaces. An interface will have one or more {@link UsbEndpoint}s, which are the channels by which the host transfers data with the device.

Developer Guides

For more information about communicating with USB hardware, read the USB developer guide.

Fields Summary
private final int
mId
private final int
mAlternateSetting
private final String
mName
private final int
mClass
private final int
mSubclass
private final int
mProtocol
private android.os.Parcelable[]
mEndpoints
public static final Parcelable.Creator
CREATOR
Constructors Summary
public UsbInterface(int id, int alternateSetting, String name, int Class, int subClass, int protocol)
UsbInterface should only be instantiated by UsbService implementation

hide

        mId = id;
        mAlternateSetting = alternateSetting;
        mName = name;
        mClass = Class;
        mSubclass = subClass;
        mProtocol = protocol;
    
Methods Summary
public intdescribeContents()


       
        return 0;
    
public intgetAlternateSetting()
Returns the interface's bAlternateSetting field. This is an integer that along with the ID uniquely identifies the interface on the device. {@link UsbDeviceConnection#setInterface} can be used to switch between two interfaces with the same ID but different alternate setting.

return
the interface's alternate setting

        return mAlternateSetting;
    
public UsbEndpointgetEndpoint(int index)
Returns the {@link android.hardware.usb.UsbEndpoint} at the given index.

return
the endpoint

        return (UsbEndpoint)mEndpoints[index];
    
public intgetEndpointCount()
Returns the number of {@link android.hardware.usb.UsbEndpoint}s this interface contains.

return
the number of endpoints

        return mEndpoints.length;
    
public intgetId()
Returns the interface's bInterfaceNumber field. This is an integer that along with the alternate setting uniquely identifies the interface on the device.

return
the interface's ID

        return mId;
    
public intgetInterfaceClass()
Returns the interface's class field. Some useful constants for USB classes can be found in {@link UsbConstants}

return
the interface's class

        return mClass;
    
public intgetInterfaceProtocol()
Returns the interface's protocol field.

return
the interface's protocol

        return mProtocol;
    
public intgetInterfaceSubclass()
Returns the interface's subclass field.

return
the interface's subclass

        return mSubclass;
    
public java.lang.StringgetName()
Returns the interface's name.

return
the interface's name

        return mName;
    
public voidsetEndpoints(android.os.Parcelable[] endpoints)
Only used by UsbService implementation

hide

        mEndpoints = endpoints;
    
public java.lang.StringtoString()

        StringBuilder builder = new StringBuilder("UsbInterface[mId=" + mId +
                ",mAlternateSetting=" + mAlternateSetting +
                ",mName=" + mName + ",mClass=" + mClass +
                ",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol +
                ",mEndpoints=[");
        for (int i = 0; i < mEndpoints.length; i++) {
            builder.append("\n");
            builder.append(mEndpoints[i].toString());
        }
        builder.append("]");
        return builder.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeInt(mId);
        parcel.writeInt(mAlternateSetting);
        parcel.writeString(mName);
        parcel.writeInt(mClass);
        parcel.writeInt(mSubclass);
        parcel.writeInt(mProtocol);
        parcel.writeParcelableArray(mEndpoints, 0);