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

Commit 038832b9 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Implement MtpDevice#getPartialObject64 in Java API.

BUG=26703522

Change-Id: I08510e3a179b7dc8bf247a9e997dc8a160138fc2
parent 5012919b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22729,6 +22729,7 @@ package android.mtp {
    field public static final int OPERATION_GET_OBJECT_PROP_VALUE = 38915; // 0x9803
    field public static final int OPERATION_GET_OBJECT_REFERENCES = 38928; // 0x9810
    field public static final int OPERATION_GET_PARTIAL_OBJECT = 4123; // 0x101b
    field public static final int OPERATION_GET_PARTIAL_OBJECT_64 = 38337; // 0x95c1
    field public static final int OPERATION_GET_STORAGE_INFO = 4101; // 0x1005
    field public static final int OPERATION_GET_STORAGE_I_DS = 4100; // 0x1004
    field public static final int OPERATION_GET_THUMB = 4106; // 0x100a
@@ -22766,6 +22767,7 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo getObjectInfo(int);
    method public long getParent(int);
    method public long getPartialObject(int, long, long, byte[]) throws java.io.IOException;
    method public long getPartialObject64(int, long, long, byte[]) throws java.io.IOException;
    method public long getStorageId(int);
    method public int[] getStorageIds();
    method public android.mtp.MtpStorageInfo getStorageInfo(int);
+2 −0
Original line number Diff line number Diff line
@@ -24336,6 +24336,7 @@ package android.mtp {
    field public static final int OPERATION_GET_OBJECT_PROP_VALUE = 38915; // 0x9803
    field public static final int OPERATION_GET_OBJECT_REFERENCES = 38928; // 0x9810
    field public static final int OPERATION_GET_PARTIAL_OBJECT = 4123; // 0x101b
    field public static final int OPERATION_GET_PARTIAL_OBJECT_64 = 38337; // 0x95c1
    field public static final int OPERATION_GET_STORAGE_INFO = 4101; // 0x1005
    field public static final int OPERATION_GET_STORAGE_I_DS = 4100; // 0x1004
    field public static final int OPERATION_GET_THUMB = 4106; // 0x100a
@@ -24373,6 +24374,7 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo getObjectInfo(int);
    method public long getParent(int);
    method public long getPartialObject(int, long, long, byte[]) throws java.io.IOException;
    method public long getPartialObject64(int, long, long, byte[]) throws java.io.IOException;
    method public long getStorageId(int);
    method public int[] getStorageIds();
    method public android.mtp.MtpStorageInfo getStorageInfo(int);
+2 −0
Original line number Diff line number Diff line
@@ -22737,6 +22737,7 @@ package android.mtp {
    field public static final int OPERATION_GET_OBJECT_PROP_VALUE = 38915; // 0x9803
    field public static final int OPERATION_GET_OBJECT_REFERENCES = 38928; // 0x9810
    field public static final int OPERATION_GET_PARTIAL_OBJECT = 4123; // 0x101b
    field public static final int OPERATION_GET_PARTIAL_OBJECT_64 = 38337; // 0x95c1
    field public static final int OPERATION_GET_STORAGE_INFO = 4101; // 0x1005
    field public static final int OPERATION_GET_STORAGE_I_DS = 4100; // 0x1004
    field public static final int OPERATION_GET_THUMB = 4106; // 0x100a
@@ -22774,6 +22775,7 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo getObjectInfo(int);
    method public long getParent(int);
    method public long getPartialObject(int, long, long, byte[]) throws java.io.IOException;
    method public long getPartialObject64(int, long, long, byte[]) throws java.io.IOException;
    method public long getStorageId(int);
    method public int[] getStorageIds();
    method public android.mtp.MtpStorageInfo getStorageInfo(int);
+2 −0
Original line number Diff line number Diff line
@@ -683,4 +683,6 @@ public final class MtpConstants {
    public static final int OPERATION_SET_OBJECT_REFERENCES = 0x9811;
    /** Operation code for Skip */
    public static final int OPERATION_SKIP = 0x9820;
    /** Operation code for GetPartialObject64 */
    public static final int OPERATION_GET_PARTIAL_OBJECT_64 = 0x95C1;
}
+23 −0
Original line number Diff line number Diff line
@@ -178,6 +178,27 @@ public final class MtpDevice {
        return native_get_partial_object(objectHandle, offset, size, buffer);
    }

    /**
     * Obtains object bytes in the specified range and writes it to an array.
     * This call may block for an arbitrary amount of time depending on the size
     * of the data and speed of the devices.
     *
     * This is a vender-extended operation supported by Android that enables us to pass
     * unsigned 64-bit offset. Check if the MTP device supports the operation by using
     * {@link MtpDeviceInfo#getOperationsSupported()}.
     *
     * @param objectHandle handle of the object to read
     * @param offset Start index of reading range. It must be a non-negative value.
     * @param size Size of reading range. It must be a non-negative value at most 0xffffffff.
     * @param buffer Array to write data.
     * @return Size of bytes that are actually read.
     * @see MtpConstants#OPERATION_GET_PARTIAL_OBJECT_64
     */
    public long getPartialObject64(int objectHandle, long offset, long size, byte[] buffer)
            throws IOException {
        return native_get_partial_object_64(objectHandle, offset, size, buffer);
    }

    /**
     * Returns the thumbnail data for an object as a byte array.
     * The size and format of the thumbnail data can be determined via
@@ -346,6 +367,8 @@ public final class MtpDevice {
    private native byte[] native_get_object(int objectHandle, int objectSize);
    private native long native_get_partial_object(
            int objectHandle, long offset, long objectSize, byte[] buffer) throws IOException;
    private native int native_get_partial_object_64(
            int objectHandle, long offset, long objectSize, byte[] buffer) throws IOException;
    private native byte[] native_get_thumbnail(int objectHandle);
    private native boolean native_delete_object(int objectHandle);
    private native long native_get_parent(int objectHandle);
Loading