Commit 2363ddc330efa939d2d43a6c809794970f401120

Sam Lantinga 2021-12-28T17:30:36

Fixed crash on Windows Subsystem for Android, which doesn't have a USB manager. Fixes https://github.com/libsdl-org/SDL/issues/5133

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java
index 5ebbb97..802c725 100644
--- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java
@@ -141,6 +141,9 @@ public class HIDDeviceManager {
 
     private void initializeUSB() {
         mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
+        if (mUsbManager == null) {
+            return;
+        }
 
         /*
         // Logging