Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e783d990 authored by Jeff Brown's avatar Jeff Brown
Browse files

Undeprecate old UsbDeviceConnection methods.

Per api review, retain the overloads that do not accept a
buffer start offset.

Bug: 8656781
Change-Id: Ie00aca7d3a4708700c5ddf60e3309e609788a67f
parent 8b60e451
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -10589,11 +10589,11 @@ package android.hardware.usb {
  }
  }
  public class UsbDeviceConnection {
  public class UsbDeviceConnection {
    method public deprecated int bulkTransfer(android.hardware.usb.UsbEndpoint, byte[], int, int);
    method public int bulkTransfer(android.hardware.usb.UsbEndpoint, byte[], int, int);
    method public int bulkTransfer(android.hardware.usb.UsbEndpoint, byte[], int, int, int);
    method public int bulkTransfer(android.hardware.usb.UsbEndpoint, byte[], int, int, int);
    method public boolean claimInterface(android.hardware.usb.UsbInterface, boolean);
    method public boolean claimInterface(android.hardware.usb.UsbInterface, boolean);
    method public void close();
    method public void close();
    method public deprecated int controlTransfer(int, int, int, int, byte[], int, int);
    method public int controlTransfer(int, int, int, int, byte[], int, int);
    method public int controlTransfer(int, int, int, int, byte[], int, int, int);
    method public int controlTransfer(int, int, int, int, byte[], int, int, int);
    method public int getFileDescriptor();
    method public int getFileDescriptor();
    method public byte[] getRawDescriptors();
    method public byte[] getRawDescriptors();
+22 −20
Original line number Original line Diff line number Diff line
@@ -107,6 +107,11 @@ public class UsbDeviceConnection {
     * {@link UsbConstants#USB_DIR_OUT}, then the transfer is a write,
     * {@link UsbConstants#USB_DIR_OUT}, then the transfer is a write,
     * and if it is {@link UsbConstants#USB_DIR_IN}, then the transfer
     * and if it is {@link UsbConstants#USB_DIR_IN}, then the transfer
     * is a read.
     * is a read.
     * <p>
     * This method transfers data starting from index 0 in the buffer.
     * To specify a different offset, use
     * {@link #controlTransfer(int, int, int, int, byte[], int, int, int)}.
     * </p>
     *
     *
     * @param requestType request type for this transaction
     * @param requestType request type for this transaction
     * @param request request ID for this transaction
     * @param request request ID for this transaction
@@ -118,11 +123,7 @@ public class UsbDeviceConnection {
     * @param timeout in milliseconds
     * @param timeout in milliseconds
     * @return length of data transferred (or zero) for success,
     * @return length of data transferred (or zero) for success,
     * or negative value for failure
     * or negative value for failure
     *
     * @deprecated Use {@link #controlTransfer(int, int, int, int, byte[], int, int, int)}
     * which accepts a buffer start index.
     */
     */
    @Deprecated
    public int controlTransfer(int requestType, int request, int value,
    public int controlTransfer(int requestType, int request, int value,
            int index, byte[] buffer, int length, int timeout) {
            int index, byte[] buffer, int length, int timeout) {
        return controlTransfer(requestType, request, value, index, buffer, 0, length, timeout);
        return controlTransfer(requestType, request, value, index, buffer, 0, length, timeout);
@@ -142,22 +143,27 @@ public class UsbDeviceConnection {
     * @param index index field for this transaction
     * @param index index field for this transaction
     * @param buffer buffer for data portion of transaction,
     * @param buffer buffer for data portion of transaction,
     * or null if no data needs to be sent or received
     * or null if no data needs to be sent or received
     * @param start the index of the first byte in the buffer to send or receive
     * @param offset the index of the first byte in the buffer to send or receive
     * @param length the length of the data to send or receive
     * @param length the length of the data to send or receive
     * @param timeout in milliseconds
     * @param timeout in milliseconds
     * @return length of data transferred (or zero) for success,
     * @return length of data transferred (or zero) for success,
     * or negative value for failure
     * or negative value for failure
     */
     */
    public int controlTransfer(int requestType, int request, int value, int index,
    public int controlTransfer(int requestType, int request, int value, int index,
            byte[] buffer, int start, int length, int timeout) {
            byte[] buffer, int offset, int length, int timeout) {
        checkBounds(buffer, start, length);
        checkBounds(buffer, offset, length);
        return native_control_request(requestType, request, value, index,
        return native_control_request(requestType, request, value, index,
                buffer, start, length, timeout);
                buffer, offset, length, timeout);
    }
    }


    /**
    /**
     * Performs a bulk transaction on the given endpoint.
     * Performs a bulk transaction on the given endpoint.
     * The direction of the transfer is determined by the direction of the endpoint
     * The direction of the transfer is determined by the direction of the endpoint.
     * <p>
     * This method transfers data starting from index 0 in the buffer.
     * To specify a different offset, use
     * {@link #bulkTransfer(UsbEndpoint, byte[], int, int, int)}.
     * </p>
     *
     *
     * @param endpoint the endpoint for this transaction
     * @param endpoint the endpoint for this transaction
     * @param buffer buffer for data to send or receive
     * @param buffer buffer for data to send or receive
@@ -165,11 +171,7 @@ public class UsbDeviceConnection {
     * @param timeout in milliseconds
     * @param timeout in milliseconds
     * @return length of data transferred (or zero) for success,
     * @return length of data transferred (or zero) for success,
     * or negative value for failure
     * or negative value for failure
     *
     * @deprecated Use {@link #bulkTransfer(UsbEndpoint, byte[], int, int, int)}
     * which accepts a buffer start index.
     */
     */
    @Deprecated
    public int bulkTransfer(UsbEndpoint endpoint,
    public int bulkTransfer(UsbEndpoint endpoint,
            byte[] buffer, int length, int timeout) {
            byte[] buffer, int length, int timeout) {
        return bulkTransfer(endpoint, buffer, 0, length, timeout);
        return bulkTransfer(endpoint, buffer, 0, length, timeout);
@@ -177,20 +179,20 @@ public class UsbDeviceConnection {


    /**
    /**
     * Performs a bulk transaction on the given endpoint.
     * Performs a bulk transaction on the given endpoint.
     * The direction of the transfer is determined by the direction of the endpoint
     * The direction of the transfer is determined by the direction of the endpoint.
     *
     *
     * @param endpoint the endpoint for this transaction
     * @param endpoint the endpoint for this transaction
     * @param buffer buffer for data to send or receive
     * @param buffer buffer for data to send or receive
     * @param start the index of the first byte in the buffer to send or receive
     * @param offset the index of the first byte in the buffer to send or receive
     * @param length the length of the data to send or receive
     * @param length the length of the data to send or receive
     * @param timeout in milliseconds
     * @param timeout in milliseconds
     * @return length of data transferred (or zero) for success,
     * @return length of data transferred (or zero) for success,
     * or negative value for failure
     * or negative value for failure
     */
     */
    public int bulkTransfer(UsbEndpoint endpoint,
    public int bulkTransfer(UsbEndpoint endpoint,
            byte[] buffer, int start, int length, int timeout) {
            byte[] buffer, int offset, int length, int timeout) {
        checkBounds(buffer, start, length);
        checkBounds(buffer, offset, length);
        return native_bulk_request(endpoint.getAddress(), buffer, start, length, timeout);
        return native_bulk_request(endpoint.getAddress(), buffer, offset, length, timeout);
    }
    }


    /**
    /**
@@ -235,9 +237,9 @@ public class UsbDeviceConnection {
    private native boolean native_claim_interface(int interfaceID, boolean force);
    private native boolean native_claim_interface(int interfaceID, boolean force);
    private native boolean native_release_interface(int interfaceID);
    private native boolean native_release_interface(int interfaceID);
    private native int native_control_request(int requestType, int request, int value,
    private native int native_control_request(int requestType, int request, int value,
            int index, byte[] buffer, int start, int length, int timeout);
            int index, byte[] buffer, int offset, int length, int timeout);
    private native int native_bulk_request(int endpoint, byte[] buffer,
    private native int native_bulk_request(int endpoint, byte[] buffer,
            int start, int length, int timeout);
            int offset, int length, int timeout);
    private native UsbRequest native_request_wait();
    private native UsbRequest native_request_wait();
    private native String native_get_serial();
    private native String native_get_serial();
}
}