Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsbMassStorageDeivce.init() throw exception #419

Open
frank-yulingfeng opened this issue May 15, 2024 · 1 comment
Open

UsbMassStorageDeivce.init() throw exception #419

frank-yulingfeng opened this issue May 15, 2024 · 1 comment

Comments

@frank-yulingfeng
Copy link

Problem

runing program on android 10 system。plugin a usb device, and then use the api UsbMassStorageDeivce.init(), this method throw exception like below

Expected behavior

init usb mass storage device success

Actual behavior

Stacktrace of Excpetion

java.lang.IllegalArgumentException
at java.nio.Buffer.limit(Buffer.java:290)
at java.nio.ByteBuffer.limit(ByteBuffer.java:818)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.transferOneCommand(ScsiBlockDevice.kt:280)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.requestSense(ScsiBlockDevice.kt:222)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.handleCommandResult(ScsiBlockDevice.kt:207)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.transferCommand(ScsiBlockDevice.kt:155)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.transferCommandWithoutDataPhase(ScsiBlockDevice.kt:199)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.initAttempt(ScsiBlockDevice.kt:115)
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.init(ScsiBlockDevice.kt:83)
at me.jahnen.libaums.core.UsbMassStorageDevice.setupDevice(UsbMassStorageDevice.kt:138)
at me.jahnen.libaums.core.UsbMassStorageDevice.init(UsbMassStorageDevice.kt:100)
at com.example.test.MainActivity.testlibaums(MainActivity.java:467)
at com.example.test.MainActivity.btnTestClicked(MainActivity.java:195)
at com.example.test.MainActivity.$r8$lambda$fyDzIc6E7gCccObvGSAp9XPEj5Y(Unknown Source:0)
at com.example.test.MainActivity$$ExternalSyntheticLambda1.onClick(D8$$SyntheticClass:0)
at android.view.View.performClick(View.java:7322)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1213)
at android.view.View.performClickInternal(View.java:7296)
at android.view.View.access$3600(View.java:839)
at android.view.View$PerformClick.run(View.java:28319)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8673)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

Code where problem occurs

@viralnakrani
Copy link

viralnakrani commented May 24, 2024

Facing same issues at my End also, while integrating mass storage USB on android 14 device.
@magnusja please help to resolve this issue here is full response with Exception while try to call massStorageDevice.init() in my code.

RESPONSE
found usb device: /dev/bus/usb/001/029=UsbDevice[mName=/dev/bus/usb/001/029,mVendorId=6421,mProductId=21018,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Nordic Semiconductor,mProductName=Bio,mVersion=1.00,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@1f9d6d6, mHasAudioPlayback=false, mHasAudioCapture=false, mHasMidi=false, mHasVideoCapture=false, mHasVideoPlayback=false, mConfigurations=[
UsbConfiguration[mId=1,mName=Default configuration,mAttributes=192,mMaxPower=250,mInterfaces=[
UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=8,mSubclass=6,mProtocol=80,mEndpoints=[
UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]
UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=64,mInterval=0]]]]

Found usb interface: UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=8,mSubclass=6,mProtocol=80,mEndpoints=[
UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]
UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=64,mInterval=0]]

Found usb endpoint: UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]
Found usb endpoint: UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=64,mInterval=0]
AndroidUsbCommunication D setup device
MAX LUN 0
inquiry response: ScsiInquiryResponse [peripheralQualifier=0, peripheralDeviceType=0, removableMedia=false, spcVersion=6, responseDataFormat=2]
Block size: 4096
Last block address: 262143
FileSystemPartitionTableCreator returned null

java.lang.IllegalArgumentException: buffer.remaining() must be multiple of blockSize!
at me.jahnen.libaums.core.driver.scsi.ScsiBlockDevice.read(ScsiBlockDevice.kt:326)
at com.github.mjdev.libaums.partition.gpt.GPT$Companion.read(GPT.kt:37)
at com.github.mjdev.libaums.partition.gpt.GPTCreator.read(GPTCreator.kt:9)
at me.jahnen.libaums.core.partition.PartitionTableFactory.createPartitionTable(PartitionTableFactory.kt:66)
at me.jahnen.libaums.core.UsbMassStorageDevice.setupDevice(UsbMassStorageDevice.kt:144)
at me.jahnen.libaums.core.UsbMassStorageDevice.init(UsbMassStorageDevice.kt:100)
at sample.projects.12.activity.HomeActivity.openDevice(HomeActivity.java:4201)
at sample.projects.12.activity.HomeActivity.access$000(HomeActivity.java:166)
at sample.projects.12.activity.HomeActivity$10.onReceive(HomeActivity.java:4078)
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1865)
at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:223)
at android.os.Looper.loop(Looper.java:324)
at android.app.ActivityThread.main(ActivityThread.java:8547)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants