| Index: media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java
|
| diff --git a/media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java b/media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java
|
| index 2f80b961da1b3daa56c7165243a1e55792b060e5..c581131fb39a646638985472e7d69ad7b8dc9c57 100644
|
| --- a/media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java
|
| +++ b/media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java
|
| @@ -20,6 +20,7 @@ import org.chromium.base.CalledByNative;
|
| import org.chromium.base.JNINamespace;
|
|
|
| import java.nio.ByteBuffer;
|
| +import java.util.Arrays;
|
| import java.util.HashMap;
|
| import java.util.Map;
|
|
|
| @@ -75,6 +76,16 @@ class UsbMidiDeviceAndroid {
|
| static final int MIDI_SUBCLASS = 3;
|
|
|
| /**
|
| + * The request type to request a USB descriptor.
|
| + */
|
| + static final int REQUEST_GET_DESCRIPTOR = 0x06;
|
| +
|
| + /**
|
| + * The STRING descriptor type.
|
| + */
|
| + static final int STRING_DESCRIPTOR_TYPE = 0x03;
|
| +
|
| + /**
|
| * Constructs a UsbMidiDeviceAndroid.
|
| * @param manager
|
| * @param device The USB device which this object is assocated with.
|
| @@ -258,6 +269,27 @@ class UsbMidiDeviceAndroid {
|
| }
|
|
|
| /**
|
| + * Returns the string descriptor bytes for the given index
|
| + * @param index index of the descriptor
|
| + * @return the string descriptor bytes for the given index.
|
| + */
|
| + @CalledByNative
|
| + byte[] getStringDescriptor(int index) {
|
| + if (mConnection == null) {
|
| + return new byte[0];
|
| + }
|
| + byte[] buffer = new byte[255];
|
| + int type = UsbConstants.USB_DIR_IN | UsbConstants.USB_TYPE_STANDARD;
|
| + int request = REQUEST_GET_DESCRIPTOR;
|
| + int value = (STRING_DESCRIPTOR_TYPE << 8) | index;
|
| + int read = mConnection.controlTransfer(type, request, value, 0, buffer, buffer.length, 0);
|
| + if (read < 0) {
|
| + return new byte[0];
|
| + }
|
| + return Arrays.copyOf(buffer, read);
|
| + }
|
| +
|
| + /**
|
| * Closes the device connection.
|
| */
|
| @CalledByNative
|
|
|