summaryrefslogtreecommitdiffstats
path: root/mtp/legacy
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mtp/legacy/Android.mk (renamed from mtp/Android.mk)34
-rw-r--r--mtp/legacy/MtpDataPacket.cpp (renamed from mtp/MtpDataPacket.cpp)0
-rw-r--r--mtp/legacy/MtpDataPacket.h123
-rw-r--r--mtp/legacy/MtpDatabase.h116
-rw-r--r--mtp/legacy/MtpDebug.cpp (renamed from mtp/MtpDebug.cpp)0
-rw-r--r--mtp/legacy/MtpDebug.h (renamed from mtp/MtpDebug.h)0
-rw-r--r--mtp/legacy/MtpDevice.cpp (renamed from mtp/MtpDevice.cpp)0
-rw-r--r--mtp/legacy/MtpDevice.h116
-rw-r--r--mtp/legacy/MtpDeviceInfo.cpp (renamed from mtp/MtpDeviceInfo.cpp)0
-rw-r--r--mtp/legacy/MtpDeviceInfo.h54
-rw-r--r--mtp/legacy/MtpEventPacket.cpp (renamed from mtp/MtpEventPacket.cpp)0
-rw-r--r--mtp/legacy/MtpEventPacket.h (renamed from mtp/MtpEventPacket.h)20
-rw-r--r--mtp/legacy/MtpMessage.hpp33
-rw-r--r--mtp/legacy/MtpObjectInfo.cpp (renamed from mtp/MtpObjectInfo.cpp)0
-rw-r--r--mtp/legacy/MtpObjectInfo.h60
-rw-r--r--mtp/legacy/MtpPacket.cpp (renamed from mtp/MtpPacket.cpp)0
-rw-r--r--mtp/legacy/MtpPacket.h72
-rw-r--r--mtp/legacy/MtpProperty.cpp (renamed from mtp/MtpProperty.cpp)0
-rw-r--r--mtp/legacy/MtpProperty.h114
-rw-r--r--mtp/legacy/MtpRequestPacket.cpp (renamed from mtp/MtpRequestPacket.cpp)2
-rw-r--r--mtp/legacy/MtpRequestPacket.h (renamed from mtp/MtpRequestPacket.h)20
-rw-r--r--mtp/legacy/MtpResponsePacket.cpp (renamed from mtp/MtpResponsePacket.cpp)0
-rw-r--r--mtp/legacy/MtpResponsePacket.h (renamed from mtp/MtpResponsePacket.h)20
-rw-r--r--mtp/legacy/MtpServer.cpp (renamed from mtp/MtpServer.cpp)44
-rw-r--r--mtp/legacy/MtpServer.h155
-rw-r--r--mtp/legacy/MtpStorage.cpp (renamed from mtp/MtpStorage.cpp)10
-rw-r--r--mtp/legacy/MtpStorage.h (renamed from mtp/MtpStorage.h)56
-rw-r--r--mtp/legacy/MtpStorageInfo.cpp (renamed from mtp/MtpStorageInfo.cpp)0
-rw-r--r--mtp/legacy/MtpStorageInfo.h (renamed from mtp/MtpStorageInfo.h)28
-rw-r--r--mtp/legacy/MtpStringBuffer.cpp (renamed from mtp/MtpStringBuffer.cpp)0
-rw-r--r--mtp/legacy/MtpStringBuffer.h (renamed from mtp/MtpStringBuffer.h)34
-rw-r--r--mtp/legacy/MtpTypes.h (renamed from mtp/MtpTypes.h)0
-rw-r--r--mtp/legacy/MtpUtils.cpp (renamed from mtp/MtpUtils.cpp)0
-rw-r--r--mtp/legacy/MtpUtils.h (renamed from mtp/MtpUtils.h)0
-rw-r--r--mtp/legacy/btree.cpp (renamed from mtp/btree.cpp)0
-rw-r--r--mtp/legacy/btree.hpp82
-rw-r--r--mtp/legacy/mtp.h (renamed from mtp/mtp.h)0
-rw-r--r--mtp/legacy/mtp_MtpDatabase.cpp (renamed from mtp/mtp_MtpDatabase.cpp)0
-rw-r--r--mtp/legacy/mtp_MtpDatabase.hpp146
-rw-r--r--mtp/legacy/mtp_MtpServer.cpp (renamed from mtp/mtp_MtpServer.cpp)0
-rw-r--r--mtp/legacy/mtp_MtpServer.hpp (renamed from mtp/mtp_MtpServer.hpp)0
-rw-r--r--mtp/legacy/node.cpp (renamed from mtp/node.cpp)0
-rw-r--r--mtp/legacy/twrpMtp.cpp (renamed from mtp/twrpMtp.cpp)0
-rw-r--r--mtp/legacy/twrpMtp.hpp (renamed from mtp/twrpMtp.hpp)0
44 files changed, 1188 insertions, 151 deletions
diff --git a/mtp/Android.mk b/mtp/legacy/Android.mk
index 43649f794..cd04ac018 100644
--- a/mtp/Android.mk
+++ b/mtp/legacy/Android.mk
@@ -3,7 +3,7 @@ LOCAL_PATH := $(call my-dir)
# Build libtwrpmtp library
include $(CLEAR_VARS)
-LOCAL_MODULE := libtwrpmtp
+LOCAL_MODULE := libtwrpmtp-legacy
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -DMTP_DEVICE -DMTP_HOST -fno-strict-aliasing -Wno-unused-variable -Wno-format -Wno-unused-parameter -Wno-unused-private-field
LOCAL_C_INCLUDES += $(LOCAL_PATH) bionic frameworks/base/include system/core/include bionic/libc/private/
@@ -45,35 +45,3 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0)
endif
include $(BUILD_SHARED_LIBRARY)
-
-# Build twrpmtp binary / executable
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := twrpmtp
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -DMTP_DEVICE -DMTP_HOST -DTWRPMTP
-LOCAL_C_INCLUDES += $(LOCAL_PATH) bionic frameworks/base/include system/core/include bionic/libc/private/
-LOCAL_SRC_FILES = \
- btree.cpp \
- MtpDataPacket.cpp \
- MtpDebug.cpp \
- MtpDevice.cpp \
- MtpDeviceInfo.cpp \
- MtpEventPacket.cpp \
- MtpObjectInfo.cpp \
- MtpPacket.cpp \
- MtpProperty.cpp \
- MtpRequestPacket.cpp \
- MtpResponsePacket.cpp \
- MtpServer.cpp \
- MtpStorage.cpp \
- MtpStorageInfo.cpp \
- MtpStringBuffer.cpp \
- MtpUtils.cpp \
- mtp_MtpServer.cpp \
- twrpMtp.cpp \
- mtp_MtpDatabase.cpp \
- node.cpp
-LOCAL_SHARED_LIBRARIES += libz libc libusbhost libstdc++ libdl libcutils libutils libaosprecovery
-include $(BUILD_EXECUTABLE)
diff --git a/mtp/MtpDataPacket.cpp b/mtp/legacy/MtpDataPacket.cpp
index 845db968e..845db968e 100644
--- a/mtp/MtpDataPacket.cpp
+++ b/mtp/legacy/MtpDataPacket.cpp
diff --git a/mtp/legacy/MtpDataPacket.h b/mtp/legacy/MtpDataPacket.h
new file mode 100644
index 000000000..5ad440d7f
--- /dev/null
+++ b/mtp/legacy/MtpDataPacket.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++
+ *
+ */
+
+#ifndef _MTP_DATA_PACKET_H
+#define _MTP_DATA_PACKET_H
+
+#include "MtpPacket.h"
+#include "mtp.h"
+
+struct usb_device;
+struct usb_request;
+
+
+class MtpStringBuffer;
+
+class MtpDataPacket : public MtpPacket {
+private:
+ // current offset for get/put methods
+ uint64_t mOffset;
+
+public:
+ MtpDataPacket();
+ virtual ~MtpDataPacket();
+
+ virtual void reset();
+
+ void setOperationCode(MtpOperationCode code);
+ void setTransactionID(MtpTransactionID id);
+
+ inline const uint8_t* getData() const { return mBuffer + MTP_CONTAINER_HEADER_SIZE; }
+ inline uint8_t getUInt8() { return (uint8_t)mBuffer[mOffset++]; }
+ inline int8_t getInt8() { return (int8_t)mBuffer[mOffset++]; }
+ uint16_t getUInt16();
+ inline int16_t getInt16() { return (int16_t)getUInt16(); }
+ uint32_t getUInt32();
+ inline int32_t getInt32() { return (int32_t)getUInt32(); }
+ uint64_t getUInt64();
+ inline int64_t getInt64() { return (int64_t)getUInt64(); }
+ void getUInt128(uint128_t& value);
+ inline void getInt128(int128_t& value) { getUInt128((uint128_t&)value); }
+ void getString(MtpStringBuffer& string);
+
+ Int8List* getAInt8();
+ UInt8List* getAUInt8();
+ Int16List* getAInt16();
+ UInt16List* getAUInt16();
+ Int32List* getAInt32();
+ UInt32List* getAUInt32();
+ Int64List* getAInt64();
+ UInt64List* getAUInt64();
+
+ void putInt8(int8_t value);
+ void putUInt8(uint8_t value);
+ void putInt16(int16_t value);
+ void putUInt16(uint16_t value);
+ void putInt32(int32_t value);
+ void putUInt32(uint32_t value);
+ void putInt64(int64_t value);
+ void putUInt64(uint64_t value);
+ void putInt128(const int128_t& value);
+ void putUInt128(const uint128_t& value);
+ void putInt128(int64_t value);
+ void putUInt128(uint64_t value);
+
+ void putAInt8(const int8_t* values, int count);
+ void putAUInt8(const uint8_t* values, int count);
+ void putAInt16(const int16_t* values, int count);
+ void putAUInt16(const uint16_t* values, int count);
+ void putAUInt16(const UInt16List* values);
+ void putAInt32(const int32_t* values, int count);
+ void putAUInt32(const uint32_t* values, int count);
+ void putAUInt32(const UInt32List* list);
+ void putAInt64(const int64_t* values, int count);
+ void putAUInt64(const uint64_t* values, int count);
+ void putString(const MtpStringBuffer& string);
+ void putString(const char* string);
+ void putString(const uint16_t* string);
+ inline void putEmptyString() { putUInt8(0); }
+ inline void putEmptyArray() { putUInt32(0); }
+
+
+#ifdef MTP_DEVICE
+ // fill our buffer with data from the given file descriptor
+ int read(int fd);
+
+ // write our data to the given file descriptor
+ int write(int fd);
+ int writeData(int fd, void* data, uint32_t length);
+#endif
+#ifdef MTP_HOST
+ int read(struct usb_request *request);
+ int readData(struct usb_request *request, void* buffer, int length);
+ int readDataAsync(struct usb_request *req);
+ int readDataWait(struct usb_device *device);
+ int readDataHeader(struct usb_request *ep);
+
+ int writeDataHeader(struct usb_request *ep, uint32_t length);
+ int write(struct usb_request *ep);
+ int write(struct usb_request *ep, void* buffer, uint32_t length);
+#endif
+ inline bool hasData() const { return mPacketSize > MTP_CONTAINER_HEADER_SIZE; }
+ inline uint32_t getContainerLength() const { return MtpPacket::getUInt32(MTP_CONTAINER_LENGTH_OFFSET); }
+ void* getData(int& outLength) const;
+};
+
+
+#endif // _MTP_DATA_PACKET_H
diff --git a/mtp/legacy/MtpDatabase.h b/mtp/legacy/MtpDatabase.h
new file mode 100644
index 000000000..f7f33ffb5
--- /dev/null
+++ b/mtp/legacy/MtpDatabase.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++
+ */
+
+#ifndef _MTP_DATABASE_H
+#define _MTP_DATABASE_H
+
+#include "MtpTypes.h"
+
+class MtpDataPacket;
+class MtpProperty;
+class MtpObjectInfo;
+
+class MtpDatabase {
+public:
+ virtual ~MtpDatabase() {}
+
+ // called from SendObjectInfo to reserve a database entry for the incoming file
+ virtual MtpObjectHandle beginSendObject(const char* path,
+ MtpObjectFormat format,
+ MtpObjectHandle parent,
+ MtpStorageID storage,
+ uint64_t size,
+ time_t modified) = 0;
+
+ // called to report success or failure of the SendObject file transfer
+ // success should signal a notification of the new object's creation,
+ // failure should remove the database entry created in beginSendObject
+ virtual void endSendObject(const char* path,
+ MtpObjectHandle handle,
+ MtpObjectFormat format,
+ bool succeeded) = 0;
+
+ virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID,
+ MtpObjectFormat format,
+ MtpObjectHandle parent) = 0;
+
+ virtual int getNumObjects(MtpStorageID storageID,
+ MtpObjectFormat format,
+ MtpObjectHandle parent) = 0;
+
+ // callee should delete[] the results from these
+ // results can be NULL
+ virtual MtpObjectFormatList* getSupportedPlaybackFormats() = 0;
+ virtual MtpObjectFormatList* getSupportedCaptureFormats() = 0;
+ virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format) = 0;
+ virtual MtpDevicePropertyList* getSupportedDeviceProperties() = 0;
+
+ virtual void createDB(MtpStorage* storage, MtpStorageID storageID) = 0;
+ virtual void destroyDB(MtpStorageID storageID) = 0;
+
+ virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle,
+ MtpObjectProperty property,
+ MtpDataPacket& packet) = 0;
+
+ virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle,
+ MtpObjectProperty property,
+ MtpDataPacket& packet) = 0;
+
+ virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property,
+ MtpDataPacket& packet) = 0;
+
+ virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property,
+ MtpDataPacket& packet) = 0;
+
+ virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property) = 0;
+
+ virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle,
+ uint32_t format, uint32_t property,
+ int groupCode, int depth,
+ MtpDataPacket& packet) = 0;
+
+ virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle,
+ MtpObjectInfo& info) = 0;
+
+ virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) = 0;
+
+ virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle,
+ MtpString& outFilePath,
+ int64_t& outFileLength,
+ MtpObjectFormat& outFormat) = 0;
+
+ virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0;
+
+ virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0;
+
+ virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle,
+ MtpObjectHandleList* references) = 0;
+
+ virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property,
+ MtpObjectFormat format) = 0;
+
+ virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property) = 0;
+
+ virtual void sessionStarted() = 0;
+
+ virtual void sessionEnded() = 0;
+ virtual void lockMutex() = 0;
+ virtual void unlockMutex() = 0;
+};
+
+#endif // _MTP_DATABASE_H
diff --git a/mtp/MtpDebug.cpp b/mtp/legacy/MtpDebug.cpp
index c986923db..c986923db 100644
--- a/mtp/MtpDebug.cpp
+++ b/mtp/legacy/MtpDebug.cpp
diff --git a/mtp/MtpDebug.h b/mtp/legacy/MtpDebug.h
index 073ddcc83..073ddcc83 100644
--- a/mtp/MtpDebug.h
+++ b/mtp/legacy/MtpDebug.h
diff --git a/mtp/MtpDevice.cpp b/mtp/legacy/MtpDevice.cpp
index 089fc2272..089fc2272 100644
--- a/mtp/MtpDevice.cpp
+++ b/mtp/legacy/MtpDevice.cpp
diff --git a/mtp/legacy/MtpDevice.h b/mtp/legacy/MtpDevice.h
new file mode 100644
index 000000000..34b39ecbd
--- /dev/null
+++ b/mtp/legacy/MtpDevice.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_DEVICE_H
+#define _MTP_DEVICE_H
+
+#include "MtpRequestPacket.h"
+#include "MtpDataPacket.h"
+#include "MtpResponsePacket.h"
+#include "MtpTypes.h"
+
+#include <utils/threads.h>
+
+struct usb_device;
+struct usb_request;
+struct usb_endpoint_descriptor;
+
+
+class MtpDeviceInfo;
+class MtpObjectInfo;
+class MtpStorageInfo;
+
+class MtpDevice {
+private:
+ struct usb_device* mDevice;
+ int mInterface;
+ struct usb_request* mRequestIn1;
+ struct usb_request* mRequestIn2;
+ struct usb_request* mRequestOut;
+ struct usb_request* mRequestIntr;
+ MtpDeviceInfo* mDeviceInfo;
+ MtpPropertyList mDeviceProperties;
+
+ // current session ID
+ MtpSessionID mSessionID;
+ // current transaction ID
+ MtpTransactionID mTransactionID;
+
+ MtpRequestPacket mRequest;
+ MtpDataPacket mData;
+ MtpResponsePacket mResponse;
+ // set to true if we received a response packet instead of a data packet
+ bool mReceivedResponse;
+
+ // to ensure only one MTP transaction at a time
+ android::Mutex mMutex;
+
+public:
+ MtpDevice(struct usb_device* device, int interface,
+ const struct usb_endpoint_descriptor *ep_in,
+ const struct usb_endpoint_descriptor *ep_out,
+ const struct usb_endpoint_descriptor *ep_intr);
+
+ static MtpDevice* open(const char* deviceName, int fd);
+
+ virtual ~MtpDevice();
+
+ void initialize();
+ void close();
+ void print();
+ const char* getDeviceName();
+
+ bool openSession();
+ bool closeSession();
+
+ MtpDeviceInfo* getDeviceInfo();
+ MtpStorageIDList* getStorageIDs();
+ MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
+ MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format,
+ MtpObjectHandle parent);
+ MtpObjectInfo* getObjectInfo(MtpObjectHandle handle);
+ void* getThumbnail(MtpObjectHandle handle, int& outLength);
+ MtpObjectHandle sendObjectInfo(MtpObjectInfo* info);
+ bool sendObject(MtpObjectInfo* info, int srcFD);
+ bool deleteObject(MtpObjectHandle handle);
+ MtpObjectHandle getParent(MtpObjectHandle handle);
+ MtpObjectHandle getStorageID(MtpObjectHandle handle);
+
+ MtpObjectPropertyList* getObjectPropsSupported(MtpObjectFormat format);
+
+ MtpProperty* getDevicePropDesc(MtpDeviceProperty code);
+ MtpProperty* getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format);
+
+ bool readObject(MtpObjectHandle handle,
+ bool (* callback)(void* data, int offset,
+ int length, void* clientData),
+ int objectSize, void* clientData);
+ bool readObject(MtpObjectHandle handle, const char* destPath, int group,
+ int perm);
+
+private:
+ bool sendRequest(MtpOperationCode operation);
+ bool sendData();
+ bool readData();
+ bool writeDataHeader(MtpOperationCode operation, int dataLength);
+ MtpResponseCode readResponse();
+
+};
+
+
+#endif // _MTP_DEVICE_H
diff --git a/mtp/MtpDeviceInfo.cpp b/mtp/legacy/MtpDeviceInfo.cpp
index 337cc130d..337cc130d 100644
--- a/mtp/MtpDeviceInfo.cpp
+++ b/mtp/legacy/MtpDeviceInfo.cpp
diff --git a/mtp/legacy/MtpDeviceInfo.h b/mtp/legacy/MtpDeviceInfo.h
new file mode 100644
index 000000000..264e199dd
--- /dev/null
+++ b/mtp/legacy/MtpDeviceInfo.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_DEVICE_INFO_H
+#define _MTP_DEVICE_INFO_H
+
+struct stat;
+
+
+class MtpDataPacket;
+
+class MtpDeviceInfo {
+public:
+ uint16_t mStandardVersion;
+ uint32_t mVendorExtensionID;
+ uint16_t mVendorExtensionVersion;
+ char* mVendorExtensionDesc;
+ uint16_t mFunctionalCode;
+ UInt16List* mOperations;
+ UInt16List* mEvents;
+ MtpDevicePropertyList* mDeviceProperties;
+ MtpObjectFormatList* mCaptureFormats;
+ MtpObjectFormatList* mPlaybackFormats;
+ char* mManufacturer;
+ char* mModel;
+ char* mVersion;
+ char* mSerial;
+
+public:
+ MtpDeviceInfo();
+ virtual ~MtpDeviceInfo();
+
+ void read(MtpDataPacket& packet);
+
+ void print();
+};
+
+
+#endif // _MTP_DEVICE_INFO_H
diff --git a/mtp/MtpEventPacket.cpp b/mtp/legacy/MtpEventPacket.cpp
index 1119f7d53..1119f7d53 100644
--- a/mtp/MtpEventPacket.cpp
+++ b/mtp/legacy/MtpEventPacket.cpp
diff --git a/mtp/MtpEventPacket.h b/mtp/legacy/MtpEventPacket.h
index b42abceaf..64398560d 100644
--- a/mtp/MtpEventPacket.h
+++ b/mtp/legacy/MtpEventPacket.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,22 +25,22 @@
class MtpEventPacket : public MtpPacket {
public:
- MtpEventPacket();
- virtual ~MtpEventPacket();
+ MtpEventPacket();
+ virtual ~MtpEventPacket();
#ifdef MTP_DEVICE
- // write our data to the given file descriptor
- int write(int fd);
+ // write our data to the given file descriptor
+ int write(int fd);
#endif
#ifdef MTP_HOST
- // read our buffer with the given request
- int read(struct usb_request *request);
+ // read our buffer with the given request
+ int read(struct usb_request *request);
#endif
- inline MtpEventCode getEventCode() const { return getContainerCode(); }
- inline void setEventCode(MtpEventCode code)
- { return setContainerCode(code); }
+ inline MtpEventCode getEventCode() const { return getContainerCode(); }
+ inline void setEventCode(MtpEventCode code)
+ { return setContainerCode(code); }
};
#endif // _MTP_EVENT_PACKET_H
diff --git a/mtp/legacy/MtpMessage.hpp b/mtp/legacy/MtpMessage.hpp
new file mode 100644
index 000000000..31465d8c6
--- /dev/null
+++ b/mtp/legacy/MtpMessage.hpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTPMESSAGE_HPP
+#define _MTPMESSAGE_HPP
+
+#define MTP_MESSAGE_ADD_STORAGE 1
+#define MTP_MESSAGE_REMOVE_STORAGE 2
+
+struct mtpmsg {
+ int message_type; // 1 is add, 2 is remove, see above
+ unsigned int storage_id;
+ char display[1024];
+ char path[1024];
+ uint64_t maxFileSize;
+};
+
+#endif //_MTPMESSAGE_HPP
diff --git a/mtp/MtpObjectInfo.cpp b/mtp/legacy/MtpObjectInfo.cpp
index 50192d730..50192d730 100644
--- a/mtp/MtpObjectInfo.cpp
+++ b/mtp/legacy/MtpObjectInfo.cpp
diff --git a/mtp/legacy/MtpObjectInfo.h b/mtp/legacy/MtpObjectInfo.h
new file mode 100644
index 000000000..9b023bcee
--- /dev/null
+++ b/mtp/legacy/MtpObjectInfo.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_OBJECT_INFO_H
+#define _MTP_OBJECT_INFO_H
+
+#include "MtpTypes.h"
+
+
+class MtpDataPacket;
+
+class MtpObjectInfo {
+public:
+ MtpObjectHandle mHandle;
+ MtpStorageID mStorageID;
+ MtpObjectFormat mFormat;
+ uint16_t mProtectionStatus;
+ uint32_t mCompressedSize;
+ MtpObjectFormat mThumbFormat;
+ uint32_t mThumbCompressedSize;
+ uint32_t mThumbPixWidth;
+ uint32_t mThumbPixHeight;
+ uint32_t mImagePixWidth;
+ uint32_t mImagePixHeight;
+ uint32_t mImagePixDepth;
+ MtpObjectHandle mParent;
+ uint16_t mAssociationType;
+ uint32_t mAssociationDesc;
+ uint32_t mSequenceNumber;
+ char* mName;
+ time_t mDateCreated;
+ time_t mDateModified;
+ char* mKeywords;
+
+public:
+ MtpObjectInfo(MtpObjectHandle handle);
+ virtual ~MtpObjectInfo();
+
+ void read(MtpDataPacket& packet);
+
+ void print();
+};
+
+
+#endif // _MTP_OBJECT_INFO_H
diff --git a/mtp/MtpPacket.cpp b/mtp/legacy/MtpPacket.cpp
index 2f9e438ba..2f9e438ba 100644
--- a/mtp/MtpPacket.cpp
+++ b/mtp/legacy/MtpPacket.cpp
diff --git a/mtp/legacy/MtpPacket.h b/mtp/legacy/MtpPacket.h
new file mode 100644
index 000000000..be3db3091
--- /dev/null
+++ b/mtp/legacy/MtpPacket.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_PACKET_H
+#define _MTP_PACKET_H
+
+#include "MtpTypes.h"
+
+struct usb_request;
+
+
+class MtpPacket {
+
+protected:
+ uint8_t* mBuffer;
+ // current size of the buffer
+ int mBufferSize;
+ // number of bytes to add when resizing the buffer
+ int mAllocationIncrement;
+ // size of the data in the packet
+ unsigned mPacketSize;
+
+public:
+ MtpPacket(int bufferSize);
+ virtual ~MtpPacket();
+
+ // sets packet size to the default container size and sets buffer to zero
+ virtual void reset();
+
+ void allocate(int length);
+ void dump();
+ void copyFrom(const MtpPacket& src);
+
+ uint16_t getContainerCode() const;
+ void setContainerCode(uint16_t code);
+
+ uint16_t getContainerType() const;
+
+ MtpTransactionID getTransactionID() const;
+ void setTransactionID(MtpTransactionID id);
+
+ uint32_t getParameter(int index) const;
+ void setParameter(int index, uint32_t value);
+
+#ifdef MTP_HOST
+ int transfer(struct usb_request* request);
+#endif
+
+protected:
+ uint16_t getUInt16(int offset) const;
+ uint32_t getUInt32(int offset) const;
+ void putUInt16(int offset, uint16_t value);
+ void putUInt32(int offset, uint32_t value);
+};
+
+
+#endif // _MTP_PACKET_H
diff --git a/mtp/MtpProperty.cpp b/mtp/legacy/MtpProperty.cpp
index e105f2497..e105f2497 100644
--- a/mtp/MtpProperty.cpp
+++ b/mtp/legacy/MtpProperty.cpp
diff --git a/mtp/legacy/MtpProperty.h b/mtp/legacy/MtpProperty.h
new file mode 100644
index 000000000..c1f323380
--- /dev/null
+++ b/mtp/legacy/MtpProperty.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_PROPERTY_H
+#define _MTP_PROPERTY_H
+
+#include "MtpTypes.h"
+
+
+class MtpDataPacket;
+
+struct MtpPropertyValue {
+ union {
+ int8_t i8;
+ uint8_t u8;
+ int16_t i16;
+ uint16_t u16;
+ int32_t i32;
+ uint32_t u32;
+ int64_t i64;
+ uint64_t u64;
+ int128_t i128;
+ uint128_t u128;
+ } u;
+ // string in UTF8 format
+ char* str;
+};
+
+class MtpProperty {
+public:
+ MtpPropertyCode mCode;
+ MtpDataType mType;
+ bool mWriteable;
+ MtpPropertyValue mDefaultValue;
+ MtpPropertyValue mCurrentValue;
+
+ // for array types
+ int mDefaultArrayLength;
+ MtpPropertyValue* mDefaultArrayValues;
+ int mCurrentArrayLength;
+ MtpPropertyValue* mCurrentArrayValues;
+
+ enum {
+ kFormNone = 0,
+ kFormRange = 1,
+ kFormEnum = 2,
+ kFormDateTime = 3,
+ };
+
+ uint32_t mGroupCode;
+ uint8_t mFormFlag;
+
+ // for range form
+ MtpPropertyValue mMinimumValue;
+ MtpPropertyValue mMaximumValue;
+ MtpPropertyValue mStepSize;
+
+ // for enum form
+ int mEnumLength;
+ MtpPropertyValue* mEnumValues;
+
+public:
+ MtpProperty();
+ MtpProperty(MtpPropertyCode propCode,
+ MtpDataType type,
+ bool writeable = false,
+ int defaultValue = 0);
+ virtual ~MtpProperty();
+
+ inline MtpPropertyCode getPropertyCode() const { return mCode; }
+
+ void read(MtpDataPacket& packet);
+ void write(MtpDataPacket& packet);
+
+ 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 setFormDateTime();
+
+ void print();
+ void print(MtpPropertyValue& value, MtpString& buffer);
+
+ inline bool isDeviceProperty() const {
+ return ( ((mCode & 0xF000) == 0x5000)
+ || ((mCode & 0xF800) == 0xD000));
+ }
+
+private:
+ void readValue(MtpDataPacket& packet, MtpPropertyValue& value);
+ void writeValue(MtpDataPacket& packet, MtpPropertyValue& value);
+ MtpPropertyValue* readArrayValues(MtpDataPacket& packet, int& length);
+ void writeArrayValues(MtpDataPacket& packet,
+ MtpPropertyValue* values, int length);
+};
+
+
+#endif // _MTP_PROPERTY_H
diff --git a/mtp/MtpRequestPacket.cpp b/mtp/legacy/MtpRequestPacket.cpp
index 754e205aa..e700e3b2b 100644
--- a/mtp/MtpRequestPacket.cpp
+++ b/mtp/legacy/MtpRequestPacket.cpp
@@ -36,9 +36,7 @@ MtpRequestPacket::~MtpRequestPacket() {
#ifdef MTP_DEVICE
int MtpRequestPacket::read(int fd) {
- MTPD("block1 fd: %d\n", fd);
int ret = ::read(fd, mBuffer, mBufferSize);
- MTPD("block2\n");
if (ret >= 0)
mPacketSize = ret;
else
diff --git a/mtp/MtpRequestPacket.h b/mtp/legacy/MtpRequestPacket.h
index 8551dded0..dcf00d6ec 100644
--- a/mtp/MtpRequestPacket.h
+++ b/mtp/legacy/MtpRequestPacket.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,21 +28,21 @@ struct usb_request;
class MtpRequestPacket : public MtpPacket {
public:
- MtpRequestPacket();
- virtual ~MtpRequestPacket();
+ MtpRequestPacket();
+ virtual ~MtpRequestPacket();
#ifdef MTP_DEVICE
- // fill our buffer with data from the given file descriptor
- int read(int fd);
+ // fill our buffer with data from the given file descriptor
+ int read(int fd);
#endif
#ifdef MTP_HOST
- // write our buffer to the given endpoint
- int write(struct usb_request *request);
+ // write our buffer to the given endpoint
+ int write(struct usb_request *request);
#endif
- inline MtpOperationCode getOperationCode() const { return getContainerCode(); }
- inline void setOperationCode(MtpOperationCode code)
- { return setContainerCode(code); }
+ inline MtpOperationCode getOperationCode() const { return getContainerCode(); }
+ inline void setOperationCode(MtpOperationCode code)
+ { return setContainerCode(code); }
};
diff --git a/mtp/MtpResponsePacket.cpp b/mtp/legacy/MtpResponsePacket.cpp
index 8eed13a14..8eed13a14 100644
--- a/mtp/MtpResponsePacket.cpp
+++ b/mtp/legacy/MtpResponsePacket.cpp
diff --git a/mtp/MtpResponsePacket.h b/mtp/legacy/MtpResponsePacket.h
index 749b5344a..f9621aac3 100644
--- a/mtp/MtpResponsePacket.h
+++ b/mtp/legacy/MtpResponsePacket.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,22 +26,22 @@
class MtpResponsePacket : public MtpPacket {
public:
- MtpResponsePacket();
- virtual ~MtpResponsePacket();
+ MtpResponsePacket();
+ virtual ~MtpResponsePacket();
#ifdef MTP_DEVICE
- // write our data to the given file descriptor
- int write(int fd);
+ // write our data to the given file descriptor
+ int write(int fd);
#endif
#ifdef MTP_HOST
- // read our buffer with the given request
- int read(struct usb_request *request);
+ // read our buffer with the given request
+ int read(struct usb_request *request);
#endif
- inline MtpResponseCode getResponseCode() const { return getContainerCode(); }
- inline void setResponseCode(MtpResponseCode code)
- { return setContainerCode(code); }
+ inline MtpResponseCode getResponseCode() const { return getContainerCode(); }
+ inline void setResponseCode(MtpResponseCode code)
+ { return setContainerCode(code); }
};
diff --git a/mtp/MtpServer.cpp b/mtp/legacy/MtpServer.cpp
index 11eca86bc..c4e1cd3ae 100644
--- a/mtp/MtpServer.cpp
+++ b/mtp/legacy/MtpServer.cpp
@@ -25,8 +25,8 @@
#include <errno.h>
#include <sys/stat.h>
#include <dirent.h>
-#include "../twcommon.h"
-#include "../set_metadata.h"
+#include "../../twcommon.h"
+#include "../../set_metadata.h"
#include <cutils/properties.h>
#include "MtpTypes.h"
@@ -383,7 +383,7 @@ bool MtpServer::handleRequest() {
MTPD("doGetStorageIDs()\n");
response = doGetStorageIDs();
break;
- case MTP_OPERATION_GET_STORAGE_INFO:
+ case MTP_OPERATION_GET_STORAGE_INFO:
MTPD("about to call doGetStorageInfo()\n");
response = doGetStorageInfo();
break;
@@ -527,7 +527,7 @@ MtpResponseCode MtpServer::doGetDeviceInfo() {
sizeof(kSupportedEventCodes) / sizeof(uint16_t)); // Events Supported
mData.putAUInt16(deviceProperties); // Device Properties Supported
mData.putAUInt16(captureFormats); // Capture Formats
- mData.putAUInt16(playbackFormats); // Playback Formats
+ mData.putAUInt16(playbackFormats); // Playback Formats
property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");
MTPD("prop: %s\n", prop_value);
@@ -824,7 +824,7 @@ MtpResponseCode MtpServer::doGetObjectInfo() {
mData.putString(info.mName);
mData.putEmptyString(); // date created
formatDateTime(info.mDateModified, date, sizeof(date));
- mData.putString(date); // date modified
+ mData.putString(date); // date modified
mData.putEmptyString(); // keywords
}
return result;
@@ -846,7 +846,7 @@ MtpResponseCode MtpServer::doGetObject() {
const char* filePath = (const char *)pathBuf;
MTPD("filePath: %s\n", filePath);
- mtp_file_range mfr;
+ mtp_file_range mfr;
mfr.fd = open(filePath, O_RDONLY);
if (mfr.fd < 0) {
return MTP_RESPONSE_GENERAL_ERROR;
@@ -918,7 +918,7 @@ MtpResponseCode MtpServer::doGetPartialObject(MtpOperationCode operation) {
length = fileLength - offset;
const char* filePath = (const char *)pathBuf;
- mtp_file_range mfr;
+ mtp_file_range mfr;
mfr.fd = open(filePath, O_RDONLY);
if (mfr.fd < 0) {
return MTP_RESPONSE_GENERAL_ERROR;
@@ -971,21 +971,21 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
}
// read only the fields we need
- mData.getUInt32(); // storage ID
+ mData.getUInt32(); // storage ID
MtpObjectFormat format = mData.getUInt16();
- mData.getUInt16(); // protection status
+ mData.getUInt16(); // protection status
mSendObjectFileSize = mData.getUInt32();
- mData.getUInt16(); // thumb format
- mData.getUInt32(); // thumb compressed size
- mData.getUInt32(); // thumb pix width
- mData.getUInt32(); // thumb pix height
- mData.getUInt32(); // image pix width
- mData.getUInt32(); // image pix height
- mData.getUInt32(); // image bit depth
- mData.getUInt32(); // parent
+ mData.getUInt16(); // thumb format
+ mData.getUInt32(); // thumb compressed size
+ mData.getUInt32(); // thumb pix width
+ mData.getUInt32(); // thumb pix height
+ mData.getUInt32(); // image pix width
+ mData.getUInt32(); // image pix height
+ mData.getUInt32(); // image bit depth
+ mData.getUInt32(); // parent
uint16_t associationType = mData.getUInt16();
- uint32_t associationDesc = mData.getUInt32(); // association desc
- mData.getUInt32(); // sequence number
+ uint32_t associationDesc = mData.getUInt32(); // association desc
+ mData.getUInt32(); // sequence number
MtpStringBuffer name, created, modified;
mData.getString(name); // file name
mData.getString(created); // date created
@@ -1077,7 +1077,7 @@ MtpResponseCode MtpServer::doSendObject() {
}
initialData = ret - MTP_CONTAINER_HEADER_SIZE;
- mtp_file_range mfr;
+ mtp_file_range mfr;
mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC, 0640);
if (mfr.fd < 0) {
result = MTP_RESPONSE_GENERAL_ERROR;
@@ -1114,7 +1114,7 @@ MtpResponseCode MtpServer::doSendObject() {
if (errno == ECANCELED)
result = MTP_RESPONSE_TRANSACTION_CANCELLED;
else {
- MTPD("errno: %d\n", errno);
+ MTPD("errno: %d\n", errno);
result = MTP_RESPONSE_GENERAL_ERROR;
}
}
@@ -1292,7 +1292,7 @@ MtpResponseCode MtpServer::doSendPartialObject() {
}
if (length > 0) {
- mtp_file_range mfr;
+ mtp_file_range mfr;
mfr.fd = edit->mFD;
mfr.offset = offset;
mfr.length = length;
diff --git a/mtp/legacy/MtpServer.h b/mtp/legacy/MtpServer.h
new file mode 100644
index 000000000..d58cb30a4
--- /dev/null
+++ b/mtp/legacy/MtpServer.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef _MTP_SERVER_H
+#define _MTP_SERVER_H
+
+#include <utils/threads.h>
+#include <utils/Vector.h>
+#include "MtpRequestPacket.h"
+#include "MtpDatabase.h"
+#include "MtpDataPacket.h"
+#include "MtpResponsePacket.h"
+#include "MtpEventPacket.h"
+#include "mtp.h"
+#include "MtpUtils.h"
+
+
+class MtpDatabase;
+class MtpStorage;
+
+class MtpServer {
+
+private:
+ // file descriptor for MTP kernel driver
+ int mFD;
+ android::Mutex mMutex;
+ MtpDatabase* mDatabase;
+
+ // appear as a PTP device
+ bool mPtp;
+
+ // group to own new files and folders
+ int mFileGroup;
+ // permissions for new files and directories
+ int mFilePermission;
+ int mDirectoryPermission;
+
+ // current session ID
+ MtpSessionID mSessionID;
+ // true if we have an open session and mSessionID is valid
+ bool mSessionOpen;
+
+ MtpRequestPacket mRequest;
+ MtpDataPacket mData;
+ MtpResponsePacket mResponse;
+ MtpEventPacket mEvent;
+
+ MtpStorageList mStorages;
+
+ // handle for new object, set by SendObjectInfo and used by SendObject
+ MtpObjectHandle mSendObjectHandle;
+ MtpObjectFormat mSendObjectFormat;
+ MtpString mSendObjectFilePath;
+ size_t mSendObjectFileSize;
+
+ pthread_mutex_t mtpMutex;
+
+ // represents an MTP object that is being edited using the android extensions
+ // for direct editing (BeginEditObject, SendPartialObject, TruncateObject and EndEditObject)
+ class ObjectEdit {
+ public:
+ MtpObjectHandle mHandle;
+ MtpString mPath;
+ uint64_t mSize;
+ MtpObjectFormat mFormat;
+ int mFD;
+
+ ObjectEdit(MtpObjectHandle handle, const char* path, uint64_t size,
+ MtpObjectFormat format, int fd)
+ : mHandle(handle), mPath(path), mSize(size), mFormat(format), mFD(fd) {
+ }
+
+ virtual ~ObjectEdit() {
+ close(mFD);
+ }
+ };
+ android::Vector<ObjectEdit*> mObjectEditList;
+
+public:
+ MtpServer(MtpDatabase* database, bool ptp,
+ int fileGroup, int filePerm, int directoryPerm);
+ virtual ~MtpServer();
+
+ MtpStorage* getStorage(MtpStorageID id);
+ inline bool hasStorage() { return mStorages.size() > 0; }
+ bool hasStorage(MtpStorageID id);
+ void addStorage(MtpStorage* storage);
+ void removeStorage(MtpStorage* storage);
+
+ void run(int fd);
+
+ void sendObjectAdded(MtpObjectHandle handle);
+ void sendObjectRemoved(MtpObjectHandle handle);
+ void sendObjectUpdated(MtpObjectHandle handle);
+
+private:
+ void sendStoreAdded(MtpStorageID id);
+ void sendStoreRemoved(MtpStorageID id);
+ void sendEvent(MtpEventCode code, uint32_t param1);
+
+ void addEditObject(MtpObjectHandle handle, MtpString& path,
+ uint64_t size, MtpObjectFormat format, int fd);
+ ObjectEdit* getEditObject(MtpObjectHandle handle);
+ void removeEditObject(MtpObjectHandle handle);
+ void commitEdit(ObjectEdit* edit);
+
+ bool handleRequest();
+
+ MtpResponseCode doGetDeviceInfo();
+ MtpResponseCode doOpenSession();
+ MtpResponseCode doCloseSession();
+ MtpResponseCode doGetStorageIDs();
+ MtpResponseCode doGetStorageInfo();
+ MtpResponseCode doGetObjectPropsSupported();
+ MtpResponseCode doGetObjectHandles();
+ MtpResponseCode doGetNumObjects();
+ MtpResponseCode doGetObjectReferences();
+ MtpResponseCode doSetObjectReferences();
+ MtpResponseCode doGetObjectPropValue();
+ MtpResponseCode doSetObjectPropValue();
+ MtpResponseCode doGetDevicePropValue();
+ MtpResponseCode doSetDevicePropValue();
+ MtpResponseCode doResetDevicePropValue();
+ MtpResponseCode doGetObjectPropList();
+ MtpResponseCode doGetObjectInfo();
+ MtpResponseCode doGetObject();
+ MtpResponseCode doGetThumb();
+ MtpResponseCode doGetPartialObject(MtpOperationCode operation);
+ MtpResponseCode doSendObjectInfo();
+ MtpResponseCode doSendObject();
+ MtpResponseCode doDeleteObject();
+ MtpResponseCode doGetObjectPropDesc();
+ MtpResponseCode doGetDevicePropDesc();
+ MtpResponseCode doSendPartialObject();
+ MtpResponseCode doTruncateObject();
+ MtpResponseCode doBeginEditObject();
+ MtpResponseCode doEndEditObject();
+};
+
+#endif // _MTP_SERVER_H
diff --git a/mtp/MtpStorage.cpp b/mtp/legacy/MtpStorage.cpp
index 5a6954822..b22158a12 100644
--- a/mtp/MtpStorage.cpp
+++ b/mtp/legacy/MtpStorage.cpp
@@ -36,7 +36,7 @@
#include <signal.h>
#include <sys/inotify.h>
#include <fcntl.h>
-#include "../tw_atomic.hpp"
+#include "../../tw_atomic.hpp"
#define WATCH_FLAGS ( IN_CREATE | IN_DELETE | IN_MOVE | IN_MODIFY )
@@ -110,7 +110,7 @@ int MtpStorage::getAccessCapability() const {
uint64_t MtpStorage::getMaxCapacity() {
if (mMaxCapacity == 0) {
- struct statfs stat;
+ struct statfs stat;
if (statfs(getPath(), &stat))
return -1;
mMaxCapacity = (uint64_t)stat.f_blocks * (uint64_t)stat.f_bsize;
@@ -119,7 +119,7 @@ uint64_t MtpStorage::getMaxCapacity() {
}
uint64_t MtpStorage::getFreeSpace() {
- struct statfs stat;
+ struct statfs stat;
if (statfs(getPath(), &stat))
return -1;
uint64_t freeSpace = (uint64_t)stat.f_bavail * (uint64_t)stat.f_bsize;
@@ -157,7 +157,7 @@ int MtpStorage::createDB() {
MtpObjectHandleList* MtpStorage::getObjectList(MtpStorageID storageID, MtpObjectHandle parent) {
MTPD("MtpStorage::getObjectList, parent: %u\n", parent);
- //append object id (numerical #s) of database to int array
+ //append object id (numerical #s) of database to int array
MtpObjectHandleList* list = new MtpObjectHandleList();
if (parent == MTP_PARENT_ROOT) {
MTPD("parent == MTP_PARENT_ROOT\n");
@@ -430,7 +430,7 @@ int MtpStorage::getObjectPropertyList(MtpObjectHandle handle, uint32_t format, u
// format == 0 -> all formats, otherwise filter by ObjectFormatCode
// property == 0xffffffff -> all properties except those with group code 0xffffffff
// if property == 0 then use groupCode
- // groupCode == 0 -> return Specification_By_Group_Unsupported
+ // groupCode == 0 -> return Specification_By_Group_Unsupported
// depth == 0xffffffff -> all objects incl. and below handle
std::vector<PropEntry> results;
diff --git a/mtp/MtpStorage.h b/mtp/legacy/MtpStorage.h
index 245debf60..d967b4b9a 100644
--- a/mtp/MtpStorage.h
+++ b/mtp/legacy/MtpStorage.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,7 +28,7 @@
#include <pthread.h>
#include "btree.hpp"
#include "MtpServer.h"
-#include "../tw_atomic.hpp"
+#include "../../tw_atomic.hpp"
class MtpDatabase;
struct inotify_event;
@@ -36,37 +36,37 @@ struct inotify_event;
class MtpStorage {
private:
- MtpStorageID mStorageID;
- MtpString mFilePath;
- MtpString mDescription;
- uint64_t mMaxCapacity;
- uint64_t mMaxFileSize;
- // amount of free space to leave unallocated
- uint64_t mReserveSpace;
- bool mRemovable;
+ MtpStorageID mStorageID;
+ MtpString mFilePath;
+ MtpString mDescription;
+ uint64_t mMaxCapacity;
+ uint64_t mMaxFileSize;
+ // amount of free space to leave unallocated
+ uint64_t mReserveSpace;
+ bool mRemovable;
MtpServer* mServer;
- typedef std::map<int, Tree*> maptree;
- typedef maptree::iterator iter;
- maptree mtpmap;
+ typedef std::map<int, Tree*> maptree;
+ typedef maptree::iterator iter;
+ maptree mtpmap;
std::string mtpstorageparent;
- android::Mutex mMutex;
+ android::Mutex mMutex;
public:
- MtpStorage(MtpStorageID id, const char* filePath,
- const char* description, uint64_t reserveSpace,
- bool removable, uint64_t maxFileSize, MtpServer* refserver);
- virtual ~MtpStorage();
+ MtpStorage(MtpStorageID id, const char* filePath,
+ const char* description, uint64_t reserveSpace,
+ bool removable, uint64_t maxFileSize, MtpServer* refserver);
+ virtual ~MtpStorage();
- inline MtpStorageID getStorageID() const { return mStorageID; }
- int getType() const;
- int getFileSystemType() const;
- int getAccessCapability() const;
- uint64_t getMaxCapacity();
- uint64_t getFreeSpace();
- const char* getDescription() const;
- inline const char* getPath() const { return (const char *)mFilePath; }
- inline bool isRemovable() const { return mRemovable; }
- inline uint64_t getMaxFileSize() const { return mMaxFileSize; }
+ inline MtpStorageID getStorageID() const { return mStorageID; }
+ int getType() const;
+ int getFileSystemType() const;
+ int getAccessCapability() const;
+ uint64_t getMaxCapacity();
+ uint64_t getFreeSpace();
+ const char* getDescription() const;
+ inline const char* getPath() const { return (const char *)mFilePath; }
+ inline bool isRemovable() const { return mRemovable; }
+ inline uint64_t getMaxFileSize() const { return mMaxFileSize; }
struct PropEntry {
MtpObjectHandle handle;
diff --git a/mtp/MtpStorageInfo.cpp b/mtp/legacy/MtpStorageInfo.cpp
index a2b8ca2a1..a2b8ca2a1 100644
--- a/mtp/MtpStorageInfo.cpp
+++ b/mtp/legacy/MtpStorageInfo.cpp
diff --git a/mtp/MtpStorageInfo.h b/mtp/legacy/MtpStorageInfo.h
index 8858328fb..80f875291 100644
--- a/mtp/MtpStorageInfo.h
+++ b/mtp/legacy/MtpStorageInfo.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,23 +26,23 @@ class MtpDataPacket;
class MtpStorageInfo {
public:
- MtpStorageID mStorageID;
- uint16_t mStorageType;
- uint16_t mFileSystemType;
- uint16_t mAccessCapability;
- uint64_t mMaxCapacity;
- uint64_t mFreeSpaceBytes;
- uint32_t mFreeSpaceObjects;
- char* mStorageDescription;
- char* mVolumeIdentifier;
+ MtpStorageID mStorageID;
+ uint16_t mStorageType;
+ uint16_t mFileSystemType;
+ uint16_t mAccessCapability;
+ uint64_t mMaxCapacity;
+ uint64_t mFreeSpaceBytes;
+ uint32_t mFreeSpaceObjects;
+ char* mStorageDescription;
+ char* mVolumeIdentifier;
public:
- MtpStorageInfo(MtpStorageID id);
- virtual ~MtpStorageInfo();
+ MtpStorageInfo(MtpStorageID id);
+ virtual ~MtpStorageInfo();
- void read(MtpDataPacket& packet);
+ void read(MtpDataPacket& packet);
- void print();
+ void print();
};
diff --git a/mtp/MtpStringBuffer.cpp b/mtp/legacy/MtpStringBuffer.cpp
index 8aeb3ca94..8aeb3ca94 100644
--- a/mtp/MtpStringBuffer.cpp
+++ b/mtp/legacy/MtpStringBuffer.cpp
diff --git a/mtp/MtpStringBuffer.h b/mtp/legacy/MtpStringBuffer.h
index 9d61ecf54..68c0a0c25 100644
--- a/mtp/MtpStringBuffer.h
+++ b/mtp/legacy/MtpStringBuffer.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,27 +27,27 @@ class MtpDataPacket;
class MtpStringBuffer {
private:
- // mBuffer contains string in UTF8 format
- // maximum 3 bytes/character, with 1 extra for zero termination
- uint8_t mBuffer[255 * 3 + 1];
- int mCharCount;
- int mByteCount;
+ // mBuffer contains string in UTF8 format
+ // maximum 3 bytes/character, with 1 extra for zero termination
+ uint8_t mBuffer[255 * 3 + 1];
+ int mCharCount;
+ int mByteCount;
public:
- MtpStringBuffer();
- MtpStringBuffer(const char* src);
- MtpStringBuffer(const uint16_t* src);
- MtpStringBuffer(const MtpStringBuffer& src);
- virtual ~MtpStringBuffer();
+ MtpStringBuffer();
+ MtpStringBuffer(const char* src);
+ MtpStringBuffer(const uint16_t* src);
+ MtpStringBuffer(const MtpStringBuffer& src);
+ virtual ~MtpStringBuffer();
- void set(const char* src);
- void set(const uint16_t* src);
+ void set(const char* src);
+ void set(const uint16_t* src);
- void readFromPacket(MtpDataPacket* packet);
- void writeToPacket(MtpDataPacket* packet) const;
+ void readFromPacket(MtpDataPacket* packet);
+ void writeToPacket(MtpDataPacket* packet) const;
- inline int getCharCount() const { return mCharCount; }
- inline int getByteCount() const { return mByteCount; }
+ inline int getCharCount() const { return mCharCount; }
+ inline int getByteCount() const { return mByteCount; }
inline operator const char*() const { return (const char *)mBuffer; }
};
diff --git a/mtp/MtpTypes.h b/mtp/legacy/MtpTypes.h
index 64e180cb4..64e180cb4 100644
--- a/mtp/MtpTypes.h
+++ b/mtp/legacy/MtpTypes.h
diff --git a/mtp/MtpUtils.cpp b/mtp/legacy/MtpUtils.cpp
index 4ad59fd44..4ad59fd44 100644
--- a/mtp/MtpUtils.cpp
+++ b/mtp/legacy/MtpUtils.cpp
diff --git a/mtp/MtpUtils.h b/mtp/legacy/MtpUtils.h
index 2bca94b2e..2bca94b2e 100644
--- a/mtp/MtpUtils.h
+++ b/mtp/legacy/MtpUtils.h
diff --git a/mtp/btree.cpp b/mtp/legacy/btree.cpp
index b73789bd4..b73789bd4 100644
--- a/mtp/btree.cpp
+++ b/mtp/legacy/btree.cpp
diff --git a/mtp/legacy/btree.hpp b/mtp/legacy/btree.hpp
new file mode 100644
index 000000000..e1aad3636
--- /dev/null
+++ b/mtp/legacy/btree.hpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BTREE_HPP
+#define BTREE_HPP
+
+#include <vector>
+#include <string>
+#include <map>
+#include "MtpTypes.h"
+
+// A directory entry
+class Node {
+ MtpObjectHandle handle;
+ MtpObjectHandle parent;
+ std::string name; // name only without path
+
+public:
+ Node();
+ Node(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name);
+ virtual ~Node() {}
+
+ virtual bool isDir() const { return false; }
+
+ void rename(const std::string& newName);
+ MtpObjectHandle Mtpid() const;
+ MtpObjectHandle getMtpParentId() const;
+ const std::string& getName() const;
+
+ void addProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType);
+ void updateProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType);
+ void addProperties(const std::string& path, int storageID);
+ uint64_t getIntProperty(MtpPropertyCode property);
+ struct mtpProperty {
+ MtpPropertyCode property;
+ MtpDataType dataType;
+ uint64_t valueInt;
+ std::string valueStr;
+ mtpProperty() : property(0), dataType(0), valueInt(0) {}
+ };
+ std::vector<mtpProperty>& getMtpProps();
+ std::vector<mtpProperty> mtpProp;
+ const mtpProperty& getProperty(MtpPropertyCode property);
+};
+
+// A directory
+class Tree : public Node {
+ std::map<MtpObjectHandle, Node*> entries;
+ bool alreadyRead;
+public:
+ Tree(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name);
+ ~Tree();
+
+ virtual bool isDir() const { return true; }
+
+ void addEntry(Node* node);
+ Node* findNode(MtpObjectHandle handle);
+ void getmtpids(MtpObjectHandleList* mtpids);
+ void deleteNode(MtpObjectHandle handle);
+ std::string getPath(Node* node);
+ int getMtpParentId() { return Node::getMtpParentId(); }
+ int getMtpParentId(Node* node);
+ Node* findEntryByName(std::string name);
+ int getCount();
+ bool wasAlreadyRead() const { return alreadyRead; }
+ void setAlreadyRead(bool b) { alreadyRead = b; }
+};
+
+#endif
diff --git a/mtp/mtp.h b/mtp/legacy/mtp.h
index c3293319f..c3293319f 100644
--- a/mtp/mtp.h
+++ b/mtp/legacy/mtp.h
diff --git a/mtp/mtp_MtpDatabase.cpp b/mtp/legacy/mtp_MtpDatabase.cpp
index 5eb7d8e61..5eb7d8e61 100644
--- a/mtp/mtp_MtpDatabase.cpp
+++ b/mtp/legacy/mtp_MtpDatabase.cpp
diff --git a/mtp/legacy/mtp_MtpDatabase.hpp b/mtp/legacy/mtp_MtpDatabase.hpp
new file mode 100644
index 000000000..931ba1587
--- /dev/null
+++ b/mtp/legacy/mtp_MtpDatabase.hpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
+ */
+
+#ifndef MTP_MTPDATABASE_HPP
+#define MTP_MTPDATABASE_HPP
+
+#include <utils/Log.h>
+
+#include <stdio.h>
+#include <assert.h>
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <map>
+#include <string>
+#include <deque>
+
+#include "MtpDatabase.h"
+#include "MtpDataPacket.h"
+#include "MtpObjectInfo.h"
+#include "MtpProperty.h"
+#include "MtpStringBuffer.h"
+#include "MtpUtils.h"
+#include "mtp.h"
+
+class MyMtpDatabase : public MtpDatabase {
+private:
+ int* getSupportedObjectProperties(int format);
+
+ static int FILE_PROPERTIES[10];
+ static int DEVICE_PROPERTIES[3];
+ static int AUDIO_PROPERTIES[19];
+ static int VIDEO_PROPERTIES[15];
+ static int IMAGE_PROPERTIES[12];
+ static int ALL_PROPERTIES[25];
+ static int SUPPORTED_PLAYBACK_FORMATS[26];
+ int storagenum;
+ int count;
+ std::string lastfile;
+ std::map<int, MtpStorage*> storagemap;
+ void countDirs(std::string path);
+ int readParentDirs(std::string path, int storageID);
+
+public:
+ MyMtpDatabase();
+ virtual ~MyMtpDatabase();
+
+ void createDB(MtpStorage* storage, MtpStorageID storageID);
+ void destroyDB(MtpStorageID storageID);
+ virtual MtpObjectHandle beginSendObject(const char* path,
+ MtpObjectFormat format,
+ MtpObjectHandle parent,
+ MtpStorageID storage,
+ uint64_t size,
+ time_t modified);
+
+ virtual void endSendObject(const char* path,
+ MtpObjectHandle handle,
+ MtpObjectFormat format,
+ bool succeeded);
+
+ virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID,
+ MtpObjectFormat format,
+ MtpObjectHandle parent);
+
+ virtual int getNumObjects(MtpStorageID storageID,
+ MtpObjectFormat format,
+ MtpObjectHandle parent);
+
+ // callee should delete[] the results from these
+ // results can be NULL
+ virtual MtpObjectFormatList* getSupportedPlaybackFormats();
+ virtual MtpObjectFormatList* getSupportedCaptureFormats();
+ virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format);
+ virtual MtpDevicePropertyList* getSupportedDeviceProperties();
+
+ virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle,
+ MtpObjectProperty property,
+ MtpDataPacket& packet);
+
+ virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle,
+ MtpObjectProperty property,
+ MtpDataPacket& packet);
+
+ virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property,
+ MtpDataPacket& packet);
+
+ virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property,
+ MtpDataPacket& packet);
+
+ virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property);
+
+ virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle,
+ uint32_t format, uint32_t property,
+ int groupCode, int depth,
+ MtpDataPacket& packet);
+
+ virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle,
+ MtpObjectInfo& info);
+
+ virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize);
+
+ virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle,
+ MtpString& outFilePath,
+ int64_t& outFileLength,
+ MtpObjectFormat& outFormat);
+ virtual MtpResponseCode deleteFile(MtpObjectHandle handle);
+
+ bool getObjectPropertyInfo(MtpObjectProperty property, int& type);
+ bool getDevicePropertyInfo(MtpDeviceProperty property, int& type);
+
+ virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle);
+
+ virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle,
+ MtpObjectHandleList* references);
+
+ virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property,
+ MtpObjectFormat format);
+
+ virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property);
+
+ virtual void sessionStarted();
+
+ virtual void sessionEnded();
+ virtual void lockMutex();
+ virtual void unlockMutex();
+};
+#endif
diff --git a/mtp/mtp_MtpServer.cpp b/mtp/legacy/mtp_MtpServer.cpp
index 1ebe5f55d..1ebe5f55d 100644
--- a/mtp/mtp_MtpServer.cpp
+++ b/mtp/legacy/mtp_MtpServer.cpp
diff --git a/mtp/mtp_MtpServer.hpp b/mtp/legacy/mtp_MtpServer.hpp
index 99f63d510..99f63d510 100644
--- a/mtp/mtp_MtpServer.hpp
+++ b/mtp/legacy/mtp_MtpServer.hpp
diff --git a/mtp/node.cpp b/mtp/legacy/node.cpp
index 207a37a08..207a37a08 100644
--- a/mtp/node.cpp
+++ b/mtp/legacy/node.cpp
diff --git a/mtp/twrpMtp.cpp b/mtp/legacy/twrpMtp.cpp
index 2b2de01cd..2b2de01cd 100644
--- a/mtp/twrpMtp.cpp
+++ b/mtp/legacy/twrpMtp.cpp
diff --git a/mtp/twrpMtp.hpp b/mtp/legacy/twrpMtp.hpp
index 9ad270c72..9ad270c72 100644
--- a/mtp/twrpMtp.hpp
+++ b/mtp/legacy/twrpMtp.hpp