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

Commit 27061f74 authored by Manish Singh's avatar Manish Singh Committed by Android (Google) Code Review
Browse files

Merge "Use IMtpDatabase to open file in MTP"

parents 868ec838 fd5500ae
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -794,9 +794,8 @@ MtpResponseCode MtpServer::doGetObject() {
    struct stat sstat;
    uint64_t finalsize;
    bool transcode = android::base::GetBoolProperty("sys.fuse.transcode_mtp", true);
    if (!transcode) {
        ALOGD("Mtp transcode disabled");
        mfr.fd = mDatabase->openFilePath(filePath, false);
    ALOGD("Mtp transcode = %d", transcode);
    mfr.fd = mDatabase->openFilePath(filePath, transcode);
    // Doing this here because we want to update fileLength only for this case and leave the
    // regular path as unchanged as possible.
    if (mfr.fd >= 0) {
@@ -804,12 +803,9 @@ MtpResponseCode MtpServer::doGetObject() {
        finalsize = sstat.st_size;
        fileLength = finalsize;
    } else {
            ALOGW("Mtp open with no transcoding failed for %s. Falling back to the original",
        ALOGW("Mtp open via IMtpDatabase failed for %s. Falling back to the original",
                filePath);
        }
    }

    if (transcode || mfr.fd < 0) {
        mfr.fd = open(filePath, O_RDONLY);
        if (mfr.fd < 0) {
            return MTP_RESPONSE_GENERAL_ERROR;