Loading cmds/sm/src/com/android/commands/sm/Sm.java +22 −5 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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; } Loading core/java/android/os/FileUtils.java +7 −23 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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} */ Loading core/java/android/os/SystemProperties.java +27 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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() { } } core/java/android/os/storage/StorageManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -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; Loading core/java/android/provider/Settings.java +5 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
cmds/sm/src/com/android/commands/sm/Sm.java +22 −5 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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; } Loading
core/java/android/os/FileUtils.java +7 −23 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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} */ Loading
core/java/android/os/SystemProperties.java +27 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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() { } }
core/java/android/os/storage/StorageManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
core/java/android/provider/Settings.java +5 −0 Original line number Diff line number Diff line Loading @@ -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