summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zim <zezeozue@google.com> 2020-02-11 16:59:09 +0000
committer Zim <zezeozue@google.com> 2020-02-11 17:24:13 +0000
commit238aa33a2975957757ab343ffc9c397bbd10ca27 (patch)
treee6b4cf6d16c77fd76bf338a4be1ae84bad82c1ed
parent456ffd240f72705e33debb85b6a20a3f740a977a (diff)
Refactor FUSE flag precedence resolution
We have two FUSE flags: settings and native: settings: sys.fflag.settings_fuse --------------------------------- The settings flag allows us defer flag changes while the device is running till the next boot. These changes can come from server side flag flips or user initiated flag flips. native: persist.sys.fuse ------------------------ The native flag is what components (init, zygote, vold, installd, system_server) actually read to determine behavior. This flag doesn't change during a boot and if changed should be followed by a reboot so all components see a consistent state of the flag. The resolution at system boot of what final device state to take effect, FUSE on or off was 'needlessly complicated'. Mostly by the fact that in some rare cases the native flag could be empty. The 'empty native flag' issue is fixed in Ie475e0bb82614626803f4e88b1e9d29c8a969f17 and we now simplify the precedence resolution Test: Device boots and flags flip correctly Bug: 135341433 Change-Id: I903b104e2be282e6d4641d15284d4ebd780226ca
-rw-r--r--services/core/java/com/android/server/StorageManagerService.java23
1 files changed, 9 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index a08bdb23dd22..ddfebc7935f0 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -224,6 +224,7 @@ class StorageManagerService extends IStorageManager.Stub
* disables FuseDaemon. If {@code 0}, uses the default value from the build system.
*/
private static final String FUSE_ENABLED = "fuse_enabled";
+ private static final boolean DEFAULT_FUSE_ENABLED = false;
public static class Lifecycle extends SystemService {
private StorageManagerService mStorageManagerService;
@@ -1623,7 +1624,7 @@ class StorageManagerService extends IStorageManager.Stub
// If there is no value in the property yet (first boot after data wipe), this value may be
// incorrect until #updateFusePropFromSettings where we set the correct value and reboot if
// different
- mIsFuseEnabled = SystemProperties.getBoolean(PROP_FUSE, false);
+ mIsFuseEnabled = SystemProperties.getBoolean(PROP_FUSE, DEFAULT_FUSE_ENABLED);
mContext = context;
mResolver = mContext.getContentResolver();
mCallbacks = new Callbacks(FgThread.get().getLooper());
@@ -1686,23 +1687,17 @@ class StorageManagerService extends IStorageManager.Stub
* and updates PROP_FUSE (reboots if changed).
*/
private void updateFusePropFromSettings() {
- boolean defaultFuseFlag = false;
- boolean settingsFuseFlag = SystemProperties.getBoolean(PROP_SETTINGS_FUSE, defaultFuseFlag);
- Slog.d(TAG, "FUSE flags. Settings: " + settingsFuseFlag + ". Default: " + defaultFuseFlag);
-
- if (TextUtils.isEmpty(SystemProperties.get(PROP_SETTINGS_FUSE))) {
- // Set default value of PROP_SETTINGS_FUSE and PROP_FUSE if it
- // is unset (neither true nor false).
- // This happens only on the first boot after wiping data partition
- SystemProperties.set(PROP_SETTINGS_FUSE, Boolean.toString(defaultFuseFlag));
- SystemProperties.set(PROP_FUSE, Boolean.toString(defaultFuseFlag));
- return;
- }
+ boolean settingsFuseFlag = SystemProperties.getBoolean(PROP_SETTINGS_FUSE,
+ DEFAULT_FUSE_ENABLED);
+ Slog.d(TAG, "FUSE flags. Settings: " + settingsFuseFlag
+ + ". Default: " + DEFAULT_FUSE_ENABLED);
if (mIsFuseEnabled != settingsFuseFlag) {
Slog.i(TAG, "Toggling persist.sys.fuse to " + settingsFuseFlag);
+ // Set prop_fuse to match prop_settings_fuse because it is used by native daemons like
+ // init, zygote, installd and vold
SystemProperties.set(PROP_FUSE, Boolean.toString(settingsFuseFlag));
- // Perform hard reboot to kick policy into place
+ // Then perform hard reboot to kick policy into place
mContext.getSystemService(PowerManager.class).reboot("fuse_prop");
}
}