本文整理匯總了Java中android.hardware.usb.UsbDevice.getInterface方法的典型用法代碼示例。如果您正苦於以下問題:Java UsbDevice.getInterface方法的具體用法?Java UsbDevice.getInterface怎麽用?Java UsbDevice.getInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.usb.UsbDevice
的用法示例。
在下文中一共展示了UsbDevice.getInterface方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enumerate
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public static UsbHidDevice[] enumerate(Context context, int vid, int pid) throws Exception {
UsbManager usbManager = (UsbManager) context.getApplicationContext().getSystemService(Context.USB_SERVICE);
if (usbManager == null) {
throw new Exception("no usb service");
}
Map<String, UsbDevice> devices = usbManager.getDeviceList();
List<UsbHidDevice> usbHidDevices = new ArrayList<>();
for (UsbDevice device : devices.values()) {
if ((vid == 0 || device.getVendorId() == vid) && (pid == 0 || device.getProductId() == pid)) {
for (int i = 0; i < device.getInterfaceCount(); i++) {
UsbInterface usbInterface = device.getInterface(i);
if (usbInterface.getInterfaceClass() == INTERFACE_CLASS_HID) {
UsbHidDevice hidDevice = new UsbHidDevice(device, usbInterface, usbManager);
usbHidDevices.add(hidDevice);
}
}
}
}
return usbHidDevices.toArray(new UsbHidDevice[usbHidDevices.size()]);
}
示例2: open
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
/**
* open specific interface
* @param interfaceIndex
* @return
*/
public synchronized UsbInterface open(final int interfaceIndex) {
if (DEBUG) Log.i(TAG, "UsbControlBlock#open:" + interfaceIndex);
final UsbDevice device = mWeakDevice.get();
UsbInterface intf = null;
intf = mInterfaces.get(interfaceIndex);
if (intf == null) {
intf = device.getInterface(interfaceIndex);
if (intf != null) {
synchronized (mInterfaces) {
mInterfaces.append(interfaceIndex, intf);
}
}
}
return intf;
}
示例3: Af9035DvbDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
Af9035DvbDevice(UsbDevice usbDevice, Context context, DeviceFilter filter) throws DvbException {
super(usbDevice, context, filter, DvbDemux.DvbDmxSwfilter());
iface = usbDevice.getInterface(0);
controlEndpointIn = iface.getEndpoint(0);
controlEndpointOut = iface.getEndpoint(1);
endpoint = iface.getEndpoint(2);
// Endpoint 3 is a TS USB_DIR_IN endpoint with address 0x85
// but I don't know what it is used for
if (controlEndpointIn.getAddress() != 0x81 || controlEndpointIn.getDirection() != USB_DIR_IN)
throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
if (controlEndpointOut.getAddress() != 0x02 || controlEndpointOut.getDirection() != USB_DIR_OUT)
throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
if (endpoint.getAddress() != 0x84 || endpoint.getDirection() != USB_DIR_IN)
throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
}
示例4: readDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
/**
* Enumerate the endpoints and interfaces on the connected device.
*
* @param device Device to query.
* @return String description of the device configuration.
*/
public static String readDevice(UsbDevice device) {
StringBuilder sb = new StringBuilder();
sb.append("Device Name: " + device.getDeviceName() + "\n");
sb.append(String.format(
"Device Class: %s -> Subclass: 0x%02x -> Protocol: 0x%02x\n",
nameForClass(device.getDeviceClass()),
device.getDeviceSubclass(), device.getDeviceProtocol()));
for (int i = 0; i < device.getInterfaceCount(); i++) {
UsbInterface intf = device.getInterface(i);
sb.append(String.format(Locale.US,
"-- Interface %d Class: %s -> Subclass: 0x%02x -> Protocol: 0x%02x\n",
intf.getId(),
nameForClass(intf.getInterfaceClass()),
intf.getInterfaceSubclass(),
intf.getInterfaceProtocol()));
sb.append(String.format(Locale.US, " -- Endpoint Count: %d\n",
intf.getEndpointCount()));
}
return sb.toString();
}
示例5: isCdcDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public static boolean isCdcDevice(UsbDevice device)
{
int iIndex = device.getInterfaceCount();
for(int i=0;i<=iIndex-1;i++)
{
UsbInterface iface = device.getInterface(i);
if(iface.getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA)
return true;
}
return false;
}
示例6: setupUsb
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
protected void setupUsb(UsbDevice device) {
UsbInterface inf = device.getInterface(0);
UsbDeviceConnection conn = mUsbManager.openDevice(device);
if (conn == null) {
Log.wtf("MainActivity", "unable to open device?");
return;
}
if (!conn.claimInterface(inf, true)) {
conn.close();
Log.wtf("MainActivity", "unable to claim interface!");
return;
}
mBlinkDevice = device;
mBlinkConn = conn;
}
示例7: Rtl28xxDvbDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
Rtl28xxDvbDevice(UsbDevice usbDevice, Context context, DeviceFilter deviceFilter) throws DvbException {
super(usbDevice, context, deviceFilter, DvbDemux.DvbDmxSwfilter());
iface = usbDevice.getInterface(0);
endpoint = iface.getEndpoint(0);
if (endpoint.getAddress() != 0x81) throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
}
示例8: CxUsbDvbDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
CxUsbDvbDevice(UsbDevice usbDevice, Context context, DeviceFilter filter) throws DvbException {
super(usbDevice, context, filter, DvbDemux.DvbDmxSwfilter());
iface = usbDevice.getInterface(0);
controlEndpointIn = iface.getEndpoint(0);
controlEndpointOut = iface.getEndpoint(1);
endpoint = iface.getEndpoint(2);
if (controlEndpointIn.getAddress() != 0x81 || controlEndpointIn.getDirection() != USB_DIR_IN) throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
if (controlEndpointOut.getAddress() != 0x01 || controlEndpointOut.getDirection() != USB_DIR_OUT) throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
if (endpoint.getAddress() != 0x82 || endpoint.getDirection() != USB_DIR_IN) throw new DvbException(DVB_DEVICE_UNSUPPORTED, resources.getString(R.string.unexpected_usb_endpoint));
}
示例9: findUsbInterface
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
private UsbInterface findUsbInterface(UsbDevice device) {
//Log.d (TAG, "findAdbInterface " + device.getDeviceName());
int count = device.getInterfaceCount();
for (int i = 0; i < count; i++) {
UsbInterface intf = device.getInterface(i);
Log.d (TAG, "Interface " +i + " Class " +intf.getInterfaceClass() +" Prot " +intf.getInterfaceProtocol());
if (intf.getInterfaceClass() == 6
//255 && intf.getInterfaceSubclass() == 66 && intf.getInterfaceProtocol() == 1
) {
return intf;
}
}
return null;
}
示例10: findUsbInterface
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
protected UsbInterface findUsbInterface(UsbDevice device) {
//Log.d (TAG, "findAdbInterface " + device.getDeviceName());
int count = device.getInterfaceCount();
for (int i = 0; i < count; i++) {
UsbInterface intf = device.getInterface(i);
Log.d (TAG, "Interface " +i + " Class " +intf.getInterfaceClass() +" Prot " +intf.getInterfaceProtocol());
if (intf.getInterfaceClass() == 6
//255 && intf.getInterfaceSubclass() == 66 && intf.getInterfaceProtocol() == 1
) {
return intf;
}
}
return null;
}
示例11: findAdbInterface
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
static private UsbInterface findAdbInterface(UsbDevice device) {
Log.d(TAG, "findAdbInterface " + device);
int count = device.getInterfaceCount();
for (int i = 0; i < count; i++) {
UsbInterface intf = device.getInterface(i);
if (intf.getInterfaceClass() == 255 && intf.getInterfaceSubclass() == 66 &&
intf.getInterfaceProtocol() == 1) {
return intf;
}
}
return null;
}
示例12: CH34xSerialDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public CH34xSerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface)
{
super(device, connection);
rtsCtsEnabled = false;
dtrDsrEnabled = false;
mInterface = device.getInterface(iface >= 0 ? iface : 0);
}
示例13: CP2102SerialDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public CP2102SerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface)
{
super(device, connection);
rtsCtsEnabled = false;
dtrDsrEnabled = false;
ctsState = true;
dsrState = true;
mInterface = device.getInterface(iface >= 0 ? iface : 0);
}
示例14: PL2303SerialDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public PL2303SerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface)
{
super(device, connection);
if (iface > 1)
{
throw new IllegalArgumentException("Multi-interface PL2303 devices not supported!");
}
mInterface = device.getInterface(iface >= 0 ? iface : 0);
}
示例15: FTDISerialDevice
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public FTDISerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface)
{
super(device, connection);
ftdiUtilities = new FTDIUtilities();
rtsCtsEnabled = false;
dtrDsrEnabled = false;
ctsState = true;
dsrState = true;
firstTime = true;
mInterface = device.getInterface(iface >= 0 ? iface : 0);
}