summaryrefslogtreecommitdiff
path: root/cmds/sm
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2017-03-25 23:14:06 -0600
committerJeff Sharkey <jsharkey@android.com>2017-03-25 23:26:21 -0600
commite53e2d9576cbcf6fc2bd9c8674e162bef7297226 (patch)
treee53df1468009a650d8719220756b7feca63e6fa2 /cmds/sm
parent20fd49d8c76fb93e721388f7e66761cb1c2d1c20 (diff)
Add a new "virtual disk" feature.
It's extremely difficult to test storage related logic on devices that don't have physical SD card slots. So to support better debugging and testing, add a new "virtual disk" feature which mounts a 512MB file through loop device. Also move ParcelFileDescriptor.open() over to using Os.open() so that it gets StrictMode treatment. Bug: 34903607 Test: builds, boots, virtual disk works Change-Id: I072a3a412cfcc8a2a3472919b7273a1ed794fd98
Diffstat (limited to 'cmds/sm')
-rw-r--r--cmds/sm/src/com/android/commands/sm/Sm.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmds/sm/src/com/android/commands/sm/Sm.java b/cmds/sm/src/com/android/commands/sm/Sm.java
index db3772da9e4f..658d662de5e1 100644
--- a/cmds/sm/src/com/android/commands/sm/Sm.java
+++ b/cmds/sm/src/com/android/commands/sm/Sm.java
@@ -94,6 +94,8 @@ public final class Sm {
runGetFbeMode();
} else if ("fstrim".equals(op)) {
runFstrim();
+ } else if ("set-virtual-disk".equals(op)) {
+ runSetVirtualDisk();
} else {
throw new IllegalArgumentException();
}
@@ -225,6 +227,12 @@ public final class Sm {
mSm.fstrim(0);
}
+ public void runSetVirtualDisk() throws RemoteException {
+ final boolean virtualDisk = Boolean.parseBoolean(nextArg());
+ mSm.setDebugFlags(virtualDisk ? StorageManager.DEBUG_VIRTUAL_DISK : 0,
+ StorageManager.DEBUG_VIRTUAL_DISK);
+ }
+
private String nextArg() {
if (mNextArg >= mArgs.length) {
return null;
@@ -240,6 +248,7 @@ public final class Sm {
System.err.println(" sm has-adoptable");
System.err.println(" sm get-primary-storage-uuid");
System.err.println(" sm set-force-adoptable [true|false]");
+ System.err.println(" sm set-virtual-disk [true|false]");
System.err.println("");
System.err.println(" sm partition DISK [public|private|mixed] [ratio]");
System.err.println(" sm mount VOLUME");