Skip to content

Commit

Permalink
fix(usb): manage exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelje authored and Hector Rondon committed Jan 18, 2018
1 parent 120d18b commit 92e5042
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions inventory/src/main/java/org/flyve/inventory/categories/Usb.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;

import org.flyve.inventory.FILog;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -64,7 +65,7 @@ public Usb(Context xCtx) {
super(xCtx);

//USB inventory comes with SDK level 12 !
if(Build.VERSION.SDK_INT > 12) {
try {

UsbManager manager = (UsbManager) xCtx.getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> devices = manager.getDeviceList();
Expand All @@ -80,12 +81,15 @@ public Usb(Context xCtx) {

this.add(c);
}
}
} catch (Exception ex) {
FILog.e(ex.getMessage());
}

}

/**
* Get the device's class field
* @param UsbDevice mydevice
* @param mydevice UsbDevice
* @return string the device's class
*/
public String getClass(UsbDevice mydevice) {
Expand All @@ -94,7 +98,7 @@ public String getClass(UsbDevice mydevice) {

/**
* Get the product ID
* @param UsbDevice mydevice
* @param mydevice UsbDevice
* @return string the product ID for the device
*/
public String getProductid(UsbDevice mydevice) {
Expand All @@ -103,7 +107,7 @@ public String getProductid(UsbDevice mydevice) {

/**
* Get the vendor ID
* @param UsbDevice mydevice
* @param mydevice UsbDevice
* @return string the vendor ID for the device
*/
public String getVendorid(UsbDevice mydevice) {
Expand All @@ -112,7 +116,7 @@ public String getVendorid(UsbDevice mydevice) {

/**
* Get the device's subclass field
* @param UsbDevice mydevice
* @param mydevice UsbDevice
* @return string the device's subclass
*/
public String getSubclass(UsbDevice mydevice) {
Expand Down

0 comments on commit 92e5042

Please sign in to comment.