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

Unified Diff: device/usb/android/java/src/org/chromium/device/usb/ChromeUsbInterface.java

Issue 1514603006: Implement basic USB device enumeration on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address qinmin's comments. Created 4 years, 12 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
Index: device/usb/android/java/src/org/chromium/device/usb/ChromeUsbInterface.java
diff --git a/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbInterface.java b/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbInterface.java
new file mode 100644
index 0000000000000000000000000000000000000000..cd4f49270edead7572e387577e17edf090c1dab9
--- /dev/null
+++ b/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbInterface.java
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.device.usb;
+
+import android.hardware.usb.UsbEndpoint;
+import android.hardware.usb.UsbInterface;
+
+import org.chromium.base.Log;
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+ * Exposes android.hardware.usb.UsbInterface as necessary for C++
+ * device::UsbInterfaceAndroid.
+ *
+ * Lifetime is controlled by device::UsbInterfaceAndroid.
+ */
+@JNINamespace("device")
+final class ChromeUsbInterface {
+ private static final String TAG = "Usb";
+
+ final UsbInterface mInterface;
+
+ private ChromeUsbInterface(UsbInterface iface) {
+ mInterface = iface;
+ Log.v(TAG, "ChromeUsbInterface created.");
+ }
+
+ @CalledByNative
+ private static ChromeUsbInterface create(UsbInterface iface) {
+ return new ChromeUsbInterface(iface);
+ }
+
+ @CalledByNative
+ private int getInterfaceNumber() {
+ return mInterface.getId();
+ }
+
+ @CalledByNative
+ private int getAlternateSetting() {
+ return mInterface.getAlternateSetting();
+ }
+
+ @CalledByNative
+ private int getInterfaceClass() {
+ return mInterface.getInterfaceClass();
+ }
+
+ @CalledByNative
+ private int getInterfaceSubclass() {
+ return mInterface.getInterfaceSubclass();
+ }
+
+ @CalledByNative
+ private int getInterfaceProtocol() {
+ return mInterface.getInterfaceProtocol();
+ }
+
+ @CalledByNative
+ private UsbEndpoint[] getEndpoints() {
+ int count = mInterface.getEndpointCount();
+ UsbEndpoint[] endpoints = new UsbEndpoint[count];
+ for (int i = 0; i < count; ++i) {
+ endpoints[i] = mInterface.getEndpoint(i);
+ }
+ return endpoints;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698