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

Commit 564ff843 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Fix reading and writing device property descriptors



Change-Id: I8d9653ceedfed688addd6c4194c097d7090c3468
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 409a90cd
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ MtpProperty::~MtpProperty() {
}

void MtpProperty::read(MtpDataPacket& packet) {
    bool deviceProp = isDeviceProperty();

    mCode = packet.getUInt16();
    mType = packet.getUInt16();
@@ -137,13 +138,15 @@ void MtpProperty::read(MtpDataPacket& packet) {
        case MTP_TYPE_AINT128:
        case MTP_TYPE_AUINT128:
            mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength);
            if (deviceProp)
                mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength);
            break;
        default:
            readValue(packet, mDefaultValue);
            if (isDeviceProperty())
            if (deviceProp)
                readValue(packet, mCurrentValue);
    }
    if (!deviceProp)
        mGroupCode = packet.getUInt32();
    mFormFlag = packet.getUInt8();

@@ -160,6 +163,8 @@ void MtpProperty::read(MtpDataPacket& packet) {
}

void MtpProperty::write(MtpDataPacket& packet) {
    bool deviceProp = isDeviceProperty();

    packet.putUInt16(mCode);
    packet.putUInt16(mType);
    packet.putUInt8(mWriteable ? 1 : 0);
@@ -176,11 +181,16 @@ void MtpProperty::write(MtpDataPacket& packet) {
        case MTP_TYPE_AINT128:
        case MTP_TYPE_AUINT128:
            writeArrayValues(packet, mDefaultArrayValues, mDefaultArrayLength);
            if (deviceProp)
                writeArrayValues(packet, mCurrentArrayValues, mCurrentArrayLength);
            break;
        default:
            writeValue(packet, mDefaultValue);
            if (deviceProp)
                writeValue(packet, mCurrentValue);
    }
    packet.putUInt32(mGroupCode);
    if (!deviceProp)
        packet.putUInt8(mFormFlag);
    if (mFormFlag == kFormRange) {
            writeValue(packet, mMinimumValue);