diff options
-rw-r--r-- | src/com/android/tradefed/sandbox/TradefedSandbox.java | 13 | ||||
-rw-r--r-- | src/com/android/tradefed/util/ZipUtil2.java | 14 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/com/android/tradefed/sandbox/TradefedSandbox.java b/src/com/android/tradefed/sandbox/TradefedSandbox.java index 7fa1f6293..7f1f8c442 100644 --- a/src/com/android/tradefed/sandbox/TradefedSandbox.java +++ b/src/com/android/tradefed/sandbox/TradefedSandbox.java @@ -136,7 +136,7 @@ public class TradefedSandbox implements ISandbox { // Prepare the context try { - mSerializedContext = SerializationUtil.serialize(context); + mSerializedContext = prepareContext(context); } catch (IOException e) { return e; } @@ -194,4 +194,15 @@ public class TradefedSandbox implements ISandbox { IRunUtil createRunUtil() { return new RunUtil(); } + + /** + * Prepare and serialize the {@link IInvocationContext}. + * + * @param context the {@link IInvocationContext} to be prepared. + * @return the serialized {@link IInvocationContext}. + * @throws IOException + */ + protected File prepareContext(IInvocationContext context) throws IOException { + return SerializationUtil.serialize(context); + } } diff --git a/src/com/android/tradefed/util/ZipUtil2.java b/src/com/android/tradefed/util/ZipUtil2.java index 17046e949..aa9256d48 100644 --- a/src/com/android/tradefed/util/ZipUtil2.java +++ b/src/com/android/tradefed/util/ZipUtil2.java @@ -72,6 +72,20 @@ public class ZipUtil2 { } /** + * Utility method to extract a zip file into a given directory. The zip file being presented as + * a {@link File}. + * + * @param zipFile a {@link File} pointing to a zip file. + * @param destDir the local dir to extract file to + * @throws IOException if failed to extract file + */ + public static void extractZip(File zipFile, File destDir) throws IOException { + try (ZipFile zip = new ZipFile(zipFile)) { + extractZip(zip, destDir); + } + } + + /** * Utility method to extract one specific file from zip file into a tmp file * * @param zipFile the {@link ZipFile} to extract |