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_interface_android.h" | 5 #include "device/usb/usb_interface_android.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "device/usb/usb_endpoint_android.h" | 8 #include "device/usb/usb_endpoint_android.h" |
9 #include "jni/ChromeUsbInterface_jni.h" | 9 #include "jni/ChromeUsbInterface_jni.h" |
10 | 10 |
11 using base::android::ScopedJavaLocalRef; | 11 using base::android::ScopedJavaLocalRef; |
12 | 12 |
13 namespace device { | 13 namespace device { |
14 | 14 |
15 // static | 15 // static |
16 bool UsbInterfaceAndroid::RegisterJNI(JNIEnv* env) { | |
17 return RegisterNativesImpl(env); // Generated in ChromeUsbInterface_jni.h | |
18 } | |
19 | |
20 // static | |
21 UsbInterfaceDescriptor UsbInterfaceAndroid::Convert( | 16 UsbInterfaceDescriptor UsbInterfaceAndroid::Convert( |
22 JNIEnv* env, | 17 JNIEnv* env, |
23 const base::android::JavaRef<jobject>& usb_interface) { | 18 const base::android::JavaRef<jobject>& usb_interface) { |
24 ScopedJavaLocalRef<jobject> wrapper = | 19 ScopedJavaLocalRef<jobject> wrapper = |
25 Java_ChromeUsbInterface_create(env, usb_interface.obj()); | 20 Java_ChromeUsbInterface_create(env, usb_interface.obj()); |
26 | 21 |
27 uint8_t alternate_setting = 0; | 22 uint8_t alternate_setting = 0; |
28 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { | 23 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { |
29 alternate_setting = | 24 alternate_setting = |
30 Java_ChromeUsbInterface_getAlternateSetting(env, wrapper.obj()); | 25 Java_ChromeUsbInterface_getAlternateSetting(env, wrapper.obj()); |
(...skipping 13 matching lines...) Expand all Loading... |
44 for (jsize i = 0; i < count; ++i) { | 39 for (jsize i = 0; i < count; ++i) { |
45 ScopedJavaLocalRef<jobject> endpoint( | 40 ScopedJavaLocalRef<jobject> endpoint( |
46 env, env->GetObjectArrayElement(endpoints.obj(), i)); | 41 env, env->GetObjectArrayElement(endpoints.obj(), i)); |
47 interface.endpoints.push_back(UsbEndpointAndroid::Convert(env, endpoint)); | 42 interface.endpoints.push_back(UsbEndpointAndroid::Convert(env, endpoint)); |
48 } | 43 } |
49 | 44 |
50 return interface; | 45 return interface; |
51 } | 46 } |
52 | 47 |
53 } // namespace device | 48 } // namespace device |
OLD | NEW |