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

Commit 3e4c9c46 authored by Abhijeet Kaur's avatar Abhijeet Kaur Committed by Android (Google) Code Review
Browse files

Merge "Add a new persistent FUSE flag in Settings"

parents c913aaca b984771e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4272,6 +4272,7 @@ package android.util {
    field public static final String PERSIST_PREFIX = "persist.sys.fflag.override.";
    field public static final String SCREENRECORD_LONG_PRESS = "settings_screenrecord_long_press";
    field public static final String SEAMLESS_TRANSFER = "settings_seamless_transfer";
    field public static final String SETTINGS_FUSE_FLAG = "settings_fuse";
    field public static final String SETTINGS_WIFITRACKER2 = "settings_wifitracker2";
  }

+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class FeatureFlagUtils {
    public static final String SCREENRECORD_LONG_PRESS = "settings_screenrecord_long_press";
    public static final String DYNAMIC_SYSTEM = "settings_dynamic_system";
    public static final String SETTINGS_WIFITRACKER2 = "settings_wifitracker2";
    public static final String SETTINGS_FUSE_FLAG = "settings_fuse";

    private static final Map<String, String> DEFAULT_FLAGS;

@@ -48,6 +49,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS = new HashMap<>();
        DEFAULT_FLAGS.put("settings_audio_switcher", "true");
        DEFAULT_FLAGS.put("settings_systemui_theme", "true");
        DEFAULT_FLAGS.put(SETTINGS_FUSE_FLAG, "false");
        DEFAULT_FLAGS.put(DYNAMIC_SYSTEM, "false");
        DEFAULT_FLAGS.put(SEAMLESS_TRANSFER, "false");
        DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "false");
+32 −4
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.AtomicFile;
import android.util.DataUnit;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -819,7 +820,6 @@ class StorageManagerService extends IStorageManager.Stub
                    refreshFuseSettings();
                });
        refreshIsolatedStorageSettings();
        refreshFuseSettings();
    }

    /**
@@ -883,16 +883,25 @@ class StorageManagerService extends IStorageManager.Stub
        SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE, Boolean.toString(res));
    }

    /**
     * The most recent flag change takes precedence. Change fuse Settings flag if Device Config is
     * changed. Settings flag change will in turn change fuse system property (persist.sys.fuse)
     * whenever the user reboots.
     */
    private void refreshFuseSettings() {
        int isFuseEnabled = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                FUSE_ENABLED, 0);
        if (isFuseEnabled == 1) {
            SystemProperties.set(StorageManager.PROP_FUSE, "true");
            Slog.d(TAG, "Device Config flag for FUSE is enabled, turn Settings fuse flag on");
            SystemProperties.set(FeatureFlagUtils.PERSIST_PREFIX
                    + FeatureFlagUtils.SETTINGS_FUSE_FLAG, "true");
        } else if (isFuseEnabled == -1) {
            SystemProperties.set(StorageManager.PROP_FUSE, "false");
            Slog.d(TAG, "Device Config flag for FUSE is disabled, turn Settings fuse flag off");
            SystemProperties.set(FeatureFlagUtils.PERSIST_PREFIX
                    + FeatureFlagUtils.SETTINGS_FUSE_FLAG, "false");
        }
        // else, keep the build config.
        // This can be overridden be direct adjustment of persist.sys.prop
        // This can be overridden by direct adjustment of persist.sys.fflag.override.settings_fuse
    }

    /**
@@ -1548,6 +1557,8 @@ class StorageManagerService extends IStorageManager.Stub
    public StorageManagerService(Context context) {
        sSelf = this;

        updateFusePropFromSettings();

        // Snapshot feature flag used for this boot
        SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE_SNAPSHOT, Boolean.toString(
                SystemProperties.getBoolean(StorageManager.PROP_ISOLATED_STORAGE, true)));
@@ -1609,6 +1620,23 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    /**
     *  Checks if user changed the persistent settings_fuse flag from Settings UI
     *  and updates PROP_FUSE (reboots if changed).
     */
    private void updateFusePropFromSettings() {
        Boolean settingsFuseFlag = SystemProperties.getBoolean((FeatureFlagUtils.PERSIST_PREFIX
                + FeatureFlagUtils.SETTINGS_FUSE_FLAG), false);
        Slog.d(TAG, "The value of Settings Fuse Flag is " + settingsFuseFlag);
        if (SystemProperties.getBoolean(StorageManager.PROP_FUSE, false) != settingsFuseFlag) {
            Slog.d(TAG, "Set persist.sys.fuse to " + settingsFuseFlag);
            SystemProperties.set(StorageManager.PROP_FUSE, Boolean.toString(settingsFuseFlag));
            // Perform hard reboot to kick policy into place
            mContext.getSystemService(PowerManager.class).reboot("Reboot device for FUSE system"
                    + "property change to take effect");
        }
    }

    private void start() {
        connectStoraged();
        connectVold();