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

This commit is contained in:
Abhijeet Kaur
2020-07-09 13:11:15 +00:00
committed by Android (Google) Code Review
7 changed files with 34 additions and 139 deletions

View File

@@ -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";
}

View File

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

View File

@@ -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");

View File

@@ -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,29 +835,20 @@ 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) {
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);
BindMount(pass_through_source, "/storage", fail_fn);
} else if (mount_mode == MOUNT_EXTERNAL_INSTALLER) {
} else if (mount_mode == MOUNT_EXTERNAL_INSTALLER) {
const std::string installer_source = StringPrintf("/mnt/installer/%d", user_id);
BindMount(installer_source, "/storage", fail_fn);
} else if (isAppDataIsolationEnabled && mount_mode == MOUNT_EXTERNAL_ANDROID_WRITABLE) {
} else if (isAppDataIsolationEnabled && mount_mode == MOUNT_EXTERNAL_ANDROID_WRITABLE) {
const std::string writable_source = StringPrintf("/mnt/androidwritable/%d", user_id);
BindMount(writable_source, "/storage", fail_fn);
} 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);
BindMount(user_source, "/storage", fail_fn);
}
}

View File

@@ -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);
}
mStorageSessionController.onReset(mVold, () -> {
mHandler.removeCallbacksAndMessages(null);
});
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,27 +4676,25 @@ 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:
// Always kill regardless of op change, to remount apps /storage
// When using FUSE, we may need to kill the app if the op changes
switch(code) {
case OP_REQUEST_INSTALL_PACKAGES:
// Always kill regardless of op change, to remount apps /storage
killAppForOpChange(code, uid);
return;
case OP_MANAGE_EXTERNAL_STORAGE:
if (mode != MODE_ALLOWED) {
// Only kill if op is denied, to lose external_storage gid
// Killing when op is granted to pickup the gid automatically,
// results in a bad UX, especially since the gid only gives access
// to unreliable volumes, USB OTGs that are rarely mounted. The app
// will get the external_storage gid on next organic restart.
killAppForOpChange(code, uid);
return;
case OP_MANAGE_EXTERNAL_STORAGE:
if (mode != MODE_ALLOWED) {
// Only kill if op is denied, to lose external_storage gid
// Killing when op is granted to pickup the gid automatically,
// results in a bad UX, especially since the gid only gives access
// to unreliable volumes, USB OTGs that are rarely mounted. The app
// will get the external_storage gid on next organic restart.
killAppForOpChange(code, uid);
}
return;
case OP_LEGACY_STORAGE:
updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED);
return;
}
}
return;
case OP_LEGACY_STORAGE:
updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED);
return;
}
if (mode == MODE_ALLOWED && (code == OP_READ_EXTERNAL_STORAGE

View File

@@ -110,7 +110,6 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ProcessMap;
import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.os.RuntimeInit;
import com.android.internal.os.Zygote;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FrameworkStatsLog;
@@ -155,9 +154,6 @@ public final class ProcessList {
static final String ANDROID_VOLD_APP_DATA_ISOLATION_ENABLED_PROPERTY =
"persist.sys.vold_app_data_isolation_enabled";
// A system property to control if fuse is enabled.
static final String ANDROID_FUSE_ENABLED = "persist.sys.fuse";
// The minimum time we allow between crashes, for us to consider this
// application to be bad and stop and its services and reject broadcasts.
static final int MIN_CRASH_INTERVAL = 60 * 1000;
@@ -719,13 +715,8 @@ public final class ProcessList {
// want some apps enabled while some apps disabled
mAppDataIsolationEnabled =
SystemProperties.getBoolean(ANDROID_APP_DATA_ISOLATION_ENABLED_PROPERTY, true);
boolean fuseEnabled = SystemProperties.getBoolean(ANDROID_FUSE_ENABLED, false);
boolean voldAppDataIsolationEnabled = SystemProperties.getBoolean(
mVoldAppDataIsolationEnabled = SystemProperties.getBoolean(
ANDROID_VOLD_APP_DATA_ISOLATION_ENABLED_PROPERTY, false);
if (!fuseEnabled && voldAppDataIsolationEnabled) {
Slog.e(TAG, "Fuse is not enabled while vold app data isolation is enabled");
}
mVoldAppDataIsolationEnabled = fuseEnabled && voldAppDataIsolationEnabled;
mAppDataIsolationWhitelistedApps = new ArrayList<>(
SystemConfig.getInstance().getAppDataIsolationWhitelistedApps());

View File

@@ -53,16 +53,14 @@ public final class StorageSessionController {
private final Context mContext;
@GuardedBy("mLock")
private final SparseArray<StorageUserConnection> mConnections = new SparseArray<>();
private final boolean mIsFuseEnabled;
private volatile ComponentName mExternalStorageServiceComponent;
private volatile String mExternalStorageServicePackageName;
private volatile int mExternalStorageServiceAppId;
private volatile boolean mIsResetting;
public StorageSessionController(Context context, boolean isFuseEnabled) {
public StorageSessionController(Context context) {
mContext = Objects.requireNonNull(context);
mIsFuseEnabled = isFuseEnabled;
}
/**
@@ -361,6 +359,6 @@ public final class StorageSessionController {
}
private boolean shouldHandle(@Nullable VolumeInfo vol) {
return mIsFuseEnabled && !mIsResetting && (vol == null || isEmulatedOrPublic(vol));
return !mIsResetting && (vol == null || isEmulatedOrPublic(vol));
}
}