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

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

Merge "Remove persist.sys.fuse == false code paths"

parents 0ec6c77e a813bc1f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -5004,7 +5004,6 @@ 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";
  }

+0 −6
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ import android.system.Os;
import android.system.OsConstants;
import android.text.TextUtils;
import android.util.DataUnit;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -161,11 +160,6 @@ public class StorageManager {
    /** {@hide} */
    public static final String PROP_ISOLATED_STORAGE_SNAPSHOT = "sys.isolated_storage_snapshot";
    /** {@hide} */
    public static final String PROP_FUSE = "persist.sys.fuse";
    /** {@hide} */
    public static final String PROP_SETTINGS_FUSE = FeatureFlagUtils.PERSIST_PREFIX
            + FeatureFlagUtils.SETTINGS_FUSE_FLAG;
    /** {@hide} */
    public static final String PROP_FORCED_SCOPED_STORAGE_WHITELIST =
            "forced_scoped_storage_whitelist";

+0 −2
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ 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";
    /** @hide */
    public static final String SETTINGS_DO_NOT_RESTORE_PRESERVED =
            "settings_do_not_restore_preserved";
@@ -52,7 +51,6 @@ 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, "true");
        DEFAULT_FLAGS.put(DYNAMIC_SYSTEM, "false");
        DEFAULT_FLAGS.put(SEAMLESS_TRANSFER, "false");
        DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "false");
+4 −14
Original line number Diff line number Diff line
@@ -124,7 +124,6 @@ typedef const std::function<void(std::string)>& fail_fn_t;
static pid_t gSystemServerPid = 0;

static constexpr const char* kVoldAppDataIsolation = "persist.sys.vold_app_data_isolation_enabled";
static constexpr const char* kPropFuse = "persist.sys.fuse";
static const char kZygoteClassName[] = "com/android/internal/os/Zygote";
static jclass gZygoteClass;
static jmethodID gCallPostForkSystemServerHooks;
@@ -836,10 +835,8 @@ static void MountEmulatedStorage(uid_t uid, jint mount_mode,
  PrepareDir(user_source, 0710, user_id ? AID_ROOT : AID_SHELL,
             multiuser_get_uid(user_id, AID_EVERYBODY), fail_fn);

  bool isFuse = GetBoolProperty(kPropFuse, false);
  bool isAppDataIsolationEnabled = GetBoolProperty(kVoldAppDataIsolation, false);

  if (isFuse) {
  if (mount_mode == MOUNT_EXTERNAL_PASS_THROUGH) {
      const std::string pass_through_source = StringPrintf("/mnt/pass_through/%d", user_id);
      PrepareDir(pass_through_source, 0710, AID_ROOT, AID_MEDIA_RW, fail_fn);
@@ -853,13 +850,6 @@ static void MountEmulatedStorage(uid_t uid, jint mount_mode,
  } else {
      BindMount(user_source, "/storage", fail_fn);
  }
  } else {
    const std::string& storage_source = ExternalStorageViews[mount_mode];
    BindMount(storage_source, "/storage", fail_fn);

    // Mount user-specific symlink helper into place
    BindMount(user_source, "/storage/self", fail_fn);
  }
}

static bool NeedsNoRandomizeWorkaround() {
+27 −102
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ import static android.os.storage.OnObbStateChangeListener.ERROR_PERMISSION_DENIE
import static android.os.storage.OnObbStateChangeListener.MOUNTED;
import static android.os.storage.OnObbStateChangeListener.UNMOUNTED;
import static android.os.storage.StorageManager.PROP_FORCED_SCOPED_STORAGE_WHITELIST;
import static android.os.storage.StorageManager.PROP_FUSE;
import static android.os.storage.StorageManager.PROP_SETTINGS_FUSE;

import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readLongAttribute;
@@ -131,7 +129,6 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
import android.util.DataUnit;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -233,13 +230,6 @@ 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";
    private static final boolean DEFAULT_FUSE_ENABLED = true;

    @GuardedBy("mLock")
    private final Set<Integer> mFuseMountedUser = new ArraySet<>();

@@ -609,8 +599,6 @@ class StorageManagerService extends IStorageManager.Stub
    // Not guarded by a lock.
    private final StorageSessionController mStorageSessionController;

    private final boolean mIsFuseEnabled;

    private final boolean mVoldAppDataIsolationEnabled;

    @GuardedBy("mLock")
@@ -926,7 +914,6 @@ class StorageManagerService extends IStorageManager.Stub
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                mContext.getMainExecutor(), (properties) -> {
                    refreshIsolatedStorageSettings();
                    refreshFuseSettings();
                });
        refreshIsolatedStorageSettings();
    }
@@ -992,27 +979,6 @@ 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) {
            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) {
            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 by direct adjustment of persist.sys.fflag.override.settings_fuse
    }

    /**
     * MediaProvider has a ton of code that makes assumptions about storage
     * paths never changing, so we outright kill them to pick up new state.
@@ -1091,13 +1057,9 @@ class StorageManagerService extends IStorageManager.Stub
            final UserManager userManager = mContext.getSystemService(UserManager.class);
            final List<UserInfo> users = userManager.getUsers();

            if (mIsFuseEnabled) {
            mStorageSessionController.onReset(mVold, () -> {
                mHandler.removeCallbacksAndMessages(null);
            });
            } else {
                killMediaProvider(users);
            }

            final int[] systemUnlockedUsers;
            synchronized (mLock) {
@@ -1490,8 +1452,7 @@ class StorageManagerService extends IStorageManager.Stub
        final ActivityManagerInternal amInternal =
                LocalServices.getService(ActivityManagerInternal.class);

        if (mIsFuseEnabled && vol.mountUserId >= 0
                && !amInternal.isUserRunning(vol.mountUserId, 0)) {
        if (vol.mountUserId >= 0 && !amInternal.isUserRunning(vol.mountUserId, 0)) {
            Slog.d(TAG, "Ignoring volume " + vol.getId() + " because user "
                    + Integer.toString(vol.mountUserId) + " is no longer running.");
            return;
@@ -1803,11 +1764,7 @@ class StorageManagerService extends IStorageManager.Stub
        SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE_SNAPSHOT, Boolean.toString(
                SystemProperties.getBoolean(StorageManager.PROP_ISOLATED_STORAGE, true)));

        // 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, DEFAULT_FUSE_ENABLED);
        mVoldAppDataIsolationEnabled = mIsFuseEnabled && SystemProperties.getBoolean(
        mVoldAppDataIsolationEnabled = SystemProperties.getBoolean(
                ANDROID_VOLD_APP_DATA_ISOLATION_ENABLED_PROPERTY, false);
        mContext = context;
        mResolver = mContext.getContentResolver();
@@ -1821,7 +1778,7 @@ class StorageManagerService extends IStorageManager.Stub
        // Add OBB Action Handler to StorageManagerService thread.
        mObbActionHandler = new ObbActionHandler(IoThread.get().getLooper());

        mStorageSessionController = new StorageSessionController(mContext, mIsFuseEnabled);
        mStorageSessionController = new StorageSessionController(mContext);

        mInstaller = new Installer(mContext);
        mInstaller.onStart();
@@ -1869,26 +1826,6 @@ class StorageManagerService extends IStorageManager.Stub
                PackageManager.FEATURE_AUTOMOTIVE);
    }

    /**
     *  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(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));
            // Then perform hard reboot to kick policy into place
            mContext.getSystemService(PowerManager.class).reboot("fuse_prop");
        }
    }

    private void start() {
        connectStoraged();
        connectVold();
@@ -1987,15 +1924,6 @@ class StorageManagerService extends IStorageManager.Stub
        if (provider != null) {
            mExternalStorageAuthorityAppId = UserHandle.getAppId(provider.applicationInfo.uid);
        }

        if (!mIsFuseEnabled) {
            try {
                mIAppOpsService.startWatchingMode(OP_REQUEST_INSTALL_PACKAGES, null,
                        mAppOpsCallback);
                mIAppOpsService.startWatchingMode(OP_LEGACY_STORAGE, null, mAppOpsCallback);
            } catch (RemoteException e) {
            }
        }
    }

    private ProviderInfo getProviderInfo(String authority) {
@@ -2071,7 +1999,6 @@ class StorageManagerService extends IStorageManager.Stub
    private void bootCompleted() {
        mBootCompleted = true;
        mHandler.obtainMessage(H_BOOT_COMPLETED).sendToTarget();
        updateFusePropFromSettings();
    }

    private void handleBootCompleted() {
@@ -4269,14 +4196,14 @@ class StorageManagerService extends IStorageManager.Stub
                return Zygote.MOUNT_EXTERNAL_NONE;
            }

            if (mIsFuseEnabled && mStorageManagerInternal.isExternalStorageService(uid)) {
            if (mStorageManagerInternal.isExternalStorageService(uid)) {
                // Determine if caller requires pass_through mount; note that we do this for
                // all processes that share a UID with MediaProvider; but this is fine, since
                // those processes anyway share the same rights as MediaProvider.
                return Zygote.MOUNT_EXTERNAL_PASS_THROUGH;
            }

            if (mIsFuseEnabled && (mDownloadsAuthorityAppId == UserHandle.getAppId(uid)
            if ((mDownloadsAuthorityAppId == UserHandle.getAppId(uid)
                    || mExternalStorageAuthorityAppId == UserHandle.getAppId(uid))) {
                // DownloadManager can write in app-private directories on behalf of apps;
                // give it write access to Android/
@@ -4286,7 +4213,7 @@ class StorageManagerService extends IStorageManager.Stub

            final boolean hasMtp = mIPackageManager.checkUidPermission(ACCESS_MTP, uid) ==
                    PERMISSION_GRANTED;
            if (mIsFuseEnabled && hasMtp) {
            if (hasMtp) {
                ApplicationInfo ai = mIPackageManager.getApplicationInfo(packageName,
                        0, UserHandle.getUserId(uid));
                if (ai != null && ai.isSignedWithPlatformKey()) {
@@ -4749,7 +4676,6 @@ class StorageManagerService extends IStorageManager.Stub
        public void onAppOpsChanged(int code, int uid, @Nullable String packageName, int mode) {
            final long token = Binder.clearCallingIdentity();
            try {
                if (mIsFuseEnabled) {
                // When using FUSE, we may need to kill the app if the op changes
                switch(code) {
                    case OP_REQUEST_INSTALL_PACKAGES:
@@ -4770,7 +4696,6 @@ class StorageManagerService extends IStorageManager.Stub
                        updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED);
                        return;
                }
                }

                if (mode == MODE_ALLOWED && (code == OP_READ_EXTERNAL_STORAGE
                                || code == OP_WRITE_EXTERNAL_STORAGE
Loading