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

Commit c8718b57 authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "Add varietions of MtpDevice's mehtods using long."

parents 29748944 e0e6654a
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -23151,7 +23151,7 @@ package android.mtp {
    method public boolean importFile(int, android.os.ParcelFileDescriptor);
    method public boolean open(android.hardware.usb.UsbDeviceConnection);
    method public android.mtp.MtpEvent readEvent(android.os.CancellationSignal);
    method public boolean sendObject(int, int, android.os.ParcelFileDescriptor);
    method public boolean sendObject(int, long, android.os.ParcelFileDescriptor);
    method public android.mtp.MtpObjectInfo sendObjectInfo(android.mtp.MtpObjectInfo);
  }
@@ -23182,23 +23182,31 @@ package android.mtp {
    method public final int getAssociationDesc();
    method public final int getAssociationType();
    method public final int getCompressedSize();
    method public final long getCompressedSizeLong();
    method public final long getDateCreated();
    method public final long getDateModified();
    method public final int getFormat();
    method public final int getImagePixDepth();
    method public final long getImagePixDepthLong();
    method public final int getImagePixHeight();
    method public final long getImagePixHeightLong();
    method public final int getImagePixWidth();
    method public final long getImagePixWidthLong();
    method public final java.lang.String getKeywords();
    method public final java.lang.String getName();
    method public final int getObjectHandle();
    method public final int getParent();
    method public final int getProtectionStatus();
    method public final int getSequenceNumber();
    method public final long getSequenceNumberLong();
    method public final int getStorageId();
    method public final int getThumbCompressedSize();
    method public final long getThumbCompressedSizeLong();
    method public final int getThumbFormat();
    method public final int getThumbPixHeight();
    method public final long getThumbPixHeightLong();
    method public final int getThumbPixWidth();
    method public final long getThumbPixWidthLong();
  }
  public static class MtpObjectInfo.Builder {
@@ -23207,24 +23215,24 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo build();
    method public android.mtp.MtpObjectInfo.Builder setAssociationDesc(int);
    method public android.mtp.MtpObjectInfo.Builder setAssociationType(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setDateCreated(long);
    method public android.mtp.MtpObjectInfo.Builder setDateModified(long);
    method public android.mtp.MtpObjectInfo.Builder setFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(long);
    method public android.mtp.MtpObjectInfo.Builder setKeywords(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setName(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setObjectHandle(int);
    method public android.mtp.MtpObjectInfo.Builder setParent(int);
    method public android.mtp.MtpObjectInfo.Builder setProtectionStatus(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(long);
    method public android.mtp.MtpObjectInfo.Builder setStorageId(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(long);
  }
  public final class MtpStorageInfo {
+17 −9
Original line number Diff line number Diff line
@@ -24538,7 +24538,7 @@ package android.mtp {
    method public boolean importFile(int, android.os.ParcelFileDescriptor);
    method public boolean open(android.hardware.usb.UsbDeviceConnection);
    method public android.mtp.MtpEvent readEvent(android.os.CancellationSignal);
    method public boolean sendObject(int, int, android.os.ParcelFileDescriptor);
    method public boolean sendObject(int, long, android.os.ParcelFileDescriptor);
    method public android.mtp.MtpObjectInfo sendObjectInfo(android.mtp.MtpObjectInfo);
  }
@@ -24569,23 +24569,31 @@ package android.mtp {
    method public final int getAssociationDesc();
    method public final int getAssociationType();
    method public final int getCompressedSize();
    method public final long getCompressedSizeLong();
    method public final long getDateCreated();
    method public final long getDateModified();
    method public final int getFormat();
    method public final int getImagePixDepth();
    method public final long getImagePixDepthLong();
    method public final int getImagePixHeight();
    method public final long getImagePixHeightLong();
    method public final int getImagePixWidth();
    method public final long getImagePixWidthLong();
    method public final java.lang.String getKeywords();
    method public final java.lang.String getName();
    method public final int getObjectHandle();
    method public final int getParent();
    method public final int getProtectionStatus();
    method public final int getSequenceNumber();
    method public final long getSequenceNumberLong();
    method public final int getStorageId();
    method public final int getThumbCompressedSize();
    method public final long getThumbCompressedSizeLong();
    method public final int getThumbFormat();
    method public final int getThumbPixHeight();
    method public final long getThumbPixHeightLong();
    method public final int getThumbPixWidth();
    method public final long getThumbPixWidthLong();
  }
  public static class MtpObjectInfo.Builder {
@@ -24594,24 +24602,24 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo build();
    method public android.mtp.MtpObjectInfo.Builder setAssociationDesc(int);
    method public android.mtp.MtpObjectInfo.Builder setAssociationType(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setDateCreated(long);
    method public android.mtp.MtpObjectInfo.Builder setDateModified(long);
    method public android.mtp.MtpObjectInfo.Builder setFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(long);
    method public android.mtp.MtpObjectInfo.Builder setKeywords(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setName(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setObjectHandle(int);
    method public android.mtp.MtpObjectInfo.Builder setParent(int);
    method public android.mtp.MtpObjectInfo.Builder setProtectionStatus(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(long);
    method public android.mtp.MtpObjectInfo.Builder setStorageId(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(long);
  }
  public final class MtpStorageInfo {
+17 −9
Original line number Diff line number Diff line
@@ -23160,7 +23160,7 @@ package android.mtp {
    method public boolean importFile(int, android.os.ParcelFileDescriptor);
    method public boolean open(android.hardware.usb.UsbDeviceConnection);
    method public android.mtp.MtpEvent readEvent(android.os.CancellationSignal);
    method public boolean sendObject(int, int, android.os.ParcelFileDescriptor);
    method public boolean sendObject(int, long, android.os.ParcelFileDescriptor);
    method public android.mtp.MtpObjectInfo sendObjectInfo(android.mtp.MtpObjectInfo);
  }
@@ -23191,23 +23191,31 @@ package android.mtp {
    method public final int getAssociationDesc();
    method public final int getAssociationType();
    method public final int getCompressedSize();
    method public final long getCompressedSizeLong();
    method public final long getDateCreated();
    method public final long getDateModified();
    method public final int getFormat();
    method public final int getImagePixDepth();
    method public final long getImagePixDepthLong();
    method public final int getImagePixHeight();
    method public final long getImagePixHeightLong();
    method public final int getImagePixWidth();
    method public final long getImagePixWidthLong();
    method public final java.lang.String getKeywords();
    method public final java.lang.String getName();
    method public final int getObjectHandle();
    method public final int getParent();
    method public final int getProtectionStatus();
    method public final int getSequenceNumber();
    method public final long getSequenceNumberLong();
    method public final int getStorageId();
    method public final int getThumbCompressedSize();
    method public final long getThumbCompressedSizeLong();
    method public final int getThumbFormat();
    method public final int getThumbPixHeight();
    method public final long getThumbPixHeightLong();
    method public final int getThumbPixWidth();
    method public final long getThumbPixWidthLong();
  }
  public static class MtpObjectInfo.Builder {
@@ -23216,24 +23224,24 @@ package android.mtp {
    method public android.mtp.MtpObjectInfo build();
    method public android.mtp.MtpObjectInfo.Builder setAssociationDesc(int);
    method public android.mtp.MtpObjectInfo.Builder setAssociationType(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setDateCreated(long);
    method public android.mtp.MtpObjectInfo.Builder setDateModified(long);
    method public android.mtp.MtpObjectInfo.Builder setFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setImagePixDepth(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setImagePixWidth(long);
    method public android.mtp.MtpObjectInfo.Builder setKeywords(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setName(java.lang.String);
    method public android.mtp.MtpObjectInfo.Builder setObjectHandle(int);
    method public android.mtp.MtpObjectInfo.Builder setParent(int);
    method public android.mtp.MtpObjectInfo.Builder setProtectionStatus(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(int);
    method public android.mtp.MtpObjectInfo.Builder setSequenceNumber(long);
    method public android.mtp.MtpObjectInfo.Builder setStorageId(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbCompressedSize(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbFormat(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(int);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixHeight(long);
    method public android.mtp.MtpObjectInfo.Builder setThumbPixWidth(long);
  }
  public final class MtpStorageInfo {
+7 −6
Original line number Diff line number Diff line
@@ -153,10 +153,11 @@ public final class MtpDevice {
     *
     * @param objectHandle handle of the object to read
     * @param objectSize the size of the object (this should match
     *      {@link MtpObjectInfo#getCompressedSize}
     *      {@link MtpObjectInfo#getCompressedSize})
     * @return the object's data, or null if reading fails
     */
    public byte[] getObject(int objectHandle, int objectSize) {
        Preconditions.checkArgumentNonnegative(objectSize, "objectSize should not be negative");
        return native_get_object(objectHandle, objectSize);
    }

@@ -284,7 +285,7 @@ public final class MtpDevice {
     * @param descriptor file descriptor to read the data from.
     * @return true if the file transfer succeeds
     */
    public boolean sendObject(int objectHandle, int size, ParcelFileDescriptor descriptor) {
    public boolean sendObject(int objectHandle, long size, ParcelFileDescriptor descriptor) {
        return native_send_object(objectHandle, size, descriptor.getFd());
    }

@@ -343,16 +344,16 @@ public final class MtpDevice {
    private native MtpStorageInfo native_get_storage_info(int storageId);
    private native int[] native_get_object_handles(int storageId, int format, int objectHandle);
    private native MtpObjectInfo native_get_object_info(int objectHandle);
    private native byte[] native_get_object(int objectHandle, int objectSize);
    private native byte[] native_get_object(int objectHandle, long objectSize);
    private native long native_get_partial_object(
            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);
    private native long native_get_storage_id(int objectHandle);
    private native int native_get_parent(int objectHandle);
    private native int native_get_storage_id(int objectHandle);
    private native boolean native_import_file(int objectHandle, String destPath);
    private native boolean native_import_file(int objectHandle, int fd);
    private native boolean native_send_object(int objectHandle, int size, int fd);
    private native boolean native_send_object(int objectHandle, long size, int fd);
    private native MtpObjectInfo native_send_object_info(MtpObjectInfo info);
    private native int native_submit_event_request();
    private native MtpEvent native_reap_event_request(int handle);
+117 −17
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.mtp;

import com.android.internal.util.Preconditions;

/**
 * This class encapsulates information about an object on an MTP device.
 * This corresponds to the ObjectInfo Dataset described in
@@ -96,9 +98,19 @@ public final class MtpObjectInfo {
     * @return the object size
     */
    public final int getCompressedSize() {
        Preconditions.checkState(mCompressedSize >= 0);
        return mCompressedSize;
    }

    /**
     * Returns the size of the MTP object
     *
     * @return the object size
     */
    public final long getCompressedSizeLong() {
        return uint32ToLong(mCompressedSize);
    }

    /**
     * Returns the format code for the MTP object's thumbnail
     * Will be zero for objects with no thumbnail
@@ -116,9 +128,20 @@ public final class MtpObjectInfo {
     * @return the thumbnail size
     */
    public final int getThumbCompressedSize() {
        Preconditions.checkState(mThumbCompressedSize >= 0);
        return mThumbCompressedSize;
    }

    /**
     * Returns the size of the MTP object's thumbnail
     * Will be zero for objects with no thumbnail
     *
     * @return the thumbnail size
     */
    public final long getThumbCompressedSizeLong() {
        return uint32ToLong(mThumbCompressedSize);
    }

    /**
     * Returns the width of the MTP object's thumbnail in pixels
     * Will be zero for objects with no thumbnail
@@ -126,9 +149,20 @@ public final class MtpObjectInfo {
     * @return the thumbnail width
     */
    public final int getThumbPixWidth() {
        Preconditions.checkState(mThumbPixWidth >= 0);
        return mThumbPixWidth;
    }

    /**
     * Returns the width of the MTP object's thumbnail in pixels
     * Will be zero for objects with no thumbnail
     *
     * @return the thumbnail width
     */
    public final long getThumbPixWidthLong() {
        return uint32ToLong(mThumbPixWidth);
    }

    /**
     * Returns the height of the MTP object's thumbnail in pixels
     * Will be zero for objects with no thumbnail
@@ -136,9 +170,20 @@ public final class MtpObjectInfo {
     * @return the thumbnail height
     */
    public final int getThumbPixHeight() {
        Preconditions.checkState(mThumbPixHeight >= 0);
        return mThumbPixHeight;
    }

    /**
     * Returns the height of the MTP object's thumbnail in pixels
     * Will be zero for objects with no thumbnail
     *
     * @return the thumbnail height
     */
    public final long getThumbPixHeightLong() {
        return uint32ToLong(mThumbPixHeight);
    }

    /**
     * Returns the width of the MTP object in pixels
     * Will be zero for non-image objects
@@ -146,9 +191,20 @@ public final class MtpObjectInfo {
     * @return the image width
     */
    public final int getImagePixWidth() {
        Preconditions.checkState(mImagePixWidth >= 0);
        return mImagePixWidth;
    }

    /**
     * Returns the width of the MTP object in pixels
     * Will be zero for non-image objects
     *
     * @return the image width
     */
    public final long getImagePixWidthLong() {
        return uint32ToLong(mImagePixWidth);
    }

    /**
     * Returns the height of the MTP object in pixels
     * Will be zero for non-image objects
@@ -156,9 +212,20 @@ public final class MtpObjectInfo {
     * @return the image height
     */
    public final int getImagePixHeight() {
        Preconditions.checkState(mImagePixHeight >= 0);
        return mImagePixHeight;
    }

    /**
     * Returns the height of the MTP object in pixels
     * Will be zero for non-image objects
     *
     * @return the image height
     */
    public final long getImagePixHeightLong() {
        return uint32ToLong(mImagePixHeight);
    }

    /**
     * Returns the depth of the MTP object in bits per pixel
     * Will be zero for non-image objects
@@ -166,9 +233,20 @@ public final class MtpObjectInfo {
     * @return the image depth
     */
    public final int getImagePixDepth() {
        Preconditions.checkState(mImagePixDepth >= 0);
        return mImagePixDepth;
    }

    /**
     * Returns the depth of the MTP object in bits per pixel
     * Will be zero for non-image objects
     *
     * @return the image depth
     */
    public final long getImagePixDepthLong() {
        return uint32ToLong(mImagePixDepth);
    }

    /**
     * Returns the object handle for the object's parent
     * Will be zero for the root directory of a storage unit
@@ -212,9 +290,22 @@ public final class MtpObjectInfo {
     * @return the object's sequence number
     */
    public final int getSequenceNumber() {
        Preconditions.checkState(mSequenceNumber >= 0);
        return mSequenceNumber;
    }

    /**
     * Returns the sequence number for the MTP object
     * This field is typically not used for MTP devices,
     * but is sometimes used to define a sequence of photos
     * on PTP cameras.
     *
     * @return the object's sequence number
     */
    public final long getSequenceNumberLong() {
        return uint32ToLong(mSequenceNumber);
    }

   /**
     * Returns the name of the MTP object
     *
@@ -309,8 +400,8 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setCompressedSize(int value) {
            mObjectInfo.mCompressedSize = value;
        public Builder setCompressedSize(long value) {
            mObjectInfo.mCompressedSize = longToUint32(value, "value");
            return this;
        }

@@ -329,18 +420,18 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setImagePixDepth(int value) {
            mObjectInfo.mImagePixDepth = value;
        public Builder setImagePixDepth(long value) {
            mObjectInfo.mImagePixDepth = longToUint32(value, "value");
            return this;
        }

        public Builder setImagePixHeight(int value) {
            mObjectInfo.mImagePixHeight = value;
        public Builder setImagePixHeight(long value) {
            mObjectInfo.mImagePixHeight = longToUint32(value, "value");
            return this;
        }

        public Builder setImagePixWidth(int value) {
            mObjectInfo.mImagePixWidth = value;
        public Builder setImagePixWidth(long value) {
            mObjectInfo.mImagePixWidth = longToUint32(value, "value");
            return this;
        }

@@ -364,8 +455,8 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setSequenceNumber(int value) {
            mObjectInfo.mSequenceNumber = value;
        public Builder setSequenceNumber(long value) {
            mObjectInfo.mSequenceNumber = longToUint32(value, "value");
            return this;
        }

@@ -374,8 +465,8 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setThumbCompressedSize(int value) {
            mObjectInfo.mThumbCompressedSize = value;
        public Builder setThumbCompressedSize(long value) {
            mObjectInfo.mThumbCompressedSize = longToUint32(value, "value");
            return this;
        }

@@ -384,13 +475,13 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setThumbPixHeight(int value) {
            mObjectInfo.mThumbPixHeight = value;
        public Builder setThumbPixHeight(long value) {
            mObjectInfo.mThumbPixHeight = longToUint32(value, "value");
            return this;
        }

        public Builder setThumbPixWidth(int value) {
            mObjectInfo.mThumbPixWidth = value;
        public Builder setThumbPixWidth(long value) {
            mObjectInfo.mThumbPixWidth = longToUint32(value, "value");
            return this;
        }

@@ -407,4 +498,13 @@ public final class MtpObjectInfo {
            return result;
        }
    }

    private static long uint32ToLong(int value) {
        return value < 0 ? 0x100000000L + value : value;
    }

    private static int longToUint32(long value, String valueName) {
        Preconditions.checkArgumentInRange(value, 0, 0xffffffffL, valueName);
        return (int) value;
    }
}
Loading