diff options
7 files changed, 34 insertions, 139 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index f77922812ba1..ab0761374570 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -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"; } diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index 0abf8ae352af..6b5eb16d7bff 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -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"; diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index 537498c44d5e..e338fd977f27 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -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"); diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 6e49c0dda1ad..b7c5289043d6 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -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); } } diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 18fb7a3144cf..84bd59b7730e 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -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(); } @@ -993,27 +980,6 @@ class StorageManagerService extends IStorageManager.Stub } /** - * 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 diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 5a0ea7586301..ebff0691c1f7 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -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()); diff --git a/services/core/java/com/android/server/storage/StorageSessionController.java b/services/core/java/com/android/server/storage/StorageSessionController.java index 37df5481d3c4..6dc1d6921dbb 100644 --- a/services/core/java/com/android/server/storage/StorageSessionController.java +++ b/services/core/java/com/android/server/storage/StorageSessionController.java @@ -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)); } } |