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

Commit d9050d81 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by android-build-merger
Browse files

Merge "Give users and devices control over sdcardfs." into nyc-dev am: 7d66e831

am: 16e09761

* commit '16e09761':
  Give users and devices control over sdcardfs.

Change-Id: Ic311b3bf56f5e9417f9785dab25cbbd7ea148c30
parents 0132172c 16e09761
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ public final class Sm {
            runGetPrimaryStorageUuid();
        } else if ("set-force-adoptable".equals(op)) {
            runSetForceAdoptable();
        } else if ("set-sdcardfs".equals(op)) {
            runSetSdcardfs();
        } else if ("partition".equals(op)) {
            runPartition();
        } else if ("mount".equals(op)) {
@@ -141,6 +143,22 @@ public final class Sm {
                StorageManager.DEBUG_FORCE_ADOPTABLE);
    }

    public void runSetSdcardfs() throws RemoteException {
        final int mask = StorageManager.DEBUG_SDCARDFS_FORCE_ON
                | StorageManager.DEBUG_SDCARDFS_FORCE_OFF;
        switch (nextArg()) {
            case "on":
                mSm.setDebugFlags(StorageManager.DEBUG_SDCARDFS_FORCE_ON, mask);
                break;
            case "off":
                mSm.setDebugFlags(StorageManager.DEBUG_SDCARDFS_FORCE_OFF, mask);
                break;
            case "default":
                mSm.setDebugFlags(0, mask);
                break;
        }
    }

    public void runSetEmulateFbe() throws RemoteException {
        final boolean emulateFbe = Boolean.parseBoolean(nextArg());
        mSm.setDebugFlags(emulateFbe ? StorageManager.DEBUG_EMULATE_FBE : 0,
+6 −0
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ public class StorageManager {
    public static final String PROP_FORCE_ADOPTABLE = "persist.fw.force_adoptable";
    /** {@hide} */
    public static final String PROP_EMULATE_FBE = "persist.sys.emulate_fbe";
    /** {@hide} */
    public static final String PROP_SDCARDFS = "persist.sys.sdcardfs";

    /** {@hide} */
    public static final String UUID_PRIVATE_INTERNAL = null;
@@ -93,6 +95,10 @@ public class StorageManager {
    public static final int DEBUG_FORCE_ADOPTABLE = 1 << 0;
    /** {@hide} */
    public static final int DEBUG_EMULATE_FBE = 1 << 1;
    /** {@hide} */
    public static final int DEBUG_SDCARDFS_FORCE_ON = 1 << 2;
    /** {@hide} */
    public static final int DEBUG_SDCARDFS_FORCE_OFF = 1 << 3;

    // NOTE: keep in sync with installd
    /** {@hide} */
+22 −0
Original line number Diff line number Diff line
@@ -1984,6 +1984,28 @@ class MountService extends IMountService.Stub
                mHandler.obtainMessage(H_RESET).sendToTarget();
            }
        }

        if ((mask & (StorageManager.DEBUG_SDCARDFS_FORCE_ON
                | StorageManager.DEBUG_SDCARDFS_FORCE_OFF)) != 0) {
            final String value;
            if ((flags & StorageManager.DEBUG_SDCARDFS_FORCE_ON) != 0) {
                value = "force_on";
            } else if ((flags & StorageManager.DEBUG_SDCARDFS_FORCE_OFF) != 0) {
                value = "force_off";
            } else {
                value = "";
            }

            final long token = Binder.clearCallingIdentity();
            try {
                SystemProperties.set(StorageManager.PROP_SDCARDFS, value);

                // Reset storage to kick new setting into place
                mHandler.obtainMessage(H_RESET).sendToTarget();
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }

    @Override