Add support for reading into a file descriptor on MTP devices.
This will allow to read files on Java side without copying all bytes to
memory first, which is problematic for large files such as movies.
Bug:22908937
Change-Id: I67b116cf01d9e44af69f94c8edc64fd8fbf7b9a3
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index 3eafd6f..887f0ec 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -698,6 +698,14 @@
fchmod(fd, perm);
umask(mask);
+ bool result = readObject(handle, fd);
+ ::close(fd);
+ return result;
+}
+
+bool MtpDevice::readObject(MtpObjectHandle handle, int fd) {
+ ALOGD("readObject: %d", fd);
+
Mutex::Autolock autoLock(mMutex);
bool result = false;
@@ -779,7 +787,6 @@
}
fail:
- ::close(fd);
return result;
}