Fix transcode_optimize flags

The optimize flag depended on transcode_enabled (sysprop only,
ignoring device_config) flag to take effect.

Now, we removed the 'optimize' flag and rely on a new non-persistent
sysprop that says if transcode was enabled on the current boot.

This means that a reboot is required for 'optimizations' to take
effect, right after enabling/disabling transcode. This is anyways a
better trade-off than ignoring the device_config transcode_enabled
flag entirely.

Test: Manual
Bug: 170488060
Change-Id: I77bbc30f9fae2cfc0085c32028859fdbbc9aaed7
This commit is contained in:
Zim
2020-12-14 11:51:54 +00:00
committed by Zimuzo Ezeozue
parent 76b105c20a
commit 3952caa992
2 changed files with 19 additions and 3 deletions

View File

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

View File

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