diff options
author | Jeff Sharkey <jsharkey@android.com> | 2017-11-06 13:54:11 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2017-11-07 09:51:53 -0700 |
commit | 7e19f53f75386eab289a2ddf33dd6619775d6f21 (patch) | |
tree | ff9dc83f1de638ecdc3450f587ed7d5903ab92d1 /cmds/sm/src | |
parent | aa422681a68e8ec7cdfce7e543295548a528f289 (diff) |
Abort long-running benchmarks, report progress.
A typical storage device finishes the benchmark in under 10 seconds,
but some extremely slow devices can take minutes, resulting in a
confusing UX that looks like we've frozen. Even worse, we keep
churning through all that I/O even though we know the device will
blow past our user-warning threshold.
So periodically check if we've timed out, and also use that to report
progress up into the Settings UI.
Test: manual
Bug: 62201209, 65639764, 67055204
Change-Id: Id28e63a7ea1476d83184abab5aea737a1d193f3a
Diffstat (limited to 'cmds/sm/src')
-rw-r--r-- | cmds/sm/src/com/android/commands/sm/Sm.java | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/cmds/sm/src/com/android/commands/sm/Sm.java b/cmds/sm/src/com/android/commands/sm/Sm.java index a9a4118a8e98..699de94a0240 100644 --- a/cmds/sm/src/com/android/commands/sm/Sm.java +++ b/cmds/sm/src/com/android/commands/sm/Sm.java @@ -20,6 +20,9 @@ import static android.os.storage.StorageManager.PROP_ADOPTABLE_FBE; import static android.os.storage.StorageManager.PROP_HAS_ADOPTABLE; import static android.os.storage.StorageManager.PROP_VIRTUAL_DISK; +import android.os.IBinder; +import android.os.IVoldTaskListener; +import android.os.PersistableBundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; @@ -29,6 +32,8 @@ import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.util.Log; +import java.util.concurrent.CompletableFuture; + public final class Sm { private static final String TAG = "Sm"; @@ -221,9 +226,23 @@ public final class Sm { mSm.format(volId); } - public void runBenchmark() throws RemoteException { + public void runBenchmark() throws Exception { final String volId = nextArg(); - mSm.benchmark(volId); + final CompletableFuture<PersistableBundle> result = new CompletableFuture<>(); + mSm.benchmark(volId, new IVoldTaskListener.Stub() { + @Override + public void onStatus(int status, PersistableBundle extras) { + // Ignored + } + + @Override + public void onFinished(int status, PersistableBundle extras) { + // Touch to unparcel + extras.size(); + result.complete(extras); + } + }); + System.out.println(result.get()); } public void runForget() throws RemoteException { @@ -235,8 +254,22 @@ public final class Sm { } } - public void runFstrim() throws RemoteException { - mSm.fstrim(0); + public void runFstrim() throws Exception { + final CompletableFuture<PersistableBundle> result = new CompletableFuture<>(); + mSm.fstrim(0, new IVoldTaskListener.Stub() { + @Override + public void onStatus(int status, PersistableBundle extras) { + // Ignored + } + + @Override + public void onFinished(int status, PersistableBundle extras) { + // Touch to unparcel + extras.size(); + result.complete(extras); + } + }); + System.out.println(result.get()); } public void runSetVirtualDisk() throws RemoteException { |