-
Notifications
You must be signed in to change notification settings - Fork 272
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
Permission request + Wrong CSW status #163
Comments
Did you try the delay with sleeping proposed in issue #124 ? |
Yes, also tried that with no success. |
In some other thread, they suggested ignoring the CSW status overall. Apparently, everything still works fine. But this is obviously wrong specification-wise. Maybe there is also a bug related to parsing the CSW status. Did you try different pen drives? |
Sorry didn't yet. Only tried with single one, also tried reformatting it few times FAT, FAT32 and still the same. |
i also found this problem when I use 64G + storage. UsbDevice information is as follows: public class MediaReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null) {
return;
}
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
return;
}
switch (action) {
case Intent.ACTION_MEDIA_CHECKING:
break;
case Intent.ACTION_MEDIA_MOUNTED:
// 获取挂载路径, 读取U盘文件
WLogTool.e("MOUNTED");
Uri uri = intent.getData();
if (uri != null) {
String filePath = uri.getPath();
File rootFile = new File(filePath);
WLogTool.e(rootFile.getAbsolutePath());
for (File file : rootFile.listFiles()) {
// 文件列表...
WLogTool.e(file.getAbsolutePath());
}
}
break;
case Intent.ACTION_MEDIA_EJECT:
break;
case Intent.ACTION_MEDIA_UNMOUNTED:
WLogTool.e("UNMOUNTED");
break;
}
}
} |
Same here, |
Hey @lorenzos I havent tried sd card readers in while, but I remember that lots of them caused troubles :/ Did you try removing this check completely? |
@magnusja I did not. If I clone the repo locally and load "libaums" folder as a local gradle module, it should work as it is? Doesn’t it require additional building steps, etc? Thanks. |
Yes that should work |
@magnusja Just tried, unfortunately removing the check doesn't bring me far: I immediately get a Edit: if I try repeating the access to the device, I get similar errors, but with different |
Yes I tried to get some more error information because Android API only throws an exception with no information at all but it seems that the |
Hi @magnusja I had been testing your library and got into the similar problems: It occurred only when using card reader device. When using the USB pen drive there was no problem. I discovered there is by default LUN set to the 0. In the case of the card reader device every physical slot has its logical unit assigned. So if I change the LUN then corresponding card reader port starts working. Right now there is no possibility to choose the LUN in the code. If you agree with that I would like to help you with implementation of this functionality. But I have no time for waste so I want to consult it before I apply for the pull request so we prevent some useless steps. I suggest to add some methods into |
I wish I had seen your post earlier @lukasniedoba. |
Hey @lukasniedoba , @timcrid , thanks for the support! I am always happy to take PRs. The LUN thing has been on my list for a while now. @timcrid Your solution works but is probably a little hacky :D @lukasniedoba The best solution imho would be if the user of the library does not really need to change anything. He or she just sees an additional device for each inserted SD card. Maybe additional partitions of a particular device would also be fine. In terms of implementation I am not a 100% sure. If on device level we would need some kind of wrapper around the |
Looking at the code, maybe it makes sense to hook in here: https://github.com/magnusja/libaums/blob/develop/libaums/src/main/java/com/github/mjdev/libaums/UsbMassStorageDevice.java#L230 And just loop over the max LUNs and create a new mass storage device for each LUN. |
@timcrid @lukasniedoba can you please try this: #201 |
Hey @magnusja |
awesome :) will merge, will be in the next release |
Experiencing similar problem as #124:
When not using intent-filter and only requesting permission inside MainActivity, the application works fine. The problem is that with
usbManager.requirePermission()
the user "default checkbox" selection is not saved and the permission dialog keeps opening each time USB device is attached.Now I tried adding intent-filter with
USB_DEVICE_ATTACHED
action code which by documentation should save permission choice that user selected the first time.The first time USB is attached the code works like it should - but each next time USB attaches, the library throws me:
Any ideas why this would happen?
I understand if library was throwing this in both cases (using intent-filter and just requesting for permission) but what bothers me is that when manually requesting for permission, library works as supposed but when using filter-intent not.
The text was updated successfully, but these errors were encountered: