MTP: Fix reading and writing device property descriptors
Change-Id: I8d9653ceedfed688addd6c4194c097d7090c3468
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/media/mtp/MtpProperty.cpp b/media/mtp/MtpProperty.cpp
index c7a91d6..995f589 100644
--- a/media/mtp/MtpProperty.cpp
+++ b/media/mtp/MtpProperty.cpp
@@ -121,6 +121,7 @@
}
void MtpProperty::read(MtpDataPacket& packet) {
+ bool deviceProp = isDeviceProperty();
mCode = packet.getUInt16();
mType = packet.getUInt16();
@@ -137,14 +138,16 @@
case MTP_TYPE_AINT128:
case MTP_TYPE_AUINT128:
mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength);
- mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength);
+ if (deviceProp)
+ mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength);
break;
default:
readValue(packet, mDefaultValue);
- if (isDeviceProperty())
+ if (deviceProp)
readValue(packet, mCurrentValue);
}
- mGroupCode = packet.getUInt32();
+ if (!deviceProp)
+ mGroupCode = packet.getUInt32();
mFormFlag = packet.getUInt8();
if (mFormFlag == kFormRange) {
@@ -160,6 +163,8 @@
}
void MtpProperty::write(MtpDataPacket& packet) {
+ bool deviceProp = isDeviceProperty();
+
packet.putUInt16(mCode);
packet.putUInt16(mType);
packet.putUInt8(mWriteable ? 1 : 0);
@@ -176,12 +181,17 @@
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);
- packet.putUInt8(mFormFlag);
+ if (!deviceProp)
+ packet.putUInt8(mFormFlag);
if (mFormFlag == kFormRange) {
writeValue(packet, mMinimumValue);
writeValue(packet, mMaximumValue);