Merge "Revise seamless transcoding optimization flags"

This commit is contained in:
Zimuzo Ezeozue
2020-11-12 17:31:35 +00:00
committed by Android (Google) Code Review
4 changed files with 8 additions and 12 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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 {