Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47f61f07 authored by Jerry Zhang's avatar Jerry Zhang Committed by Android (Google) Code Review
Browse files

Merge "Fix Unicode string handling" into pi-dev

parents 2ad6e528 bc1d4b41
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ cc_library_shared {
    shared_libs: [
        "libasyncio",
        "libbase",
        "libutils",
        "liblog",
        "libusbhost",
    ],
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ namespace android {
class MtpDataPacket;
class MtpProperty;
class MtpObjectInfo;
class MtpStringBuffer;

class IMtpDatabase {
public:
@@ -86,7 +87,7 @@ public:
    virtual void*                   getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) = 0;

    virtual MtpResponseCode         getObjectFilePath(MtpObjectHandle handle,
                                            MtpString& outFilePath,
                                            MtpStringBuffer& outFilePath,
                                            int64_t& outFileLength,
                                            MtpObjectFormat& outFormat) = 0;

+9 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "MtpDataPacket.h"

#include <algorithm>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
@@ -129,7 +130,7 @@ Int8List* MtpDataPacket::getAInt8() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -145,7 +146,7 @@ UInt8List* MtpDataPacket::getAUInt8() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -161,7 +162,7 @@ Int16List* MtpDataPacket::getAInt16() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -177,7 +178,7 @@ UInt16List* MtpDataPacket::getAUInt16() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -193,7 +194,7 @@ Int32List* MtpDataPacket::getAInt32() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -209,7 +210,7 @@ UInt32List* MtpDataPacket::getAUInt32() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -225,7 +226,7 @@ Int64List* MtpDataPacket::getAInt64() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
@@ -241,7 +242,7 @@ UInt64List* MtpDataPacket::getAUInt64() {
            delete result;
            return NULL;
        }
        result->push(value);
        result->push_back(value);
    }
    return result;
}
+2 −2
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@
#define _MTP_DEBUG_H

// #define LOG_NDEBUG 0
#include <utils/Log.h>

#include "MtpTypes.h"

#include <log/log.h>

namespace android {

class MtpDebug {
+22 −22
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ void MtpDevice::initialize() {
                MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
                MtpProperty* property = getDevicePropDesc(propCode);
                if (property)
                    mDeviceProperties.push(property);
                    mDeviceProperties.push_back(property);
            }
        }
    }
@@ -327,7 +327,7 @@ const char* MtpDevice::getDeviceName() {
}

bool MtpDevice::openSession() {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mSessionID = 0;
    mTransactionID = 0;
@@ -353,7 +353,7 @@ bool MtpDevice::closeSession() {
}

MtpDeviceInfo* MtpDevice::getDeviceInfo() {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    if (!sendRequest(MTP_OPERATION_GET_DEVICE_INFO))
@@ -372,7 +372,7 @@ MtpDeviceInfo* MtpDevice::getDeviceInfo() {
}

MtpStorageIDList* MtpDevice::getStorageIDs() {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    if (!sendRequest(MTP_OPERATION_GET_STORAGE_IDS))
@@ -387,7 +387,7 @@ MtpStorageIDList* MtpDevice::getStorageIDs() {
}

MtpStorageInfo* MtpDevice::getStorageInfo(MtpStorageID storageID) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, storageID);
@@ -408,7 +408,7 @@ MtpStorageInfo* MtpDevice::getStorageInfo(MtpStorageID storageID) {

MtpObjectHandleList* MtpDevice::getObjectHandles(MtpStorageID storageID,
            MtpObjectFormat format, MtpObjectHandle parent) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, storageID);
@@ -426,7 +426,7 @@ MtpObjectHandleList* MtpDevice::getObjectHandles(MtpStorageID storageID,
}

MtpObjectInfo* MtpDevice::getObjectInfo(MtpObjectHandle handle) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    // FIXME - we might want to add some caching here

@@ -448,7 +448,7 @@ MtpObjectInfo* MtpDevice::getObjectInfo(MtpObjectHandle handle) {
}

void* MtpDevice::getThumbnail(MtpObjectHandle handle, int& outLength) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -463,7 +463,7 @@ void* MtpDevice::getThumbnail(MtpObjectHandle handle, int& outLength) {
}

MtpObjectHandle MtpDevice::sendObjectInfo(MtpObjectInfo* info) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    MtpObjectHandle parent = info->mParent;
@@ -517,7 +517,7 @@ MtpObjectHandle MtpDevice::sendObjectInfo(MtpObjectInfo* info) {
}

bool MtpDevice::sendObject(MtpObjectHandle handle, int size, int srcFD) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    if (mLastSendObjectInfoTransactionID + 1 != mTransactionID ||
            mLastSendObjectInfoObjectHandle != handle) {
@@ -537,7 +537,7 @@ bool MtpDevice::sendObject(MtpObjectHandle handle, int size, int srcFD) {
}

bool MtpDevice::deleteObject(MtpObjectHandle handle) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -572,7 +572,7 @@ MtpObjectHandle MtpDevice::getStorageID(MtpObjectHandle handle) {
}

MtpObjectPropertyList* MtpDevice::getObjectPropsSupported(MtpObjectFormat format) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, format);
@@ -589,7 +589,7 @@ MtpObjectPropertyList* MtpDevice::getObjectPropsSupported(MtpObjectFormat format
}

MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, code);
@@ -609,7 +609,7 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) {
}

MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, code);
@@ -633,7 +633,7 @@ bool MtpDevice::getObjectPropValue(MtpObjectHandle handle, MtpProperty* property
    if (property == nullptr)
        return false;

    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -684,7 +684,7 @@ bool MtpDevice::readObjectInternal(MtpObjectHandle handle,
                                   ReadObjectCallback callback,
                                   const uint32_t* expectedLength,
                                   void* clientData) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -806,7 +806,7 @@ bool MtpDevice::readPartialObject(MtpObjectHandle handle,
                                  uint32_t *writtenSize,
                                  ReadObjectCallback callback,
                                  void* clientData) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -828,7 +828,7 @@ bool MtpDevice::readPartialObject64(MtpObjectHandle handle,
                                    uint32_t *writtenSize,
                                    ReadObjectCallback callback,
                                    void* clientData) {
    Mutex::Autolock autoLock(mMutex);
    std::lock_guard<std::mutex> lg(mMutex);

    mRequest.reset();
    mRequest.setParameter(1, handle);
@@ -908,7 +908,7 @@ MtpResponseCode MtpDevice::readResponse() {
}

int MtpDevice::submitEventRequest() {
    if (mEventMutex.tryLock()) {
    if (!mEventMutex.try_lock()) {
        // An event is being reaped on another thread.
        return -1;
    }
@@ -916,7 +916,7 @@ int MtpDevice::submitEventRequest() {
        // An event request was submitted, but no reapEventRequest called so far.
        return -1;
    }
    Mutex::Autolock autoLock(mEventMutexForInterrupt);
    std::lock_guard<std::mutex> lg(mEventMutexForInterrupt);
    mEventPacket.sendRequest(mRequestIntr);
    const int currentHandle = ++mCurrentEventHandle;
    mProcessingEvent = true;
@@ -925,7 +925,7 @@ int MtpDevice::submitEventRequest() {
}

int MtpDevice::reapEventRequest(int handle, uint32_t (*parameters)[3]) {
    Mutex::Autolock autoLock(mEventMutex);
    std::lock_guard<std::mutex> lg(mEventMutex);
    if (!mProcessingEvent || mCurrentEventHandle != handle || !parameters) {
        return -1;
    }
@@ -940,7 +940,7 @@ int MtpDevice::reapEventRequest(int handle, uint32_t (*parameters)[3]) {
}

void MtpDevice::discardEventRequest(int handle) {
    Mutex::Autolock autoLock(mEventMutexForInterrupt);
    std::lock_guard<std::mutex> lg(mEventMutexForInterrupt);
    if (mCurrentEventHandle != handle) {
        return;
    }
Loading