use of android.hardware.usb.UsbInterface in project android_frameworks_base by ResurrectionRemix.
the class UsbAlsaManager method usbDeviceAdded.
/* package */
void usbDeviceAdded(UsbDevice usbDevice) {
if (DEBUG) {
Slog.d(TAG, "deviceAdded(): " + usbDevice.getManufacturerName() + " nm:" + usbDevice.getProductName());
}
// Is there an audio interface in there?
boolean isAudioDevice = false;
// FIXME - handle multiple configurations?
int interfaceCount = usbDevice.getInterfaceCount();
for (int ntrfaceIndex = 0; !isAudioDevice && ntrfaceIndex < interfaceCount; ntrfaceIndex++) {
UsbInterface ntrface = usbDevice.getInterface(ntrfaceIndex);
if (ntrface.getInterfaceClass() == UsbConstants.USB_CLASS_AUDIO) {
isAudioDevice = true;
}
}
if (DEBUG) {
Slog.d(TAG, " isAudioDevice: " + isAudioDevice);
}
if (!isAudioDevice) {
return;
}
int addedCard = mCardsParser.getDefaultUsbCard();
// handle the selection.
if (DEBUG) {
Slog.d(TAG, " mCardsParser.isCardUsb(" + addedCard + ") = " + mCardsParser.isCardUsb(addedCard));
}
if (mCardsParser.isCardUsb(addedCard)) {
UsbAudioDevice audioDevice = selectAudioCard(addedCard);
if (audioDevice != null) {
mAudioDevices.put(usbDevice, audioDevice);
Slog.i(TAG, "USB Audio Device Added: " + audioDevice);
}
// look for MIDI devices
// Don't need to call mDevicesParser.scan() because selectAudioCard() does this above.
// Uncomment this next line if that behavior changes in the fugure.
// mDevicesParser.scan()
boolean hasMidi = mDevicesParser.hasMIDIDevices(addedCard);
if (hasMidi && mHasMidiFeature) {
int device = mDevicesParser.getDefaultDeviceNum(addedCard);
AlsaDevice alsaDevice = waitForAlsaDevice(addedCard, device, AlsaDevice.TYPE_MIDI);
if (alsaDevice != null) {
Bundle properties = new Bundle();
String manufacturer = usbDevice.getManufacturerName();
String product = usbDevice.getProductName();
String version = usbDevice.getVersion();
String name;
if (manufacturer == null || manufacturer.isEmpty()) {
name = product;
} else if (product == null || product.isEmpty()) {
name = manufacturer;
} else {
name = manufacturer + " " + product;
}
properties.putString(MidiDeviceInfo.PROPERTY_NAME, name);
properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, manufacturer);
properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, product);
properties.putString(MidiDeviceInfo.PROPERTY_VERSION, version);
properties.putString(MidiDeviceInfo.PROPERTY_SERIAL_NUMBER, usbDevice.getSerialNumber());
properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, alsaDevice.mCard);
properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_DEVICE, alsaDevice.mDevice);
properties.putParcelable(MidiDeviceInfo.PROPERTY_USB_DEVICE, usbDevice);
UsbMidiDevice usbMidiDevice = UsbMidiDevice.create(mContext, properties, alsaDevice.mCard, alsaDevice.mDevice);
if (usbMidiDevice != null) {
mMidiDevices.put(usbDevice, usbMidiDevice);
}
}
}
}
if (DEBUG) {
Slog.d(TAG, "deviceAdded() - done");
}
}
use of android.hardware.usb.UsbInterface in project android_frameworks_base by ResurrectionRemix.
the class UsbHostManager method addUsbConfiguration.
/* Called from JNI in monitorUsbHostBus() to report new USB configuration for the device
currently being added. Returns true if successful, false in case of error.
*/
private void addUsbConfiguration(int id, String name, int attributes, int maxPower) {
if (mNewConfiguration != null) {
mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
mNewInterfaces.clear();
}
mNewConfiguration = new UsbConfiguration(id, name, attributes, maxPower);
mNewConfigurations.add(mNewConfiguration);
}
use of android.hardware.usb.UsbInterface in project android_frameworks_base by crdroidandroid.
the class UsbHostManager method addUsbInterface.
/* Called from JNI in monitorUsbHostBus() to report new USB interface for the device
currently being added. Returns true if successful, false in case of error.
*/
private void addUsbInterface(int id, String name, int altSetting, int Class, int subClass, int protocol) {
if (mNewInterface != null) {
mNewInterface.setEndpoints(mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()]));
mNewEndpoints.clear();
}
mNewInterface = new UsbInterface(id, altSetting, name, Class, subClass, protocol);
mNewInterfaces.add(mNewInterface);
}
use of android.hardware.usb.UsbInterface in project android_frameworks_base by crdroidandroid.
the class UsbAlsaManager method usbDeviceAdded.
/* package */
void usbDeviceAdded(UsbDevice usbDevice) {
if (DEBUG) {
Slog.d(TAG, "deviceAdded(): " + usbDevice.getManufacturerName() + " nm:" + usbDevice.getProductName());
}
// Is there an audio interface in there?
boolean isAudioDevice = false;
// FIXME - handle multiple configurations?
int interfaceCount = usbDevice.getInterfaceCount();
for (int ntrfaceIndex = 0; !isAudioDevice && ntrfaceIndex < interfaceCount; ntrfaceIndex++) {
UsbInterface ntrface = usbDevice.getInterface(ntrfaceIndex);
if (ntrface.getInterfaceClass() == UsbConstants.USB_CLASS_AUDIO) {
isAudioDevice = true;
}
}
if (DEBUG) {
Slog.d(TAG, " isAudioDevice: " + isAudioDevice);
}
if (!isAudioDevice) {
return;
}
int addedCard = mCardsParser.getDefaultUsbCard();
// handle the selection.
if (DEBUG) {
Slog.d(TAG, " mCardsParser.isCardUsb(" + addedCard + ") = " + mCardsParser.isCardUsb(addedCard));
}
if (mCardsParser.isCardUsb(addedCard)) {
UsbAudioDevice audioDevice = selectAudioCard(addedCard);
if (audioDevice != null) {
mAudioDevices.put(usbDevice, audioDevice);
Slog.i(TAG, "USB Audio Device Added: " + audioDevice);
}
// look for MIDI devices
// Don't need to call mDevicesParser.scan() because selectAudioCard() does this above.
// Uncomment this next line if that behavior changes in the fugure.
// mDevicesParser.scan()
boolean hasMidi = mDevicesParser.hasMIDIDevices(addedCard);
if (hasMidi && mHasMidiFeature) {
int device = mDevicesParser.getDefaultDeviceNum(addedCard);
AlsaDevice alsaDevice = waitForAlsaDevice(addedCard, device, AlsaDevice.TYPE_MIDI);
if (alsaDevice != null) {
Bundle properties = new Bundle();
String manufacturer = usbDevice.getManufacturerName();
String product = usbDevice.getProductName();
String version = usbDevice.getVersion();
String name;
if (manufacturer == null || manufacturer.isEmpty()) {
name = product;
} else if (product == null || product.isEmpty()) {
name = manufacturer;
} else {
name = manufacturer + " " + product;
}
properties.putString(MidiDeviceInfo.PROPERTY_NAME, name);
properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, manufacturer);
properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, product);
properties.putString(MidiDeviceInfo.PROPERTY_VERSION, version);
properties.putString(MidiDeviceInfo.PROPERTY_SERIAL_NUMBER, usbDevice.getSerialNumber());
properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, alsaDevice.mCard);
properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_DEVICE, alsaDevice.mDevice);
properties.putParcelable(MidiDeviceInfo.PROPERTY_USB_DEVICE, usbDevice);
UsbMidiDevice usbMidiDevice = UsbMidiDevice.create(mContext, properties, alsaDevice.mCard, alsaDevice.mDevice);
if (usbMidiDevice != null) {
mMidiDevices.put(usbDevice, usbMidiDevice);
}
}
}
}
if (DEBUG) {
Slog.d(TAG, "deviceAdded() - done");
}
}
use of android.hardware.usb.UsbInterface in project android_frameworks_base by crdroidandroid.
the class UsbHostManager method addUsbConfiguration.
/* Called from JNI in monitorUsbHostBus() to report new USB configuration for the device
currently being added. Returns true if successful, false in case of error.
*/
private void addUsbConfiguration(int id, String name, int attributes, int maxPower) {
if (mNewConfiguration != null) {
mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
mNewInterfaces.clear();
}
mNewConfiguration = new UsbConfiguration(id, name, attributes, maxPower);
mNewConfigurations.add(mNewConfiguration);
}
Aggregations