magnusja / libaums

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

Usbfileman onCreate() is frozen #123

Open fgpzen opened 6 years ago

fgpzen commented 6 years ago

Hey, I got some problems when using Usbfileman (example applicatoin):

  1. At first, I connected Android phone with MicroSD card reader by using OTG cable (Figure 1-1), then started Usbfileman and authorized. In this case, Usbfileman started normally. Then I connected MP3, found that [usbManager] could be read, but a Log: [no device found!] would be printed, So I went to see the source code of [MassStorageDevices = UsbMassStorageDevice.getMassStorageDevices (this)], and I found that the value of [usbInterface.getInterfaceSubclass ()] was 5 instead of 6, I didn’t know what did this value mean, so I tried to modify the IF statement, as shown in [Figure 1-2]. I restarted Usbfileman, then problem 2 came out.

Figure 1-1: figure 1-1 Figure 1-2: figure 1-2

Code position: https://github.com/magnusja/libaums/blob/develop/libaums/src/main/java/com/github/mjdev/libaums/UsbMassStorageDevice.java#L138

  1. I connected Android phone with MP3 by using OTG, then started Usbfileman and authorized. Usbfileman will be frozen for about 3 minutes before reading the MP3 file system (Figure 2-1,2-2,2-3), so there came problem 3. I found there was a MicroSD card slot on the MP3 (Figure 2-4), so inserting the MicroSD card (Figure 2-5), connecting the phone, authorizing. And Usbfileman started normally, but MicroSD card information couldn’t be read, there came problem 4.

Figure 2-1: figure 2-1 Figure 2-2,2-3 Compare System File Explorer: figure 2-2 figure 2-3 Figure 2-4: figure 2-4 Figure 2-5: figure 2-5

Frozen code: boolean claim = deviceConnection.claimInterface(usbInterface, true);

Frozen code position: https://github.com/magnusja/libaums/blob/develop/libaums/src/main/java/com/github/mjdev/libaums/UsbMassStorageDevice.java#L222

  1. I tried to use a card reader without MicroSD card to connect the phone (Figure 3-1), starting Usbfileman, Authorizing, then Usbfileman would be frozen.

Figure 3-1: figure 3-1

  1. I inserted MicroSD to the card slot of MP3, but Usbfileman couldn’t read the MicroSD card information (Figure 4-1,4-2), while the system's file explorer could read it (Figure 4-3), printing out that Log [massStorageDevices.length] had a value of 1.

Figure 4-1: figure 4-1 Figure 4-2: figure 4-2 Figure 4-3: figure 4-3

Code: massStorageDevices = UsbMassStorageDevice.getMassStorageDevices(this);

Code position: https://github.com/magnusja/libaums/blob/develop/app/src/main/java/com/github/mjdev/libaums/usbfileman/MainActivity.java#L726

magnusja commented 6 years ago

Hey there,

sorry for the late response.

So in general changing, some constants is probably not a good idea, especially when you do not know what they mean.

According to this document (http://www.usblyzer.com/usb-mass-storage-class-msc-decoder.htm) a 6 means SFF-8070i. My library only supports SCSI transparent command set.

That said, it is weird that it seems to work (at least partly). Unfortunately, I do not have time at the moment to look into this, so I would suggest that you do some research about SFF-8070i.

fgpzen commented 6 years ago

Thank you!

reardenlife commented 5 years ago

Alright. Did anyone figured out how to work with 8070i?