Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: media/base/android/java/src/org/chromium/media/UsbMidiDeviceAndroid.java

Issue 1098913003: [WebMIDI] [Android] Set appropriate port properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/midi/midi_manager_usb.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | media/midi/midi_manager_usb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698