7171@ Slf4j
7272public class UsbMassStorageDevice {
7373
74- /**
75- * Usb communication which uses the newer API in Android Jelly Bean MR2 (API
76- * level 18). It just delegates the calls to the {@link UsbDeviceConnection}
77- * .
78- *
79- * @author mjahnen
80- *
81- */
82- // @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
83- // private class JellyBeanMr2Communication implements UsbCommunication {
84- // @Override
85- // public int bulkOutTransfer(byte[] buffer, int length) {
86- // return deviceConnection.bulkTransfer(outEndpoint, buffer, length, TRANSFER_TIMEOUT);
87- // }
88- //
89- // @Override
90- // public int bulkOutTransfer(byte[] buffer, int offset, int length) {
91- // return deviceConnection.bulkTransfer(outEndpoint, buffer, offset, length,
92- // TRANSFER_TIMEOUT);
93- // }
94- //
95- // @Override
96- // public int bulkInTransfer(byte[] buffer, int length) {
97- // return deviceConnection.bulkTransfer(inEndpoint, buffer, length, TRANSFER_TIMEOUT);
98- // }
99- //
100- // @Override
101- // public int bulkInTransfer(byte[] buffer, int offset, int length) {
102- // return deviceConnection.bulkTransfer(inEndpoint, buffer, offset, length,
103- // TRANSFER_TIMEOUT);
104- // }
105- // }
106-
107- /**
108- * On Android API level lower 18 (Jelly Bean MR2) we cannot specify a start
109- * offset in the source/destination array. Because of that we have to use
110- * this workaround, where we have to copy the data every time offset is non
111- * zero.
112- *
113- * @author mjahnen
114- *
115- */
116- // private class HoneyCombMr1Communication implements UsbCommunication {
117- // @Override
118- // public int bulkOutTransfer(byte[] buffer, int length) {
119- // return deviceConnection.bulkTransfer(outEndpoint, buffer, length, TRANSFER_TIMEOUT);
120- // }
121- //
122- // @Override
123- // public int bulkOutTransfer(byte[] buffer, int offset, int length) {
124- // if (offset == 0)
125- // return deviceConnection.bulkTransfer(outEndpoint, buffer, length, TRANSFER_TIMEOUT);
126- //
127- // byte[] tmpBuffer = new byte[length];
128- // System.arraycopy(buffer, offset, tmpBuffer, 0, length);
129- // return deviceConnection.bulkTransfer(outEndpoint, tmpBuffer, length,
130- // TRANSFER_TIMEOUT);
131- // }
132- //
133- // @Override
134- // public int bulkInTransfer(byte[] buffer, int length) {
135- // return deviceConnection.bulkTransfer(inEndpoint, buffer, length, TRANSFER_TIMEOUT);
136- // }
137- //
138- // @Override
139- // public int bulkInTransfer(byte[] buffer, int offset, int length) {
140- // if (offset == 0)
141- // return deviceConnection.bulkTransfer(inEndpoint, buffer, length, TRANSFER_TIMEOUT);
142- //
143- // byte[] tmpBuffer = new byte[length];
144- // int result = deviceConnection.bulkTransfer(inEndpoint, tmpBuffer, length,
145- // TRANSFER_TIMEOUT);
146- // System.arraycopy(tmpBuffer, 0, buffer, offset, length);
147- // return result;
148- // }
149- // }
150-
151-
152-
153- private static int TRANSFER_TIMEOUT = 21000 ;
154-
155-
15674 UsbMassStorageDeviceConfig usbMassStorageDeviceConfig ;
15775
15876 @ Getter
@@ -163,7 +81,7 @@ public class UsbMassStorageDevice {
16381 // this two parameters will be overwritten with values
16482 private boolean loadPartitionTable = true ;
16583
166- Usb4JavaUsbDeviceCommunication communication ;
84+ private Usb4JavaUsbDeviceCommunication communication ;
16785 private boolean connectedToDevice ;
16886
16987 /**
@@ -299,7 +217,6 @@ public static List<UsbMassStorageDeviceConfig> getListOfAttachedUsbMassStorageDe
299217 }
300218
301219
302-
303220 /**
304221 * Initializes the mass storage device and determines different things like
305222 * for example the MBR or the file systems for the different partitions.
@@ -340,8 +257,6 @@ private void setupDevice() throws LibAumsException {
340257 partitionTable = PartitionTableFactory .createPartitionTable (blockDevice );
341258 initPartitions ();
342259 }
343-
344-
345260 }
346261
347262 /**
@@ -384,16 +299,5 @@ public List<Partition> getPartitions() {
384299 return partitions ;
385300 }
386301
387- /**
388- * This returns the @link android.hardware.usb.UsbDevice which can be used
389- * to request permission for communication.
390- *
391- // @return Underlying @link android.hardware.usb.UsbDevice used for
392- * communication.
393- */
394- // public UsbDevice getUsbDevice() {
395- // return usbDevice;
396- // }
397-
398302
399303}
0 commit comments