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_endpoint_android.h" | |
6 | |
7 #include "jni/ChromeUsbEndpoint_jni.h" | |
8 | |
9 namespace device { | |
10 | |
11 // static | |
12 bool UsbEndpointAndroid::RegisterJNI(JNIEnv* env) { | |
13 return RegisterNativesImpl(env); // Generated in ChromeUsbEndpoint_jni.h | |
14 } | |
15 | |
16 // static | |
17 UsbEndpointDescriptor UsbEndpointAndroid::Convert( | |
18 JNIEnv* env, | |
19 const base::android::JavaRef<jobject>& usb_endpoint) { | |
20 base::android::ScopedJavaLocalRef<jobject> wrapper = | |
21 Java_ChromeUsbEndpoint_create(env, usb_endpoint.obj()); | |
22 | |
23 UsbEndpointDescriptor endpoint; | |
24 endpoint.address = Java_ChromeUsbEndpoint_getAddress(env, wrapper.obj()); | |
25 endpoint.direction = static_cast<UsbEndpointDirection>( | |
26 Java_ChromeUsbEndpoint_getDirection(env, wrapper.obj())); | |
27 endpoint.maximum_packet_size = | |
28 Java_ChromeUsbEndpoint_getMaxPacketSize(env, wrapper.obj()); | |
29 jint attributes = Java_ChromeUsbEndpoint_getAttributes(env, wrapper.obj()); | |
30 endpoint.synchronization_type = | |
31 static_cast<UsbSynchronizationType>((attributes >> 2) & 3); | |
32 endpoint.usage_type = static_cast<UsbUsageType>((attributes >> 4) & 3); | |
33 endpoint.transfer_type = static_cast<UsbTransferType>( | |
34 Java_ChromeUsbEndpoint_getType(env, wrapper.obj())); | |
35 endpoint.polling_interval = | |
36 Java_ChromeUsbEndpoint_getInterval(env, wrapper.obj()); | |
37 | |
38 return endpoint; | |
39 } | |
40 | |
41 } // namespace device | |
OLD | NEW |