diff options
author | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-06 19:02:01 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-06 19:02:01 +0000 |
commit | 42ba4e7941988adfe75ca02e1e415b2bcce5861b (patch) | |
tree | 5518f8262cb4e1ad2b4d2dcf7d1bbf177d61e126 | |
parent | 4979b01afdee0de92e670a5a728052d2ccd83133 (diff) | |
parent | 71a47642ed4d36120b8ad5f39ac94d37f868646e (diff) |
Merge "Avoid hardcoding /storage/emulated/0 in memory metrics test." am: 71a47642ed
Change-Id: I25f46e60f9b8eae3a6ca57e8cbd8f4d547f56416
-rw-r--r-- | metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java b/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java index 57348f9bc9..e96bc72c6e 100644 --- a/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java +++ b/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java @@ -30,8 +30,7 @@ import com.android.tradefed.util.FileUtil; import java.io.File; import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.Instant; /** * Helper class that runs the metric instrumentations on a test device. @@ -49,12 +48,8 @@ class MetricsRunner { */ static MetricsRunner create(ITestDevice testDevice, TestLogData logs) throws DeviceNotAvailableException { - // TODO(b/145514052): Work out how to get this dynamically rather than hard-coding. - // In theory it should be possible to do this with - // testDevice.executeShellCommand("echo -n ${EXTERNAL_STORAGE}"); - // but the value returned by that call ("/sdcard") no longer works. - // Until that issue is resolved, it should be safe to assume the following path: - String deviceParentDirectory = "/storage/emulated/0"; + String deviceParentDirectory = + testDevice.executeShellCommand("echo -n ${EXTERNAL_STORAGE}"); return new MetricsRunner(testDevice, deviceParentDirectory, logs); } @@ -247,10 +242,14 @@ class MetricsRunner { } } + /** + * Returns the ISO 8601 form of the current time in UTC, for use as a timestamp in filenames. + * (Note that using UTC avoids an issue where the timezone indicator includes a + sign for the + * offset, which triggers an issue with URL encoding in tradefed, which causes the calls to + * {@code testDevice.pullFile()} to fail. See b/149018916.) + */ private static String getCurrentTimeIso8601() { - SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - Date now = new Date(); - return iso8601Format.format(now); + return Instant.now().toString(); } /** |