- Added exception handler for the new SecurityException in USBDevice getSerialNumber

This commit is contained in:
Sockmonsters 2020-05-29 15:37:03 -07:00
parent ae9ff11bae
commit eea450bc99
1 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,13 @@ class HIDDeviceUSB implements HIDDevice {
public String getSerialNumber() { public String getSerialNumber() {
String result = null; String result = null;
if (Build.VERSION.SDK_INT >= 21) { 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) { if (result == null) {
result = ""; result = "";