OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/usb/usb_configuration_android.h" | 5 #include "device/usb/usb_configuration_android.h" |
6 | 6 |
7 #include "device/usb/usb_interface_android.h" | 7 #include "device/usb/usb_interface_android.h" |
8 #include "jni/ChromeUsbConfiguration_jni.h" | 8 #include "jni/ChromeUsbConfiguration_jni.h" |
9 | 9 |
10 using base::android::ScopedJavaLocalRef; | 10 using base::android::ScopedJavaLocalRef; |
11 | 11 |
12 namespace device { | 12 namespace device { |
13 | 13 |
14 // static | 14 // static |
15 UsbConfigDescriptor UsbConfigurationAndroid::Convert( | 15 UsbConfigDescriptor UsbConfigurationAndroid::Convert( |
16 JNIEnv* env, | 16 JNIEnv* env, |
17 const base::android::JavaRef<jobject>& usb_configuration) { | 17 const base::android::JavaRef<jobject>& usb_configuration) { |
18 ScopedJavaLocalRef<jobject> wrapper = | 18 ScopedJavaLocalRef<jobject> wrapper = |
19 Java_ChromeUsbConfiguration_create(env, usb_configuration.obj()); | 19 Java_ChromeUsbConfiguration_create(env, usb_configuration); |
20 | 20 |
21 UsbConfigDescriptor config( | 21 UsbConfigDescriptor config( |
22 Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper.obj()), | 22 Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper), |
23 Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper.obj()), | 23 Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper), |
24 Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper.obj()), | 24 Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper), |
25 Java_ChromeUsbConfiguration_getMaxPower(env, wrapper.obj())); | 25 Java_ChromeUsbConfiguration_getMaxPower(env, wrapper)); |
26 | 26 |
27 ScopedJavaLocalRef<jobjectArray> interfaces = | 27 ScopedJavaLocalRef<jobjectArray> interfaces = |
28 Java_ChromeUsbConfiguration_getInterfaces(env, wrapper.obj()); | 28 Java_ChromeUsbConfiguration_getInterfaces(env, wrapper); |
29 jsize count = env->GetArrayLength(interfaces.obj()); | 29 jsize count = env->GetArrayLength(interfaces.obj()); |
30 config.interfaces.reserve(count); | 30 config.interfaces.reserve(count); |
31 for (jsize i = 0; i < count; ++i) { | 31 for (jsize i = 0; i < count; ++i) { |
32 ScopedJavaLocalRef<jobject> interface( | 32 ScopedJavaLocalRef<jobject> interface( |
33 env, env->GetObjectArrayElement(interfaces.obj(), i)); | 33 env, env->GetObjectArrayElement(interfaces.obj(), i)); |
34 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); | 34 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); |
35 } | 35 } |
36 | 36 |
37 return config; | 37 return config; |
38 } | 38 } |
39 | 39 |
40 } // namespace device | 40 } // namespace device |
OLD | NEW |