From eea450bc99925195beb649310d22a9d22dcc6a3f Mon Sep 17 00:00:00 2001 From: Sockmonsters Date: Fri, 29 May 2020 15:37:03 -0700 Subject: [PATCH] - Added exception handler for the new SecurityException in USBDevice getSerialNumber --- .../app/src/main/java/org/libsdl/app/HIDDeviceUSB.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java index 33816e344..efcb7b195 100644 --- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java +++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java @@ -53,7 +53,13 @@ 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()); + result = ""; + } } if (result == null) { result = "";