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

Commit 3ab40f18 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add sm set-isolated-storage [true|false]"

parents 459e4069 be0febe4
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ public final class Sm {
            runFstrim();
        } else if ("set-virtual-disk".equals(op)) {
            runSetVirtualDisk();
        } else if ("set-isolated-storage".equals(op)) {
            runIsolatedStorage();
        } else {
            throw new IllegalArgumentException();
        }
@@ -278,6 +280,20 @@ public final class Sm {
                StorageManager.DEBUG_VIRTUAL_DISK);
    }

    public void runIsolatedStorage() throws RemoteException {
        final boolean enableIsolatedStorage = Boolean.parseBoolean(nextArg());
        // Toggling isolated-storage state will result in a device reboot. So to avoid this command
        // from erroring out (DeadSystemException), call setDebugFlags() in a separate thread.
        new Thread(() -> {
            try {
                mSm.setDebugFlags(enableIsolatedStorage ? StorageManager.DEBUG_ISOLATED_STORAGE : 0,
                        StorageManager.DEBUG_ISOLATED_STORAGE);
            } catch (RemoteException e) {
                Log.e(TAG, "Encountered an error!", e);
            }
        }).start();
    }

    public void runIdleMaint() throws RemoteException {
        final boolean im_run = "run".equals(nextArg());
        if (im_run) {
@@ -316,6 +332,8 @@ public final class Sm {
        System.err.println("");
        System.err.println("       sm set-emulate-fbe [true|false]");
        System.err.println("");
        System.err.println("       sm set-isolated-storage [true|false]");
        System.err.println("");
        return 1;
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -467,6 +467,14 @@ public class Environment {
        return new File(getDataPreloadsDirectory(), "file_cache");
    }

    /**
     * Returns location of packages cache directory.
     * {@hide}
     */
    public static File getPackageCacheDirectory() {
        return new File(getDataSystemDirectory(), "package_cache");
    }

    /**
     * Return the primary shared/external storage directory. This directory may
     * not currently be accessible if it has been mounted by the user on their
+7 −2
Original line number Diff line number Diff line
@@ -1156,11 +1156,16 @@ public class FileUtils {
    public static @Nullable File createDir(File baseDir, String name) {
        final File dir = new File(baseDir, name);

        return createDir(dir) ? dir : null;
    }

    /** @hide */
    public static boolean createDir(File dir) {
        if (dir.exists()) {
            return dir.isDirectory() ? dir : null;
            return dir.isDirectory();
        }

        return dir.mkdir() ? dir : null;
        return dir.mkdir();
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -225,6 +225,8 @@ public class StorageManager {
    public static final int DEBUG_SDCARDFS_FORCE_OFF = 1 << 4;
    /** {@hide} */
    public static final int DEBUG_VIRTUAL_DISK = 1 << 5;
    /** {@hide} */
    public static final int DEBUG_ISOLATED_STORAGE = 1 << 6;

    /** {@hide} */
    public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
+20 −0
Original line number Diff line number Diff line
@@ -2097,6 +2097,26 @@ class StorageManagerService extends IStorageManager.Stub
                Binder.restoreCallingIdentity(token);
            }
        }

        if ((mask & StorageManager.DEBUG_ISOLATED_STORAGE) != 0) {
            final boolean enabled = (flags & StorageManager.DEBUG_ISOLATED_STORAGE) != 0;

            final long token = Binder.clearCallingIdentity();
            try {
                SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE,
                        Boolean.toString(enabled));

                // Some of the storage related permissions get fiddled with during
                // package scanning. So, delete the package cache to force PackageManagerService
                // to do package scanning.
                FileUtils.deleteContents(Environment.getPackageCacheDirectory());

                // Perform hard reboot to kick policy into place
                mContext.getSystemService(PowerManager.class).reboot(null);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }

    @Override
Loading