FileDocCategorySizeDatePackage
UsbAccessoryBulkTransport.javaAPI DocAndroid 5.1 API2485Thu Mar 12 22:22:42 GMT 2015com.android.accessorydisplay.sink

UsbAccessoryBulkTransport

public class UsbAccessoryBulkTransport extends com.android.accessorydisplay.common.Transport
Sends or receives messages using bulk endpoints associated with a {@link UsbDevice} that represents a USB accessory.

Fields Summary
private static final int
TIMEOUT_MILLIS
private android.hardware.usb.UsbDeviceConnection
mConnection
private android.hardware.usb.UsbEndpoint
mBulkInEndpoint
private android.hardware.usb.UsbEndpoint
mBulkOutEndpoint
Constructors Summary
public UsbAccessoryBulkTransport(com.android.accessorydisplay.common.Logger logger, android.hardware.usb.UsbDeviceConnection connection, android.hardware.usb.UsbEndpoint bulkInEndpoint, android.hardware.usb.UsbEndpoint bulkOutEndpoint)


        
                
        super(logger, 16384);
        mConnection = connection;
        mBulkInEndpoint = bulkInEndpoint;
        mBulkOutEndpoint = bulkOutEndpoint;
    
Methods Summary
protected voidioClose()

        mConnection = null;
        mBulkInEndpoint = null;
        mBulkOutEndpoint = null;
    
protected intioRead(byte[] buffer, int offset, int count)

        if (mConnection == null) {
            throw new IOException("Connection was closed.");
        }
        return mConnection.bulkTransfer(mBulkInEndpoint, buffer, offset, count, -1);
    
protected voidioWrite(byte[] buffer, int offset, int count)

        if (mConnection == null) {
            throw new IOException("Connection was closed.");
        }
        int result = mConnection.bulkTransfer(mBulkOutEndpoint,
                buffer, offset, count, TIMEOUT_MILLIS);
        if (result < 0) {
            throw new IOException("Bulk transfer failed.");
        }