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

Commit ad4f583e authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski Committed by Android (Google) Code Review
Browse files

Merge "Fix sendObject upload."

parents db6878a2 532b4f23
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);