summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--media/mtp/MtpDataPacket.cpp1
-rw-r--r--media/mtp/MtpDebug.cpp1
-rw-r--r--media/mtp/MtpProperty.cpp89
-rw-r--r--media/mtp/MtpProperty.h3
4 files changed, 92 insertions, 2 deletions
diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp
index ec78ff02d1f7..20dd94d0e922 100644
--- a/media/mtp/MtpDataPacket.cpp
+++ b/media/mtp/MtpDataPacket.cpp
@@ -373,7 +373,6 @@ int MtpDataPacket::readDataHeader(int fd) {
int MtpDataPacket::write(int fd) {
MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
- dump();
// send header separately from data
int ret = ::write(fd, mBuffer, MTP_CONTAINER_HEADER_SIZE);
if (ret == MTP_CONTAINER_HEADER_SIZE)
diff --git a/media/mtp/MtpDebug.cpp b/media/mtp/MtpDebug.cpp
index d6b107d7434c..34168072b958 100644
--- a/media/mtp/MtpDebug.cpp
+++ b/media/mtp/MtpDebug.cpp
@@ -63,7 +63,6 @@ static const CodeEntry sOperationCodes[] = {
};
static const CodeEntry sFormatCodes[] = {
- { "MTP_OPERATION_GET_DEVICE_INFO", 0x1001 },
{ "MTP_FORMAT_UNDEFINED", 0x3000 },
{ "MTP_FORMAT_ASSOCIATION", 0x3001 },
{ "MTP_FORMAT_SCRIPT", 0x3002 },
diff --git a/media/mtp/MtpProperty.cpp b/media/mtp/MtpProperty.cpp
index bbd023767e80..f7c12d6300ff 100644
--- a/media/mtp/MtpProperty.cpp
+++ b/media/mtp/MtpProperty.cpp
@@ -223,6 +223,95 @@ void MtpProperty::setCurrentValue(const uint16_t* string) {
mCurrentValue.str = NULL;
}
+void MtpProperty::setFormRange(int min, int max, int step) {
+ mFormFlag = kFormRange;
+ switch (mType) {
+ case MTP_TYPE_INT8:
+ mMinimumValue.u.i8 = min;
+ mMaximumValue.u.i8 = max;
+ mStepSize.u.i8 = step;
+ break;
+ case MTP_TYPE_UINT8:
+ mMinimumValue.u.u8 = min;
+ mMaximumValue.u.u8 = max;
+ mStepSize.u.u8 = step;
+ break;
+ case MTP_TYPE_INT16:
+ mMinimumValue.u.i16 = min;
+ mMaximumValue.u.i16 = max;
+ mStepSize.u.i16 = step;
+ break;
+ case MTP_TYPE_UINT16:
+ mMinimumValue.u.u16 = min;
+ mMaximumValue.u.u16 = max;
+ mStepSize.u.u16 = step;
+ break;
+ case MTP_TYPE_INT32:
+ mMinimumValue.u.i32 = min;
+ mMaximumValue.u.i32 = max;
+ mStepSize.u.i32 = step;
+ break;
+ case MTP_TYPE_UINT32:
+ mMinimumValue.u.u32 = min;
+ mMaximumValue.u.u32 = max;
+ mStepSize.u.u32 = step;
+ break;
+ case MTP_TYPE_INT64:
+ mMinimumValue.u.i64 = min;
+ mMaximumValue.u.i64 = max;
+ mStepSize.u.i64 = step;
+ break;
+ case MTP_TYPE_UINT64:
+ mMinimumValue.u.u64 = min;
+ mMaximumValue.u.u64 = max;
+ mStepSize.u.u64 = step;
+ break;
+ default:
+ LOGE("unsupported type for MtpProperty::setRange");
+ break;
+ }
+}
+
+void MtpProperty::setFormEnum(const int* values, int count) {
+ mFormFlag = kFormEnum;
+ delete[] mEnumValues;
+ mEnumValues = new MtpPropertyValue[count];
+ mEnumLength = count;
+
+ for (int i = 0; i < count; i++) {
+ int value = *values++;
+ switch (mType) {
+ case MTP_TYPE_INT8:
+ mEnumValues[i].u.i8 = value;
+ break;
+ case MTP_TYPE_UINT8:
+ mEnumValues[i].u.u8 = value;
+ break;
+ case MTP_TYPE_INT16:
+ mEnumValues[i].u.i16 = value;
+ break;
+ case MTP_TYPE_UINT16:
+ mEnumValues[i].u.u16 = value;
+ break;
+ case MTP_TYPE_INT32:
+ mEnumValues[i].u.i32 = value;
+ break;
+ case MTP_TYPE_UINT32:
+ mEnumValues[i].u.u32 = value;
+ break;
+ case MTP_TYPE_INT64:
+ mEnumValues[i].u.i64 = value;
+ break;
+ case MTP_TYPE_UINT64:
+ mEnumValues[i].u.u64 = value;
+ break;
+ default:
+ LOGE("unsupported type for MtpProperty::setEnum");
+ break;
+ }
+ }
+}
+
void MtpProperty::print() {
LOGV("MtpProperty %04X\n", mCode);
LOGV(" type %04X\n", mType);
diff --git a/media/mtp/MtpProperty.h b/media/mtp/MtpProperty.h
index 98b465ac76ac..c12399c04fc6 100644
--- a/media/mtp/MtpProperty.h
+++ b/media/mtp/MtpProperty.h
@@ -88,6 +88,9 @@ public:
void setDefaultValue(const uint16_t* string);
void setCurrentValue(const uint16_t* string);
+ void setFormRange(int min, int max, int step);
+ void setFormEnum(const int* values, int count);
+
void print();
inline bool isDeviceProperty() const {