summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-11-10 09:57:34 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-10 09:57:34 -0800
commitf1094227f8efc04351b25d7095c36c6a4d8d033c (patch)
tree91cc2bb7220d363d9663a03a88e69802c6060b0e /media
parent5d4c6226caddfb5fa1cee71aa6f90e24e56e53c0 (diff)
parent83cff86dcd5b137fd21f765f35736cf313a89ae1 (diff)
downloadframeworks_base-f1094227f8efc04351b25d7095c36c6a4d8d033c.zip
frameworks_base-f1094227f8efc04351b25d7095c36c6a4d8d033c.tar.gz
frameworks_base-f1094227f8efc04351b25d7095c36c6a4d8d033c.tar.bz2
Merge changes I49b383d3,I70809401
* changes: MTP: Don't dump data packets twice in debug output. Add support for range and enum forms in MTP ObjectPropDescs
Diffstat (limited to 'media')
-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 ec78ff0..20dd94d 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 d6b107d..3416807 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 bbd0237..f7c12d6 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 98b465a..c12399c 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 {