本文整理汇总了Java中android.hardware.usb.UsbConstants.USB_CLASS_AUDIO属性的典型用法代码示例。如果您正苦于以下问题:Java UsbConstants.USB_CLASS_AUDIO属性的具体用法?Java UsbConstants.USB_CLASS_AUDIO怎么用?Java UsbConstants.USB_CLASS_AUDIO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.usb.UsbConstants
的用法示例。
在下文中一共展示了UsbConstants.USB_CLASS_AUDIO属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestDevicePermissionIfNecessary
/**
* Request a device access permission if there is a MIDI interface in the device.
*
* @param device a USB device
*/
private void requestDevicePermissionIfNecessary(UsbDevice device) {
for (UsbDevice d : mRequestedDevices) {
if (d.getDeviceId() == device.getDeviceId()) {
// It is already requested.
return;
}
}
for (int i = 0; i < device.getInterfaceCount(); ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_AUDIO
&& iface.getInterfaceSubclass() == UsbMidiDeviceAndroid.MIDI_SUBCLASS) {
// There is at least one interface supporting MIDI.
mUsbManager.requestPermission(device,
PendingIntent.getBroadcast(ContextUtils.getApplicationContext(), 0,
new Intent(ACTION_USB_PERMISSION), 0));
mRequestedDevices.add(device);
break;
}
}
}
示例2: UsbMidiDeviceAndroid
/**
* Constructs a UsbMidiDeviceAndroid.
* @param manager
* @param device The USB device which this object is assocated with.
*/
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
mConnection = manager.openDevice(device);
mEndpointMap = new HashMap<Integer, UsbEndpoint>();
mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
for (int i = 0; i < device.getInterfaceCount(); ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO ||
iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
continue;
}
mConnection.claimInterface(iface, true);
for (int j = 0; j < iface.getEndpointCount(); ++j) {
UsbEndpoint endpoint = iface.getEndpoint(j);
if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
}
}
}
}
示例3: nameForClass
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 "";
}
}
示例4: nameForClass
public static String nameForClass(int classType) {
switch (classType) {
case UsbConstants.USB_CLASS_APP_SPEC:
return String.format("Application Specific 0x%02x", 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_PER_INTERFACE:
return "(Defined Per Interface)";
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 String.format("0x%02x", classType);
}
}
示例5: UsbMidiDeviceAndroid
/**
* Constructs a UsbMidiDeviceAndroid.
* @param manager
* @param device The USB device which this object is assocated with.
*/
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
mConnection = manager.openDevice(device);
mEndpointMap = new SparseArray<UsbEndpoint>();
mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
mHandler = new Handler();
mUsbDevice = device;
mIsClosed = false;
mHasInputThread = false;
mNativePointer = 0;
for (int i = 0; i < device.getInterfaceCount(); ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO
|| iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
continue;
}
mConnection.claimInterface(iface, true);
for (int j = 0; j < iface.getEndpointCount(); ++j) {
UsbEndpoint endpoint = iface.getEndpoint(j);
if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
}
}
}
// Start listening for input endpoints.
// This function will create and run a thread if there is USB-MIDI endpoints in the
// device. Note that because UsbMidiDevice is shared among all tabs and the thread
// will be terminated when the device is disconnected, at most one thread can be created
// for each connected USB-MIDI device.
startListen(device);
}
示例6: getClassName
private String getClassName(int deviceClass) {
switch (deviceClass) {
case UsbConstants.USB_CLASS_AUDIO:
return this.getString(R.string.class_audio);
case UsbConstants.USB_CLASS_CDC_DATA:
return this.getString(R.string.class_cdc_data);
case UsbConstants.USB_CLASS_COMM:
return this.getString(R.string.class_comm);
case UsbConstants.USB_CLASS_CONTENT_SEC:
return this.getString(R.string.class_content_sec);
case UsbConstants.USB_CLASS_HID:
return this.getString(R.string.class_hid);
case UsbConstants.USB_CLASS_HUB:
return this.getString(R.string.class_hub);
case UsbConstants.USB_CLASS_MASS_STORAGE:
return this.getString(R.string.class_mass_storage);
case UsbConstants.USB_CLASS_MISC:
return this.getString(R.string.class_misc);
case UsbConstants.USB_CLASS_PHYSICA:
return this.getString(R.string.class_physica);
case UsbConstants.USB_CLASS_PRINTER:
return this.getString(R.string.class_printer);
case UsbConstants.USB_CLASS_STILL_IMAGE:
return this.getString(R.string.class_still_image);
case UsbConstants.USB_CLASS_VIDEO:
return this.getString(R.string.class_video);
case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
return this.getString(R.string.class_wireless_controller);
default:
return this.getString(R.string.class_unknown);
}
}
示例7: enumerateDevices
/**
* Enumerates USB-MIDI devices.
* If there are devices having USB-MIDI interfaces, this function requests permission for
* accessing the device to the user.
* When the permission request is accepted or rejected onRequestDone will be called.
*
* If there are no USB-MIDI interfaces, this function returns false.
* @return true if some permission requests are in progress.
*/
@CalledByNative
boolean enumerateDevices(Context context) {
mUsbManager = (UsbManager)context.getSystemService(Context.USB_SERVICE);
Map<String, UsbDevice> devices = mUsbManager.getDeviceList();
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context, 0, new Intent(ACTION_USB_PERMISSION), 0);
mRequestedDevices = new HashSet<UsbDevice>();
for (UsbDevice device : devices.values()) {
boolean found = false;
for (int i = 0; i < device.getInterfaceCount() && !found; ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_AUDIO &&
iface.getInterfaceSubclass() == UsbMidiDeviceAndroid.MIDI_SUBCLASS) {
found = true;
}
}
if (found) {
mUsbManager.requestPermission(device, pendingIntent);
mRequestedDevices.add(device);
}
}
if (mRequestedDevices.isEmpty()) {
// No USB-MIDI devices are found.
return false;
}
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (ACTION_USB_PERMISSION.equals(intent.getAction())) {
onRequestDone(context, intent);
}
}
};
context.registerReceiver(mReceiver, filter);
return true;
}