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

Unified Diff: device/usb/usb_configuration_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_configuration_android.h ('k') | device/usb/usb_descriptors.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_configuration_android.cc
diff --git a/device/usb/usb_configuration_android.cc b/device/usb/usb_configuration_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a9c7129d9747014d99d7e705f10806a69346e88
--- /dev/null
+++ b/device/usb/usb_configuration_android.cc
@@ -0,0 +1,49 @@
+// 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_configuration_android.h"
+
+#include "device/usb/usb_interface_android.h"
+#include "jni/ChromeUsbConfiguration_jni.h"
+
+using base::android::ScopedJavaLocalRef;
+
+namespace device {
+
+// static
+bool UsbConfigurationAndroid::RegisterJNI(JNIEnv* env) {
+ return RegisterNativesImpl(env); // Generated in ChromeUsbConfiguration_jni.h
+}
+
+// static
+UsbConfigDescriptor UsbConfigurationAndroid::Convert(
+ JNIEnv* env,
+ const base::android::JavaRef<jobject>& usb_configuration) {
+ ScopedJavaLocalRef<jobject> wrapper =
+ Java_ChromeUsbConfiguration_create(env, usb_configuration.obj());
+
+ UsbConfigDescriptor config;
+ config.configuration_value =
+ Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper.obj());
+ config.self_powered =
+ Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper.obj());
+ config.remote_wakeup =
+ Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper.obj());
+ config.maximum_power =
+ Java_ChromeUsbConfiguration_getMaxPower(env, wrapper.obj());
+
+ ScopedJavaLocalRef<jobjectArray> interfaces =
+ Java_ChromeUsbConfiguration_getInterfaces(env, wrapper.obj());
+ jsize count = env->GetArrayLength(interfaces.obj());
+ config.interfaces.reserve(count);
+ for (jsize i = 0; i < count; ++i) {
+ ScopedJavaLocalRef<jobject> interface(
+ env, env->GetObjectArrayElement(interfaces.obj(), i));
+ config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface));
+ }
+
+ return config;
+}
+
+} // namespace device
« no previous file with comments | « device/usb/usb_configuration_android.h ('k') | device/usb/usb_descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698