| 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 bool UsbConfigurationAndroid::RegisterJNI(JNIEnv* env) { | |
| 16 return RegisterNativesImpl(env); // Generated in ChromeUsbConfiguration_jni.h | |
| 17 } | |
| 18 | |
| 19 // static | |
| 20 UsbConfigDescriptor UsbConfigurationAndroid::Convert( | 15 UsbConfigDescriptor UsbConfigurationAndroid::Convert( |
| 21 JNIEnv* env, | 16 JNIEnv* env, |
| 22 const base::android::JavaRef<jobject>& usb_configuration) { | 17 const base::android::JavaRef<jobject>& usb_configuration) { |
| 23 ScopedJavaLocalRef<jobject> wrapper = | 18 ScopedJavaLocalRef<jobject> wrapper = |
| 24 Java_ChromeUsbConfiguration_create(env, usb_configuration.obj()); | 19 Java_ChromeUsbConfiguration_create(env, usb_configuration.obj()); |
| 25 | 20 |
| 26 UsbConfigDescriptor config( | 21 UsbConfigDescriptor config( |
| 27 Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper.obj()), | 22 Java_ChromeUsbConfiguration_getConfigurationValue(env, wrapper.obj()), |
| 28 Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper.obj()), | 23 Java_ChromeUsbConfiguration_isSelfPowered(env, wrapper.obj()), |
| 29 Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper.obj()), | 24 Java_ChromeUsbConfiguration_isRemoteWakeup(env, wrapper.obj()), |
| 30 Java_ChromeUsbConfiguration_getMaxPower(env, wrapper.obj())); | 25 Java_ChromeUsbConfiguration_getMaxPower(env, wrapper.obj())); |
| 31 | 26 |
| 32 ScopedJavaLocalRef<jobjectArray> interfaces = | 27 ScopedJavaLocalRef<jobjectArray> interfaces = |
| 33 Java_ChromeUsbConfiguration_getInterfaces(env, wrapper.obj()); | 28 Java_ChromeUsbConfiguration_getInterfaces(env, wrapper.obj()); |
| 34 jsize count = env->GetArrayLength(interfaces.obj()); | 29 jsize count = env->GetArrayLength(interfaces.obj()); |
| 35 config.interfaces.reserve(count); | 30 config.interfaces.reserve(count); |
| 36 for (jsize i = 0; i < count; ++i) { | 31 for (jsize i = 0; i < count; ++i) { |
| 37 ScopedJavaLocalRef<jobject> interface( | 32 ScopedJavaLocalRef<jobject> interface( |
| 38 env, env->GetObjectArrayElement(interfaces.obj(), i)); | 33 env, env->GetObjectArrayElement(interfaces.obj(), i)); |
| 39 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); | 34 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); |
| 40 } | 35 } |
| 41 | 36 |
| 42 return config; | 37 return config; |
| 43 } | 38 } |
| 44 | 39 |
| 45 } // namespace device | 40 } // namespace device |
| OLD | NEW |