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

Commit 56e7af06 authored by Zimuzo Ezeozue's avatar Zimuzo Ezeozue Committed by Android (Google) Code Review
Browse files

Merge "Revise seamless transcoding optimization flags"

parents 24b362f6 d2f9505d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1436,7 +1436,10 @@ public final class FileUtils {
    public static FileDescriptor convertToModernFd(FileDescriptor fd) {
        try {
            Context context = AppGlobals.getInitialApplication();
            if (UserHandle.getAppId(Process.myUid()) == getMediaProviderAppId(context)) {
            if (!SystemProperties.getBoolean("persist.sys.fuse.transcode", false)
                    || !SystemProperties.getBoolean("persist.sys.fuse.transcode_optimize", true)
                    || UserHandle.getAppId(Process.myUid()) == getMediaProviderAppId(context)) {
                // If transcode is enabled we optimize by default, unless explicitly disabled.
                // Never convert modern fd for MediaProvider, because this requires
                // MediaStore#scanFile and can cause infinite loops when MediaProvider scans
                return null;
+2 −6
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.FileUtils;
import android.os.SystemProperties;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
@@ -1528,8 +1527,7 @@ public class ExifInterface {
        if (fileDescriptor == null) {
            throw new NullPointerException("fileDescriptor cannot be null");
        }
        boolean optimize = SystemProperties.getBoolean("fuse.sys.transcode_exif_optimize", false);
        FileDescriptor modernFd = optimize ? FileUtils.convertToModernFd(fileDescriptor) : null;
        FileDescriptor modernFd = FileUtils.convertToModernFd(fileDescriptor);
        if (modernFd != null) {
            fileDescriptor = modernFd;
        }
@@ -2549,9 +2547,7 @@ public class ExifInterface {
        mIsInputStream = false;
        try {
            in = new FileInputStream(filename);
            boolean optimize = SystemProperties.getBoolean("fuse.sys.transcode_exif_optimize",
                    false);
            FileDescriptor modernFd = optimize ? FileUtils.convertToModernFd(in.getFD()) : null;
            FileDescriptor modernFd = FileUtils.convertToModernFd(in.getFD());
            if (modernFd != null) {
                legacyInputStream = in;
                in = new FileInputStream(modernFd);
+1 −3
Original line number Diff line number Diff line
@@ -300,9 +300,7 @@ public class MediaMetadataRetriever implements AutoCloseable {
     */
    public void setDataSource(FileDescriptor fd, long offset, long length)
            throws IllegalArgumentException  {
        boolean optimize = SystemProperties.getBoolean("fuse.sys.transcode_retriever_optimize",
                false);
        FileDescriptor modernFd = optimize ? FileUtils.convertToModernFd(fd) : null;
        FileDescriptor modernFd = FileUtils.convertToModernFd(fd);
        if (modernFd == null) {
            _setDataSource(fd, offset, length);
        } else {
+1 −2
Original line number Diff line number Diff line
@@ -1258,8 +1258,7 @@ public class MediaPlayer extends PlayerBase
     */
    public void setDataSource(FileDescriptor fd, long offset, long length)
            throws IOException, IllegalArgumentException, IllegalStateException {
        boolean optimize = SystemProperties.getBoolean("fuse.sys.transcode_player_optimize", false);
        FileDescriptor modernFd = optimize ? FileUtils.convertToModernFd(fd) : null;
        FileDescriptor modernFd = FileUtils.convertToModernFd(fd);
        if (modernFd == null) {
            _setDataSource(fd, offset, length);
        } else {