From 5643f464cc4b2724be539e02984572515e7c87be Mon Sep 17 00:00:00 2001 From: elasota Date: Wed, 22 Jun 2022 21:29:55 -0400 Subject: [PATCH] Discard security exception on getSerialNumber, fixes Android USB gamepad crash. --- .../app/src/main/java/org/libsdl/app/HIDDeviceUSB.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SDL2-2.0.12/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java b/SDL2-2.0.12/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java index 33816e3..d20fe80 100644 --- a/SDL2-2.0.12/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java +++ b/SDL2-2.0.12/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java @@ -53,7 +53,12 @@ class HIDDeviceUSB implements HIDDevice { public String getSerialNumber() { String result = null; if (Build.VERSION.SDK_INT >= 21) { - result = mDevice.getSerialNumber(); + try { + result = mDevice.getSerialNumber(); + } + catch (SecurityException exception) { + //Log.w(TAG, "App permissions mean we cannot get serial number for device " + getDeviceName() + " message: " + exception.getMessage()); + } } if (result == null) { result = "";