| Summary: | Unhandled SecurityException in HIDDeviceUSB::getSerialNumber() | ||
|---|---|---|---|
| Product: | SDL | Reporter: | sdlbugs |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.12 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | Patch to catch, log and sink SecurityException | ||
|
Description
sdlbugs
2020-05-26 12:19:14 UTC
Note that this function is only called if the USB device identifies as a HID device, which should rule out external storage or cameras. It's getting triggered somehow though. Having real problems reproducing it. Error reporting devices were a OnePlus7ProTMO and a Motorola One Hyper, both running Android 10 I've another theory, that in Android 10 you can deny an app access to a particular controller, and then it might also throw the Security Exception when you ask for the serial number, but again I'm just guessing because I don't have access to such a device. OK, based on USB documentation https://developer.android.com/guide/topics/connectivity/usb/host This suggests that if you try to enumerate USB devices before user grants permission then on Android-29/Q/Android 10 then you'll get a SecurityException. As getSerialNumber() now throws an exception where it didn't before, I think it needs to be added to the list of things not to try until permission is granted. Before Android 10 I think it's safe to call without permission. Again, all conjecture as I can't test. OK, found a person with a test device. The behaviour with the 2.0.12 code is for the app to crash with the SecurityException if an Android 10 device has a wired controller attached. You do NOT get the chance to see the 'Would you like this app to access your controller' dialog. With the attached patch it does not crash, you DO get the permission dialog and everything is fine after that. Patch added, thanks! https://hg.libsdl.org/SDL/rev/931ece03fbee |