Package org.robolectric.shadows
Class ShadowUsbDeviceConnection
java.lang.Object
org.robolectric.shadows.ShadowUsbDeviceConnection
@Implements(android.hardware.usb.UsbDeviceConnection.class)
public class ShadowUsbDeviceConnection
extends Object
Robolectric implementation of 
UsbDeviceConnection.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected intbulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout) protected intbulkTransfer(UsbEndpoint endpoint, byte[] buffer, int offset, int length, int timeout) protected booleanclaimInterface(UsbInterface intf, boolean force) protected intcontrolTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout) protected intcontrolTransfer(int requestType, int request, int value, int index, byte[] buffer, int offset, int length, int timeout) Provides anInputStreamthat allows reading data written by UsbDeviceConnection#bulkTransfer.voidreadOutgoingData(byte[] buffer) Deprecated.protected booleanreleaseInterface(UsbInterface intf) protected UsbRequestprotected UsbRequestrequestWait(long timeout) protected booleansetInterface(UsbInterface intf) No-op on Robolectric.voidwriteIncomingData(byte[] data) Passes data that can then be read by an initialized UsbRequest#queue(ByteBuffer).
- 
Constructor Details- 
ShadowUsbDeviceConnectionpublic ShadowUsbDeviceConnection()
 
- 
- 
Method Details- 
claimInterface
- 
releaseInterface
- 
setInterfaceNo-op on Robolectric. The real implementation would return false on Robolectric and make it impossible to test callers that expect a successful result. Always returnstrue.
- 
controlTransfer@Implementation protected int controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout) 
- 
controlTransfer@Implementation protected int controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int offset, int length, int timeout) 
- 
requestWait
- 
requestWait- Throws:
- TimeoutException
 
- 
bulkTransfer@Implementation protected int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int offset, int length, int timeout) 
- 
bulkTransfer@Implementation protected int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout) 
- 
readOutgoingDataDeprecated.prefergetOutgoingDataStream(), which allows callers to know how much data has been read and when theUsbDeviceConnectioncloses.Fills the buffer with data that was written by UsbDeviceConnection#bulkTransfer.- Throws:
- IOException
 
- 
getOutgoingDataStreamProvides anInputStreamthat allows reading data written by UsbDeviceConnection#bulkTransfer. Closing this stream has no effect. It is effectively closed duringUsbDeviceConnection.releaseInterface(UsbInterface).
- 
writeIncomingDatapublic void writeIncomingData(byte[] data) Passes data that can then be read by an initialized UsbRequest#queue(ByteBuffer).
 
- 
getOutgoingDataStream(), which allows callers to know how much data has been read and when theUsbDeviceConnectioncloses.