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

Side by Side Diff: device/usb/usb_configuration_android.cc

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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/usb/usb_configuration_android.h"
6
7 #include "device/usb/usb_interface_android.h"
8 #include "jni/ChromeUsbConfiguration_jni.h"
9
10 using base::android::ScopedJavaLocalRef;
11
12 namespace device {
13
14 // static
15 bool UsbConfigurationAndroid::RegisterJNI(JNIEnv* env) {
16 return RegisterNativesImpl(env); // Generated in ChromeUsbConfiguration_jni.h
17 }
18
19 // static
20 UsbConfigDescriptor UsbConfigurationAndroid::Convert(
21 JNIEnv* env,
22 const base::android::JavaRef<jobject>& usb_configuration) {
23 ScopedJavaLocalRef<jobject> wrapper =
24 Java_ChromeUsbConfiguration_create(env, usb_configuration.obj());
25
26 UsbConfigDescriptor config;
27 config.configuration_value =
28 Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper.obj());
29 config.self_powered =
30 Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper.obj());
31 config.remote_wakeup =
32 Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper.obj());
33 config.maximum_power =
34 Java_ChromeUsbConfiguration_getMaxPower(env, wrapper.obj());
35
36 ScopedJavaLocalRef<jobjectArray> interfaces =
37 Java_ChromeUsbConfiguration_getInterfaces(env, wrapper.obj());
38 jsize count = env->GetArrayLength(interfaces.obj());
39 config.interfaces.reserve(count);
40 for (jsize i = 0; i < count; ++i) {
41 ScopedJavaLocalRef<jobject> interface(
42 env, env->GetObjectArrayElement(interfaces.obj(), i));
43 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface));
44 }
45
46 return config;
47 }
48
49 } // namespace device
OLDNEW
« 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