OLD | NEW |
| (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 | |
OLD | NEW |