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

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

Merge "Fix transcode_optimize flags"

parents 869b1dc1 3952caa9
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1436,9 +1436,7 @@ public final class FileUtils {
    public static FileDescriptor convertToModernFd(FileDescriptor fd) {
        try {
            Context context = AppGlobals.getInitialApplication();
            // TODO(b/169327180): Consider device config.
            if (!SystemProperties.getBoolean("persist.sys.fuse.transcode_enabled", false)
                    || !SystemProperties.getBoolean("persist.sys.fuse.transcode_optimize", true)
            if (!SystemProperties.getBoolean("sys.fuse.transcode_enabled", false)
                    || 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
+18 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ import android.os.storage.StorageManagerInternal;
import android.os.storage.StorageVolume;
import android.os.storage.VolumeInfo;
import android.os.storage.VolumeRecord;
import android.provider.DeviceConfig;
import android.provider.DocumentsContract;
import android.provider.Downloads;
import android.provider.MediaStore;
@@ -879,6 +880,8 @@ class StorageManagerService extends IStorageManager.Stub
                    com.android.internal.R.bool.config_zramWriteback)) {
            ZramWriteback.scheduleZramWriteback(mContext);
        }

        updateTranscodeEnabled();
    }

    /**
@@ -910,6 +913,21 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    private void updateTranscodeEnabled() {
        // See MediaProvider TranscodeHelper#getBooleanProperty for more information
        boolean transcodeEnabled = false;
        boolean defaultValue = true;

        if (SystemProperties.getBoolean("persist.sys.fuse.transcode_user_control", false)) {
            transcodeEnabled = SystemProperties.getBoolean("persist.sys.fuse.transcode_enabled",
                    defaultValue);
        } else {
            transcodeEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                    "transcode_enabled", defaultValue);
        }
        SystemProperties.set("sys.fuse.transcode_enabled", String.valueOf(transcodeEnabled));
    }

    /**
     * MediaProvider has a ton of code that makes assumptions about storage
     * paths never changing, so we outright kill them to pick up new state.