فهرست منبع

- Added exception handler for the new SecurityException in USBDevice getSerialNumber

Sockmonsters 5 سال پیش
والد
کامیت
eea450bc99
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java

+ 7 - 1
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 = "";