Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -18089,6 +18089,7 @@ package android.mtp { method public android.mtp.MtpStorageInfo getStorageInfo(int); method public byte[] getThumbnail(int); method public boolean importFile(int, java.lang.String); method public boolean importFile(int, android.os.ParcelFileDescriptor); method public boolean open(android.hardware.usb.UsbDeviceConnection); } api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19601,6 +19601,7 @@ package android.mtp { method public android.mtp.MtpStorageInfo getStorageInfo(int); method public byte[] getThumbnail(int); method public boolean importFile(int, java.lang.String); method public boolean importFile(int, android.os.ParcelFileDescriptor); method public boolean open(android.hardware.usb.UsbDeviceConnection); } media/java/android/mtp/MtpDevice.java +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.mtp; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.os.ParcelFileDescriptor; /** * This class represents an MTP or PTP device connected on the USB host bus. An application can Loading Loading @@ -235,6 +236,20 @@ public final class MtpDevice { return native_import_file(objectHandle, destPath); } /** * Copies the data for an object to a file descriptor. * This call may block for an arbitrary amount of time depending on the size * of the data and speed of the devices. The file descriptor is not closed * on completion, and must be done by the caller. * * @param objectHandle handle of the object to read * @param descriptor file descriptor to write the data to for the file transfer. * @return true if the file transfer succeeds */ public boolean importFile(int objectHandle, ParcelFileDescriptor descriptor) { return native_import_file(objectHandle, descriptor.getFd()); } // used by the JNI code private long mNativeContext; Loading @@ -251,4 +266,5 @@ public final class MtpDevice { private native long native_get_parent(int objectHandle); private native long 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); } media/jni/android_mtp_MtpDevice.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -393,6 +393,16 @@ android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jst return JNI_FALSE; } static jboolean android_mtp_MtpDevice_import_file_to_fd(JNIEnv *env, jobject thiz, jint object_id, jint fd) { MtpDevice* device = get_device_from_object(env, thiz); if (device) return device->readObject(object_id, fd); else return JNI_FALSE; } // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { Loading @@ -415,6 +425,7 @@ static JNINativeMethod gMethods[] = { {"native_get_storage_id", "(I)J", (void *)android_mtp_MtpDevice_get_storage_id}, {"native_import_file", "(ILjava/lang/String;)Z", (void *)android_mtp_MtpDevice_import_file}, {"native_import_file", "(II)Z", (void *)android_mtp_MtpDevice_import_file_to_fd} }; int register_android_mtp_MtpDevice(JNIEnv *env) Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -18089,6 +18089,7 @@ package android.mtp { method public android.mtp.MtpStorageInfo getStorageInfo(int); method public byte[] getThumbnail(int); method public boolean importFile(int, java.lang.String); method public boolean importFile(int, android.os.ParcelFileDescriptor); method public boolean open(android.hardware.usb.UsbDeviceConnection); }
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19601,6 +19601,7 @@ package android.mtp { method public android.mtp.MtpStorageInfo getStorageInfo(int); method public byte[] getThumbnail(int); method public boolean importFile(int, java.lang.String); method public boolean importFile(int, android.os.ParcelFileDescriptor); method public boolean open(android.hardware.usb.UsbDeviceConnection); }
media/java/android/mtp/MtpDevice.java +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.mtp; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.os.ParcelFileDescriptor; /** * This class represents an MTP or PTP device connected on the USB host bus. An application can Loading Loading @@ -235,6 +236,20 @@ public final class MtpDevice { return native_import_file(objectHandle, destPath); } /** * Copies the data for an object to a file descriptor. * This call may block for an arbitrary amount of time depending on the size * of the data and speed of the devices. The file descriptor is not closed * on completion, and must be done by the caller. * * @param objectHandle handle of the object to read * @param descriptor file descriptor to write the data to for the file transfer. * @return true if the file transfer succeeds */ public boolean importFile(int objectHandle, ParcelFileDescriptor descriptor) { return native_import_file(objectHandle, descriptor.getFd()); } // used by the JNI code private long mNativeContext; Loading @@ -251,4 +266,5 @@ public final class MtpDevice { private native long native_get_parent(int objectHandle); private native long 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); }
media/jni/android_mtp_MtpDevice.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -393,6 +393,16 @@ android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jst return JNI_FALSE; } static jboolean android_mtp_MtpDevice_import_file_to_fd(JNIEnv *env, jobject thiz, jint object_id, jint fd) { MtpDevice* device = get_device_from_object(env, thiz); if (device) return device->readObject(object_id, fd); else return JNI_FALSE; } // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { Loading @@ -415,6 +425,7 @@ static JNINativeMethod gMethods[] = { {"native_get_storage_id", "(I)J", (void *)android_mtp_MtpDevice_get_storage_id}, {"native_import_file", "(ILjava/lang/String;)Z", (void *)android_mtp_MtpDevice_import_file}, {"native_import_file", "(II)Z", (void *)android_mtp_MtpDevice_import_file_to_fd} }; int register_android_mtp_MtpDevice(JNIEnv *env) Loading