Check for a null UsbManager object

Apparently this can happen on some (broken?) devices
This commit is contained in:
Cameron Gutman
2023-10-12 00:22:28 -05:00
parent 0168a55596
commit 9915007f30
2 changed files with 10 additions and 8 deletions

View File

@@ -365,6 +365,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
// Count all USB devices that match our drivers
if (PreferenceConfiguration.readPreferences(context).usbDriver) {
UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
if (usbManager != null) {
for (UsbDevice dev : usbManager.getDeviceList().values()) {
// We explicitly check not to claim devices that appear as InputDevices
// otherwise we will double count them.
@@ -375,6 +376,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
}
}
}
}
if (PreferenceConfiguration.readPreferences(context).onscreenController) {
LimeLog.info("Counting OSC gamepad");

View File

@@ -287,7 +287,7 @@ public class UsbDriverService extends Service implements UsbDriverListener {
}
private void start() {
if (started) {
if (started || usbManager == null) {
return;
}