diff options
author | Jeff Sharkey <jsharkey@google.com> | 2017-11-07 19:23:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-11-07 19:23:25 +0000 |
commit | 508cce3f4a6b1644bd2bff72e52d44466cdd2da6 (patch) | |
tree | bd986815a298da78e2733a484b4086b7dac9d49f /cmds/sm | |
parent | b54be8de65b09c85992b30dbb1d52032f0498b6d (diff) | |
parent | 7e19f53f75386eab289a2ddf33dd6619775d6f21 (diff) |
Merge "Abort long-running benchmarks, report progress."
Diffstat (limited to 'cmds/sm')
-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 { |