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

Commit 532b4f23 authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski
Browse files

Fix sendObject upload.

Two issues are resolved:
- sendObject changed to accept raw arguments instead of objectinfo,
  as calling getObjectInfo after sentObjectInfo is illegal,
- send buffer decreased to 16K, as this is the maximum size working
  per comments in other places.

Change-Id: If71644dcbc508dd92c3fe74a2fdb7c6798059b42
parent f3c2b3df
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -483,17 +483,18 @@ MtpObjectHandle MtpDevice::sendObjectInfo(MtpObjectInfo* info) {
    return (MtpObjectHandle)-1;
}

bool MtpDevice::sendObject(MtpObjectInfo* info, int srcFD) {
bool MtpDevice::sendObject(MtpObjectHandle handle, int size, int srcFD) {
    Mutex::Autolock autoLock(mMutex);

    int remaining = info->mCompressedSize;
    int remaining = size;
    mRequest.reset();
    mRequest.setParameter(1, info->mHandle);
    mRequest.setParameter(1, handle);
    if (sendRequest(MTP_OPERATION_SEND_OBJECT)) {
        // send data header
        writeDataHeader(MTP_OPERATION_SEND_OBJECT, remaining);

        char buffer[65536];
        // USB writes greater than 16K don't work
        char buffer[MTP_BUFFER_SIZE];
        while (remaining > 0) {
            int count = read(srcFD, buffer, sizeof(buffer));
            if (count > 0) {
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public:
    MtpObjectInfo*          getObjectInfo(MtpObjectHandle handle);
    void*                   getThumbnail(MtpObjectHandle handle, int& outLength);
    MtpObjectHandle         sendObjectInfo(MtpObjectInfo* info);
    bool                    sendObject(MtpObjectInfo* info, int srcFD);
    bool                    sendObject(MtpObjectHandle handle, int size, int srcFD);
    bool                    deleteObject(MtpObjectHandle handle);
    MtpObjectHandle         getParent(MtpObjectHandle handle);
    MtpObjectHandle         getStorageID(MtpObjectHandle handle);