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

Commit dfb7c95a authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "Add MtpDevice#getPartialObject64 method."

parents 8a3ff465 326edd98
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -778,7 +778,27 @@ bool MtpDevice::readPartialObject(MtpObjectHandle handle,
        ALOGE("Failed to send a read request.");
        return false;
    }
    return readData(callback, NULL /* expected size */, writtenSize, clientData);
    return readData(callback, nullptr /* expected size */, writtenSize, clientData);
}

bool MtpDevice::readPartialObject64(MtpObjectHandle handle,
                                    uint64_t offset,
                                    uint32_t size,
                                    uint32_t *writtenSize,
                                    ReadObjectCallback callback,
                                    void* clientData) {
    Mutex::Autolock autoLock(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
    mRequest.setParameter(2, 0xffffffff & offset);
    mRequest.setParameter(3, 0xffffffff & (offset >> 32));
    mRequest.setParameter(4, size);
    if (!sendRequest(MTP_OPERATION_GET_PARTIAL_OBJECT_64)) {
        ALOGE("Failed to send a read request.");
        return false;
    }
    return readData(callback, nullptr /* expected size */, writtenSize, clientData);
}

bool MtpDevice::sendRequest(MtpOperationCode operation) {
+6 −0
Original line number Diff line number Diff line
@@ -118,6 +118,12 @@ public:
                                              uint32_t *writtenSize,
                                              ReadObjectCallback callback,
                                              void* clientData);
    bool                    readPartialObject64(MtpObjectHandle handle,
                                                uint64_t offset,
                                                uint32_t size,
                                                uint32_t *writtenSize,
                                                ReadObjectCallback callback,
                                                void* clientData);
    // Starts a request to read MTP event from MTP device. It returns a request handle that
    // can be used for blocking read or cancel. If other thread has already been processing an
    // event returns -1.