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

Commit 90dcdb21 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Local and remote isolated storage feature flags."

parents 860ed7c6 b0c363b2
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -282,14 +282,31 @@ public final class Sm {
                StorageManager.DEBUG_VIRTUAL_DISK);
    }

    public void runIsolatedStorage() throws RemoteException {
        final boolean enableIsolatedStorage = Boolean.parseBoolean(nextArg());
    public void runIsolatedStorage() {
        final int value;
        final int mask = StorageManager.DEBUG_ISOLATED_STORAGE_FORCE_ON
                | StorageManager.DEBUG_ISOLATED_STORAGE_FORCE_OFF;
        switch (nextArg()) {
            case "on":
            case "true":
                value = StorageManager.DEBUG_ISOLATED_STORAGE_FORCE_ON;
                break;
            case "off":
                value = StorageManager.DEBUG_ISOLATED_STORAGE_FORCE_OFF;
                break;
            case "default":
            case "false":
                value = 0;
                break;
            default:
                return;
        }

        // 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);
                mSm.setDebugFlags(value, mask);
            } catch (RemoteException e) {
                Log.e(TAG, "Encountered an error!", e);
            }
@@ -334,7 +351,7 @@ 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("       sm set-isolated-storage [on|off|default]");
        System.err.println("");
        return 1;
    }
+7 −23
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.util.Slog;
import android.webkit.MimeTypeMap;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.SizedInputStream;

import libcore.io.IoUtils;
@@ -110,8 +111,6 @@ public class FileUtils {
        public static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+");
    }

    private static final File[] EMPTY = new File[0];

    // non-final so it can be toggled by Robolectric's ShadowFileUtils
    private static boolean sEnableCopyOptimizations = true;

@@ -1164,35 +1163,20 @@ public class FileUtils {

    /** {@hide} */
    public static @NonNull String[] listOrEmpty(@Nullable File dir) {
        if (dir == null) return EmptyArray.STRING;
        final String[] res = dir.list();
        if (res != null) {
            return res;
        } else {
            return EmptyArray.STRING;
        }
        return (dir != null) ? ArrayUtils.defeatNullable(dir.list())
                : EmptyArray.STRING;
    }

    /** {@hide} */
    public static @NonNull File[] listFilesOrEmpty(@Nullable File dir) {
        if (dir == null) return EMPTY;
        final File[] res = dir.listFiles();
        if (res != null) {
            return res;
        } else {
            return EMPTY;
        }
        return (dir != null) ? ArrayUtils.defeatNullable(dir.listFiles())
                : ArrayUtils.EMPTY_FILE;
    }

    /** {@hide} */
    public static @NonNull File[] listFilesOrEmpty(@Nullable File dir, FilenameFilter filter) {
        if (dir == null) return EMPTY;
        final File[] res = dir.listFiles(filter);
        if (res != null) {
            return res;
        } else {
            return EMPTY;
        }
        return (dir != null) ? ArrayUtils.defeatNullable(dir.listFiles(filter))
                : ArrayUtils.EMPTY_FILE;
    }

    /** {@hide} */
+27 −1
Original line number Diff line number Diff line
@@ -25,10 +25,15 @@ import android.util.MutableInt;

import com.android.internal.annotations.GuardedBy;

import libcore.util.HexEncoding;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;


/**
 * Gives access to the system properties store.  The system properties
 * store contains a list of string key-value pairs.
@@ -232,6 +237,27 @@ public class SystemProperties {
        native_report_sysprop_change();
    }

    /**
     * Return a {@code SHA-1} digest of the given keys and their values as a
     * hex-encoded string. The ordering of the incoming keys doesn't change the
     * digest result.
     *
     * @hide
     */
    public static @NonNull String digestOf(@NonNull String... keys) {
        Arrays.sort(keys);
        try {
            final MessageDigest digest = MessageDigest.getInstance("SHA-1");
            for (String key : keys) {
                final String item = key + "=" + get(key) + "\n";
                digest.update(item.getBytes(StandardCharsets.UTF_8));
            }
            return HexEncoding.encodeToString(digest.digest()).toLowerCase();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

    private SystemProperties() {
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -226,7 +226,9 @@ public class StorageManager {
    /** {@hide} */
    public static final int DEBUG_VIRTUAL_DISK = 1 << 5;
    /** {@hide} */
    public static final int DEBUG_ISOLATED_STORAGE = 1 << 6;
    public static final int DEBUG_ISOLATED_STORAGE_FORCE_ON = 1 << 6;
    /** {@hide} */
    public static final int DEBUG_ISOLATED_STORAGE_FORCE_OFF = 1 << 7;

    /** {@hide} */
    public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
+5 −0
Original line number Diff line number Diff line
@@ -12964,6 +12964,11 @@ public final class Settings {
        public static final String CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED =
                "content_capture_service_explicitly_enabled";
        /** {@hide} */
        public static final String ISOLATED_STORAGE_LOCAL = "isolated_storage_local";
        /** {@hide} */
        public static final String ISOLATED_STORAGE_REMOTE = "isolated_storage_remote";
        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
Loading