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

Commit 8d96aa8e authored by James Wei's avatar James Wei
Browse files

MTP: Skip runtime thumbnail generation for Android Host

Android Host is not capable to deal with the long processing time for
runtime thumbnail generation.
Skip runtime thumbnail generation for Android Host
but keep no impact to other Host

Bug: 188752500
Test: atest MtpTests
Test: atest MtpServerTest
Test: atest MtpServiceTests
Test: manual test on Windows 10 File Explorer
Test: manual test on Android Host Files App
Change-Id: I73b6d804cc350a6146e4ab2794d15d05d1277f34
parent d9b67319
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -608,6 +608,32 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) {
    return NULL;
}

bool MtpDevice::setDevicePropValueStr(MtpProperty* property) {
    if (property == nullptr)
        return false;

    std::lock_guard<std::mutex> lg(mMutex);

    if (property->getDataType() != MTP_TYPE_STR) {
        return false;
    }

    mRequest.reset();
    mRequest.setParameter(1, property->getPropertyCode());

    mData.reset();
    mData.putString(property->getCurrentValue().str);

   if (sendRequest(MTP_OPERATION_SET_DEVICE_PROP_VALUE) && sendData()) {
        MtpResponseCode ret = readResponse();
        if (ret != MTP_RESPONSE_OK) {
            ALOGW("%s: Response=0x%04X\n", __func__, ret);
            return false;
        }
    }
    return true;
}

MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format) {
    std::lock_guard<std::mutex> lg(mMutex);

+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ public:
    MtpObjectPropertyList*  getObjectPropsSupported(MtpObjectFormat format);

    MtpProperty*            getDevicePropDesc(MtpDeviceProperty code);
    bool                    setDevicePropValueStr(MtpProperty* property);
    MtpProperty*            getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format);

    // Reads value of |property| for |handle|. Returns true on success.
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ int MtpPacket::transfer(struct usb_request* request) {
                            request->endpoint,
                            request->buffer,
                            request->buffer_length,
                            1000);
                            5000);
    request->actual_length = result;
    return result;
}
+10 −0
Original line number Diff line number Diff line
@@ -240,6 +240,16 @@ void MtpProperty::setCurrentValue(const uint16_t* string) {
        mCurrentValue.str = NULL;
}

void MtpProperty::setCurrentValue(const char* string) {
    free(mCurrentValue.str);
    if (string) {
        MtpStringBuffer buffer(string);
        mCurrentValue.str = strdup(buffer);
    }
    else
        mCurrentValue.str = NULL;
}

void MtpProperty::setCurrentValue(MtpDataPacket& packet) {
    free(mCurrentValue.str);
    mCurrentValue.str = NULL;
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public:

    void                setDefaultValue(const uint16_t* string);
    void                setCurrentValue(const uint16_t* string);
    void                setCurrentValue(const char* string);
    void                setCurrentValue(MtpDataPacket& packet);
    const MtpPropertyValue& getCurrentValue() { return mCurrentValue; }