Chromium Code Reviews| Index: device/usb/android/java/src/org/chromium/device/usb/ChromeUsbEndpoint.java |
| diff --git a/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbEndpoint.java b/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbEndpoint.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2359321fdb84a950b92698580a272c70fabdf761 |
| --- /dev/null |
| +++ b/device/usb/android/java/src/org/chromium/device/usb/ChromeUsbEndpoint.java |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.device.usb; |
| + |
| +import android.hardware.usb.UsbConstants; |
| +import android.hardware.usb.UsbEndpoint; |
| + |
| +import org.chromium.base.Log; |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| + |
| +/** |
| + * Exposes android.hardware.usb.UsbEndpoint as necessary for C++ |
| + * device::UsbEndpointAndroid. |
| + * |
| + * Lifetime is controlled by device::UsbEndpointAndroid. |
| + */ |
| +@JNINamespace("device") |
| +final class ChromeUsbEndpoint { |
| + private static final String TAG = "Usb"; |
| + |
| + final UsbEndpoint mEndpoint; |
| + |
| + private ChromeUsbEndpoint(UsbEndpoint endpoint) { |
| + mEndpoint = endpoint; |
| + Log.v(TAG, "ChromeUsbEndpoint created."); |
| + } |
| + |
| + @CalledByNative |
| + private static ChromeUsbEndpoint create(UsbEndpoint endpoint) { |
| + return new ChromeUsbEndpoint(endpoint); |
| + } |
| + |
| + @CalledByNative |
| + private int getAddress() { |
| + return mEndpoint.getAddress(); |
| + } |
| + |
| + @CalledByNative |
| + private int getDirection() { |
| + switch (mEndpoint.getDirection()) { |
| + case UsbConstants.USB_DIR_IN: |
| + return UsbEndpointDirection.USB_DIRECTION_INBOUND; |
| + case UsbConstants.USB_DIR_OUT: |
| + return UsbEndpointDirection.USB_DIRECTION_OUTBOUND; |
| + } |
| + throw new AssertionError(); |
|
qinmin
2016/01/04 19:20:26
you can move this to the switch statement's defaul
Reilly Grant (use Gerrit)
2016/01/05 01:35:29
Done.
|
| + } |
| + |
| + @CalledByNative |
| + private int getMaxPacketSize() { |
| + return mEndpoint.getMaxPacketSize(); |
| + } |
| + |
| + @CalledByNative |
| + private int getAttributes() { |
| + return mEndpoint.getAttributes(); |
| + } |
| + |
| + @CalledByNative |
| + private int getType() { |
| + switch (mEndpoint.getType()) { |
| + case UsbConstants.USB_ENDPOINT_XFER_CONTROL: |
| + return UsbTransferType.USB_TRANSFER_CONTROL; |
| + case UsbConstants.USB_ENDPOINT_XFER_ISOC: |
| + return UsbTransferType.USB_TRANSFER_ISOCHRONOUS; |
| + case UsbConstants.USB_ENDPOINT_XFER_BULK: |
| + return UsbTransferType.USB_TRANSFER_BULK; |
| + case UsbConstants.USB_ENDPOINT_XFER_INT: |
| + return UsbTransferType.USB_TRANSFER_INTERRUPT; |
| + } |
| + throw new AssertionError(); |
|
qinmin
2016/01/04 19:20:26
ditto
Reilly Grant (use Gerrit)
2016/01/05 01:35:29
Done.
|
| + } |
| + |
| + @CalledByNative |
| + private int getInterval() { |
| + return mEndpoint.getInterval(); |
| + } |
| +} |