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

Commit 025ffd9c authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski
Browse files

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
parent b2d33aee
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -698,6 +698,14 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int gro
    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 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int gro
    }

fail:
    ::close(fd);
    return result;
}

+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public:
                                    size_t objectSize, void* clientData);
    bool                    readObject(MtpObjectHandle handle, const char* destPath, int group,
                                    int perm);
    bool                    readObject(MtpObjectHandle handle, int fd);

private:
    bool                    sendRequest(MtpOperationCode operation);