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 ofUsbDeviceConnection.
-
-
Constructor Summary
Constructors Constructor Description ShadowUsbDeviceConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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)InputStreamgetOutgoingDataStream()Provides anInputStreamthat allows reading data written by UsbDeviceConnection#bulkTransfer.voidreadOutgoingData(byte[] buffer)Deprecated.prefergetOutgoingDataStream(), which allows callers to know how much data has been read and when theUsbDeviceConnectioncloses.protected booleanreleaseInterface(UsbInterface intf)protected UsbRequestrequestWait()protected UsbRequestrequestWait(long timeout)protected booleansetInterface(UsbInterface intf)No-op on Robolectrict.voidwriteIncomingData(byte[] data)Passes data that can then be read by an initialized UsbRequest#queue(ByteBuffer).
-
-
-
Method Detail
-
claimInterface
@Implementation protected boolean claimInterface(UsbInterface intf, boolean force)
-
releaseInterface
@Implementation protected boolean releaseInterface(UsbInterface intf)
-
setInterface
@Implementation(minSdk=21) protected boolean setInterface(UsbInterface intf)
No-op on Robolectrict. The real implementation would return false on Robolectric and make it impossible to test callers that expect a successful result. Always returnstrue.
-
controlTransfer
@Implementation(minSdk=19) protected int controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout)
-
controlTransfer
@Implementation(minSdk=19) protected int controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int offset, int length, int timeout)
-
requestWait
@Implementation protected UsbRequest requestWait()
-
requestWait
@Implementation(minSdk=26) protected UsbRequest requestWait(long timeout) throws TimeoutException
- Throws:
TimeoutException
-
bulkTransfer
@Implementation(minSdk=18) 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)
-
readOutgoingData
@Deprecated public void readOutgoingData(byte[] buffer) throws IOException
Deprecated.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
-
getOutgoingDataStream
public InputStream getOutgoingDataStream()
Provides anInputStreamthat allows reading data written by UsbDeviceConnection#bulkTransfer. Closing this stream has no effect. It is effectively closed duringUsbDeviceConnection.releaseInterface(UsbInterface).
-
writeIncomingData
public void writeIncomingData(byte[] data)
Passes data that can then be read by an initialized UsbRequest#queue(ByteBuffer).
-
-