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

Commit b2992b61 authored by shafik's avatar shafik
Browse files

Configure persist.sys.fuse flag using DeviceConfig

Assign the value of persist.sys.fuse from DeviceConfig's flag
storage_native_boot.fuse_enabled on device boot.
Also add a listener for property changed so that the flag will always be
updated when the server pushes a new value to devices.

More info on how the flags are updated and how we guarantee consistency,
check out go/usefuse

Test: toggle persist.sys.fuse on and off
Fixes: 140803239
Change-Id: Icf970505952af7792c10f96c694e63ce6261cf0b
parent 976722f3
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -208,6 +208,12 @@ class StorageManagerService extends IStorageManager.Stub
     */
    private static final String ISOLATED_STORAGE_ENABLED = "isolated_storage_enabled";

    /**
     * If {@code 1}, enables FuseDaemon to intercept file system ops. If {@code -1},
     * disables FuseDaemon. If {@code 0}, uses the default value from the build system.
     */
    private static final String FUSE_ENABLED = "fuse_enabled";

    public static class Lifecycle extends SystemService {
        private StorageManagerService mStorageManagerService;

@@ -817,8 +823,10 @@ class StorageManagerService extends IStorageManager.Stub
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                mContext.getMainExecutor(), (properties) -> {
                    refreshIsolatedStorageSettings();
                    refreshFuseSettings();
                });
        refreshIsolatedStorageSettings();
        refreshFuseSettings();
    }

    /**
@@ -882,6 +890,18 @@ class StorageManagerService extends IStorageManager.Stub
        SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE, Boolean.toString(res));
    }

    private void refreshFuseSettings() {
        int isFuseEnabled = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                FUSE_ENABLED, 0);
        if (isFuseEnabled == 1) {
            SystemProperties.set(StorageManager.PROP_FUSE, "true");
        } else if (isFuseEnabled == -1) {
            SystemProperties.set(StorageManager.PROP_FUSE, "false");
        }
        // else, keep the build config.
        // This can be overridden be direct adjustment of persist.sys.prop
    }

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