Loading media/mtp/MtpDevice.cpp +20 −1 Original line number Diff line number Diff line Loading @@ -611,7 +611,7 @@ MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectForma return NULL; if (!readData()) return NULL; MtpResponseCode ret = readResponse(); const MtpResponseCode ret = readResponse(); if (ret == MTP_RESPONSE_OK) { MtpProperty* property = new MtpProperty; if (property->read(mData)) Loading @@ -622,6 +622,25 @@ MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectForma return NULL; } bool MtpDevice::getObjectPropValue(MtpObjectHandle handle, MtpProperty* property) { if (property == nullptr) return false; Mutex::Autolock autoLock(mMutex); mRequest.reset(); mRequest.setParameter(1, handle); mRequest.setParameter(2, property->getPropertyCode()); if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROP_VALUE)) return false; if (!readData()) return false; if (readResponse() != MTP_RESPONSE_OK) return false; property->setCurrentValue(mData); return true; } bool MtpDevice::readObject(MtpObjectHandle handle, ReadObjectCallback callback, uint32_t expectedLength, Loading media/mtp/MtpDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,9 @@ public: MtpProperty* getDevicePropDesc(MtpDeviceProperty code); MtpProperty* getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format); // Reads value of |property| for |handle|. Returns true on success. bool getObjectPropValue(MtpObjectHandle handle, MtpProperty* property); bool readObject(MtpObjectHandle handle, ReadObjectCallback callback, uint32_t objectSize, void* clientData); bool readObject(MtpObjectHandle handle, const char* destPath, int group, Loading media/mtp/MtpProperty.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,12 @@ void MtpProperty::setCurrentValue(const uint16_t* string) { mCurrentValue.str = NULL; } void MtpProperty::setCurrentValue(MtpDataPacket& packet) { free(mCurrentValue.str); mCurrentValue.str = NULL; readValue(packet, mCurrentValue); } void MtpProperty::setFormRange(int min, int max, int step) { mFormFlag = kFormRange; switch (mType) { Loading media/mtp/MtpProperty.h +4 −1 Original line number Diff line number Diff line Loading @@ -81,13 +81,16 @@ public: int defaultValue = 0); virtual ~MtpProperty(); inline MtpPropertyCode getPropertyCode() const { return mCode; } MtpPropertyCode getPropertyCode() const { return mCode; } MtpDataType getDataType() const { return mType; } bool read(MtpDataPacket& packet); void write(MtpDataPacket& packet); void setDefaultValue(const uint16_t* string); void setCurrentValue(const uint16_t* string); void setCurrentValue(MtpDataPacket& packet); const MtpPropertyValue& getCurrentValue() { return mCurrentValue; } void setFormRange(int min, int max, int step); void setFormEnum(const int* values, int count); Loading Loading
media/mtp/MtpDevice.cpp +20 −1 Original line number Diff line number Diff line Loading @@ -611,7 +611,7 @@ MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectForma return NULL; if (!readData()) return NULL; MtpResponseCode ret = readResponse(); const MtpResponseCode ret = readResponse(); if (ret == MTP_RESPONSE_OK) { MtpProperty* property = new MtpProperty; if (property->read(mData)) Loading @@ -622,6 +622,25 @@ MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectForma return NULL; } bool MtpDevice::getObjectPropValue(MtpObjectHandle handle, MtpProperty* property) { if (property == nullptr) return false; Mutex::Autolock autoLock(mMutex); mRequest.reset(); mRequest.setParameter(1, handle); mRequest.setParameter(2, property->getPropertyCode()); if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROP_VALUE)) return false; if (!readData()) return false; if (readResponse() != MTP_RESPONSE_OK) return false; property->setCurrentValue(mData); return true; } bool MtpDevice::readObject(MtpObjectHandle handle, ReadObjectCallback callback, uint32_t expectedLength, Loading
media/mtp/MtpDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,9 @@ public: MtpProperty* getDevicePropDesc(MtpDeviceProperty code); MtpProperty* getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format); // Reads value of |property| for |handle|. Returns true on success. bool getObjectPropValue(MtpObjectHandle handle, MtpProperty* property); bool readObject(MtpObjectHandle handle, ReadObjectCallback callback, uint32_t objectSize, void* clientData); bool readObject(MtpObjectHandle handle, const char* destPath, int group, Loading
media/mtp/MtpProperty.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,12 @@ void MtpProperty::setCurrentValue(const uint16_t* string) { mCurrentValue.str = NULL; } void MtpProperty::setCurrentValue(MtpDataPacket& packet) { free(mCurrentValue.str); mCurrentValue.str = NULL; readValue(packet, mCurrentValue); } void MtpProperty::setFormRange(int min, int max, int step) { mFormFlag = kFormRange; switch (mType) { Loading
media/mtp/MtpProperty.h +4 −1 Original line number Diff line number Diff line Loading @@ -81,13 +81,16 @@ public: int defaultValue = 0); virtual ~MtpProperty(); inline MtpPropertyCode getPropertyCode() const { return mCode; } MtpPropertyCode getPropertyCode() const { return mCode; } MtpDataType getDataType() const { return mType; } bool read(MtpDataPacket& packet); void write(MtpDataPacket& packet); void setDefaultValue(const uint16_t* string); void setCurrentValue(const uint16_t* string); void setCurrentValue(MtpDataPacket& packet); const MtpPropertyValue& getCurrentValue() { return mCurrentValue; } void setFormRange(int min, int max, int step); void setFormEnum(const int* values, int count); Loading