magnusja / libaums

Open source library to access USB Mass Storage devices on Android without rooting your device
Apache License 2.0
1.26k stars 270 forks source link

hey, Copy the meeting report through fat32 here Error transferring command; errno 0 null #385

Closed zhangpeng1112 closed 1 year ago

zhangpeng1112 commented 1 year ago

UsbFile targetFile = null; try { targetFile = usbFile.createFile(fileName); FileInputStream fis = new FileInputStream(file); //int size = fis.available(); long size = file.length(); UsbFileOutputStream uos = new UsbFileOutputStream(targetFile); //8K 缓冲区 byte[] buffer = new byte[1024 16]; //byte[] buffer = new byte[(int) Constants.BytesPerCluster]; long readPos = 0; long writePos = 0; LogUtils.v("PtoU copy " + fileName + " to " + targetFile.getAbsolutePath()); long time1 = System.currentTimeMillis(); while ((readPos = fis.read(buffer)) != -1) { uos.write(buffer, 0, (int) readPos); writePos += readPos; if (listener != null) { listener.onProgress((int) (writePos 100l / size)); LogUtils.v("PtoU write file with progress = " + (int) (writePos * 100l / size)); } } uos.flush(); fis.close(); uos.close();

magnusja commented 1 year ago

Try libusbcommunication https://github.com/magnusja/libaums/tree/develop/libusbcommunication

zhangpeng1112 commented 1 year ago

Sorry, this libusbcommunication may also have errors jint Java_me_jahnen_libaums_libusbcommunication_LibusbCommunication_nativeBulkTransfer(JNIEnv *, jobject, jlong, jint, jbyteArray, jint, jint, jint):86 libusb_bulk_transfer returned -7, Operation timed out

zhangpeng1112 commented 1 year ago
implementation 'me.jahnen.libaums:libusbcommunication:0.3.0'

implementation'me.jahnen.libaums:httpserver:0.6.2'
magnusja commented 1 year ago

What kind of device are you using? Can you try a different OTG adapter?

zhangpeng1112 commented 1 year ago

phone :OnePlus 6 Xiami 6 HUAWEI P30

zhangpeng1112 commented 1 year ago

device:aigo Device