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

Unified Diff: device/usb/usb_endpoint_android.cc

Issue 1565313002: Reland of Implement basic USB device enumeration on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dependency fix added to reland. Created 4 years, 11 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 | « device/usb/usb_endpoint_android.h ('k') | device/usb/usb_interface_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_endpoint_android.cc
diff --git a/device/usb/usb_endpoint_android.cc b/device/usb/usb_endpoint_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3280b04f4046204a09375a2c1d57067a5a17f9cf
--- /dev/null
+++ b/device/usb/usb_endpoint_android.cc
@@ -0,0 +1,41 @@
+// 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.
+
+#include "device/usb/usb_endpoint_android.h"
+
+#include "jni/ChromeUsbEndpoint_jni.h"
+
+namespace device {
+
+// static
+bool UsbEndpointAndroid::RegisterJNI(JNIEnv* env) {
+ return RegisterNativesImpl(env); // Generated in ChromeUsbEndpoint_jni.h
+}
+
+// static
+UsbEndpointDescriptor UsbEndpointAndroid::Convert(
+ JNIEnv* env,
+ const base::android::JavaRef<jobject>& usb_endpoint) {
+ base::android::ScopedJavaLocalRef<jobject> wrapper =
+ Java_ChromeUsbEndpoint_create(env, usb_endpoint.obj());
+
+ UsbEndpointDescriptor endpoint;
+ endpoint.address = Java_ChromeUsbEndpoint_getAddress(env, wrapper.obj());
+ endpoint.direction = static_cast<UsbEndpointDirection>(
+ Java_ChromeUsbEndpoint_getDirection(env, wrapper.obj()));
+ endpoint.maximum_packet_size =
+ Java_ChromeUsbEndpoint_getMaxPacketSize(env, wrapper.obj());
+ jint attributes = Java_ChromeUsbEndpoint_getAttributes(env, wrapper.obj());
+ endpoint.synchronization_type =
+ static_cast<UsbSynchronizationType>((attributes >> 2) & 3);
+ endpoint.usage_type = static_cast<UsbUsageType>((attributes >> 4) & 3);
+ endpoint.transfer_type = static_cast<UsbTransferType>(
+ Java_ChromeUsbEndpoint_getType(env, wrapper.obj()));
+ endpoint.polling_interval =
+ Java_ChromeUsbEndpoint_getInterval(env, wrapper.obj());
+
+ return endpoint;
+}
+
+} // namespace device
« no previous file with comments | « device/usb/usb_endpoint_android.h ('k') | device/usb/usb_interface_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698