Methods Summary |
---|
public void | close()Closes all resources related to the MtpDevice object.
After this is called, the object can not be used until {@link #open} is called again
with a new {@link android.hardware.usb.UsbDeviceConnection}.
native_close();
|
public boolean | deleteObject(int objectHandle)Deletes an object on the device. This call may block, since
deleting a directory containing many files may take a long time
on some devices.
return native_delete_object(objectHandle);
|
protected void | finalize()
try {
native_close();
} finally {
super.finalize();
}
|
public int | getDeviceId()Returns the USB ID of the USB device.
This returns the same value as {@link android.hardware.usb.UsbDevice#getDeviceId}
for the device's {@link android.hardware.usb.UsbDevice}
return mDevice.getDeviceId();
|
public MtpDeviceInfo | getDeviceInfo()Returns the {@link MtpDeviceInfo} for this device
return native_get_device_info();
|
public java.lang.String | getDeviceName()Returns the name of the USB device
This returns the same value as {@link android.hardware.usb.UsbDevice#getDeviceName}
for the device's {@link android.hardware.usb.UsbDevice}
return mDevice.getDeviceName();
|
public byte[] | getObject(int objectHandle, int objectSize)Returns the data for an object as a byte array.
This call may block for an arbitrary amount of time depending on the size
of the data and speed of the devices.
return native_get_object(objectHandle, objectSize);
|
public int[] | getObjectHandles(int storageId, int format, int objectHandle)Returns the list of object handles for all objects on the given storage unit,
with the given format and parent.
Information about each object can be accessed via {@link #getObjectInfo}.
return native_get_object_handles(storageId, format, objectHandle);
|
public MtpObjectInfo | getObjectInfo(int objectHandle)Retrieves the {@link MtpObjectInfo} for an object.
return native_get_object_info(objectHandle);
|
public long | getParent(int objectHandle)Retrieves the object handle for the parent of an object on the device.
return native_get_parent(objectHandle);
|
public long | getStorageId(int objectHandle)Retrieves the ID of the storage unit containing the given object on the device.
return native_get_storage_id(objectHandle);
|
public int[] | getStorageIds()Returns the list of IDs for all storage units on this device
Information about each storage unit can be accessed via {@link #getStorageInfo}.
return native_get_storage_ids();
|
public MtpStorageInfo | getStorageInfo(int storageId)Retrieves the {@link MtpStorageInfo} for a storage unit.
return native_get_storage_info(storageId);
|
public byte[] | getThumbnail(int objectHandle)Returns the thumbnail data for an object as a byte array.
The size and format of the thumbnail data can be determined via
{@link MtpObjectInfo#getThumbCompressedSize} and
{@link MtpObjectInfo#getThumbFormat}.
For typical devices the format is JPEG.
return native_get_thumbnail(objectHandle);
|
public boolean | importFile(int objectHandle, java.lang.String destPath)Copies the data for an object to a file in external storage.
This call may block for an arbitrary amount of time depending on the size
of the data and speed of the devices.
return native_import_file(objectHandle, destPath);
|
private native void | native_close()
|
private native boolean | native_delete_object(int objectHandle)
|
private native MtpDeviceInfo | native_get_device_info()
|
private native byte[] | native_get_object(int objectHandle, int objectSize)
|
private native int[] | native_get_object_handles(int storageId, int format, int objectHandle)
|
private native MtpObjectInfo | native_get_object_info(int objectHandle)
|
private native long | native_get_parent(int objectHandle)
|
private native long | native_get_storage_id(int objectHandle)
|
private native int[] | native_get_storage_ids()
|
private native MtpStorageInfo | native_get_storage_info(int storageId)
|
private native byte[] | native_get_thumbnail(int objectHandle)
|
private native boolean | native_import_file(int objectHandle, java.lang.String destPath)
|
private native boolean | native_open(java.lang.String deviceName, int fd)
|
public boolean | open(android.hardware.usb.UsbDeviceConnection connection)Opens the MTP device. Once the device is open it takes ownership of the
{@link android.hardware.usb.UsbDeviceConnection}.
The connection will be closed when you call {@link #close()}
The connection will also be closed if this method fails.
boolean result = native_open(mDevice.getDeviceName(), connection.getFileDescriptor());
if (!result) {
connection.close();
}
return result;
|
public java.lang.String | toString()
return mDevice.getDeviceName();
|