1
0
mirror of https://github.com/mik3y/usb-serial-for-android.git synced 2026-08-15 10:22:56 +00:00

write + purge tests, remove unused read buffer code

This commit is contained in:
kai-morich
2019-11-03 13:59:50 +01:00
parent 5c6748e1b8
commit e1b62cf675
2 changed files with 141 additions and 33 deletions
@@ -31,9 +31,8 @@ import java.io.IOException;
*
* @author mike wakerly (opensource@hoho.com)
*/
abstract class CommonUsbSerialPort implements UsbSerialPort {
public abstract class CommonUsbSerialPort implements UsbSerialPort {
public static final int DEFAULT_READ_BUFFER_SIZE = 16 * 1024;
public static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024;
protected final UsbDevice mDevice;
@@ -42,12 +41,8 @@ abstract class CommonUsbSerialPort implements UsbSerialPort {
// non-null when open()
protected UsbDeviceConnection mConnection = null;
protected final Object mReadBufferLock = new Object();
protected final Object mWriteBufferLock = new Object();
/** Internal read buffer. Guarded by {@link #mReadBufferLock}. */
protected byte[] mReadBuffer;
/** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */
protected byte[] mWriteBuffer;
@@ -55,7 +50,6 @@ abstract class CommonUsbSerialPort implements UsbSerialPort {
mDevice = device;
mPortNumber = portNumber;
mReadBuffer = new byte[DEFAULT_READ_BUFFER_SIZE];
mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE];
}
@@ -89,21 +83,6 @@ abstract class CommonUsbSerialPort implements UsbSerialPort {
return mConnection.getSerial();
}
/**
* Sets the size of the internal buffer used to exchange data with the USB
* stack for read operations. Most users should not need to change this.
*
* @param bufferSize the size in bytes
*/
public final void setReadBufferSize(int bufferSize) {
synchronized (mReadBufferLock) {
if (bufferSize == mReadBuffer.length) {
return;
}
mReadBuffer = new byte[bufferSize];
}
}
/**
* Sets the size of the internal buffer used to exchange data with the USB
* stack for write operations. Most users should not need to change this.