Use IMtpDatabase to open file in MTP

We want to first try opening the file in MTP using IMtpDatabase
irrespective of whether we are transcoding or not. This way we won't be
affected by the transcoding default option (A or B) and the decision
will solely rely on what we pass from here.

We can now do this because MtpDatabase now has the ability to pass both
supported and unsupported types to MediaProvider.

BUG=158466651
Test: manual

Change-Id: I20bd260cd11278afa66a9e41db3a5d06bd45a3f6
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index d0ad22c..a92848c 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -794,22 +794,18 @@
     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);
-        // 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) {
-            fstat(mfr.fd, &sstat);
-            finalsize = sstat.st_size;
-            fileLength = finalsize;
-        } else {
-            ALOGW("Mtp open with no transcoding failed for %s. Falling back to the original",
-                    filePath);
-        }
-    }
+    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) {
+        fstat(mfr.fd, &sstat);
+        finalsize = sstat.st_size;
+        fileLength = finalsize;
+    } else {
+        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;