本文整理匯總了Java中android.hardware.usb.UsbDevice.getDeviceClass方法的典型用法代碼示例。如果您正苦於以下問題:Java UsbDevice.getDeviceClass方法的具體用法?Java UsbDevice.getDeviceClass怎麽用?Java UsbDevice.getDeviceClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.usb.UsbDevice
的用法示例。
在下文中一共展示了UsbDevice.getDeviceClass方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nameForClass
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
private static String nameForClass(UsbDevice usbDevice) {
int classType = usbDevice.getDeviceClass();
switch (classType) {
case UsbConstants.USB_CLASS_AUDIO:
return "Audio";
case UsbConstants.USB_CLASS_CDC_DATA:
return "CDC Control";
case UsbConstants.USB_CLASS_COMM:
return "Communications";
case UsbConstants.USB_CLASS_CONTENT_SEC:
return "Content Security";
case UsbConstants.USB_CLASS_CSCID:
return "Content Smart Card";
case UsbConstants.USB_CLASS_HID:
return "Human Interface Device";
case UsbConstants.USB_CLASS_HUB:
return "Hub";
case UsbConstants.USB_CLASS_MASS_STORAGE:
return "Mass Storage";
case UsbConstants.USB_CLASS_MISC:
return "Wireless Miscellaneous";
case UsbConstants.USB_CLASS_PHYSICA:
return "Physical";
case UsbConstants.USB_CLASS_PRINTER:
return "Printer";
case UsbConstants.USB_CLASS_STILL_IMAGE:
return "Still Image";
case UsbConstants.USB_CLASS_VENDOR_SPEC:
return String.format("Vendor Specific 0x%02x", classType);
case UsbConstants.USB_CLASS_VIDEO:
return "Video";
case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
return "Wireless Controller";
default:
return "";
}
}
示例2: isCardReader
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
/** Indica si el dispositivo es un lector de tarjetas.
* @return <code>true</code> si es un dispositivo CCID, <code>false</code> en caso contrario */
private static boolean isCardReader(final UsbDevice device) {
if (device == null) {
return false;
}
// SmartCard Device Class: http://www.usb.org/developers/defined_class/#BaseClass00h
// SmartCard Interface Class: http://www.usb.org/developers/defined_class/#BaseClass0Bh
if(device.getDeviceClass() == 0x00 && device.getInterface(0).getInterfaceClass() == 0x0B) {
return true;
}
return false;
}
示例3: refreshDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
private final void refreshDevice() {
if (mUsbMonitor == null) {
return;
}
camList = null;
List<UsbDevice> allDev = mUsbMonitor.getDeviceList();
if (allDev.size() <= 0) {
return;
}
for (UsbDevice d : allDev) {
boolean isVideoDev = false;
if (d.getInterfaceCount() <= 0) {
if (d.getDeviceClass() == 239 && d.getDeviceSubclass() == 2) {
isVideoDev = true;
}
} else {
for (int i = 0; i < d.getInterfaceCount(); i++) {
UsbInterface in = d.getInterface(0);
if (in == null) {
continue;
}
if (in.getInterfaceClass() == 14) {
isVideoDev = true;
break;
}
}
}
if (isVideoDev) {
if (camList == null) {
camList = new ArrayList<UsbDevice>();
}
camList.add(d);
}
}
if (camList == null) {
System.out.println("v4l no device");
} else {
Collections.sort(camList, new Comparator<UsbDevice>(){
@Override
public int compare(UsbDevice left, UsbDevice right) {
return (left.getDeviceName().compareTo(right.getDeviceName()));
}
});
}
}