aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tradefed/targetprep
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r--src/com/android/tradefed/targetprep/AltDirBehavior.java3
-rw-r--r--src/com/android/tradefed/targetprep/DefaultTestsZipInstaller.java2
-rw-r--r--src/com/android/tradefed/targetprep/FlashingResourcesParser.java5
-rw-r--r--src/com/android/tradefed/targetprep/FolderSaver.java110
-rw-r--r--src/com/android/tradefed/targetprep/NativeLeakCollector.java3
-rw-r--r--src/com/android/tradefed/targetprep/companion/CompanionAllocator.java3
-rw-r--r--src/com/android/tradefed/targetprep/companion/CompanionAwarePreparer.java2
-rw-r--r--src/com/android/tradefed/targetprep/companion/CompanionDeviceTracker.java2
8 files changed, 118 insertions, 12 deletions
diff --git a/src/com/android/tradefed/targetprep/AltDirBehavior.java b/src/com/android/tradefed/targetprep/AltDirBehavior.java
index f5e5cadcb..564f5784b 100644
--- a/src/com/android/tradefed/targetprep/AltDirBehavior.java
+++ b/src/com/android/tradefed/targetprep/AltDirBehavior.java
@@ -19,7 +19,8 @@ package com.android.tradefed.targetprep;
/**
* An enum to define alternative directory behaviors for various test artifact installers/pushers
* <p>
- * @see {@link TestAppInstallSetup}, {@link TestFilePushSetup}
+ * @see TestAppInstallSetup
+ * @see TestFilePushSetup
*/
public enum AltDirBehavior {
/**
diff --git a/src/com/android/tradefed/targetprep/DefaultTestsZipInstaller.java b/src/com/android/tradefed/targetprep/DefaultTestsZipInstaller.java
index c79dc3df3..96b4f1516 100644
--- a/src/com/android/tradefed/targetprep/DefaultTestsZipInstaller.java
+++ b/src/com/android/tradefed/targetprep/DefaultTestsZipInstaller.java
@@ -152,7 +152,7 @@ public class DefaultTestsZipInstaller implements ITestsZipInstaller {
/**
* Deletes userdata from device without toggling {@link RecoveryMode}.
* <p/>
- * Expects callers to have set device to {@link RecoveryMode.ONLINE}.
+ * Expects callers to have set device to {@link RecoveryMode#ONLINE}.
*/
private void doDeleteData(ITestDevice device) throws DeviceNotAvailableException,
TargetSetupError {
diff --git a/src/com/android/tradefed/targetprep/FlashingResourcesParser.java b/src/com/android/tradefed/targetprep/FlashingResourcesParser.java
index 2e07c3834..0655959f3 100644
--- a/src/com/android/tradefed/targetprep/FlashingResourcesParser.java
+++ b/src/com/android/tradefed/targetprep/FlashingResourcesParser.java
@@ -116,7 +116,7 @@ public class FlashingResourcesParser implements IFlashingResourcesParser {
* disable filtering.
*/
public FlashingResourcesParser(BufferedReader infoReader, Map<String, Constraint> c)
- throws TargetSetupError, IOException {
+ throws IOException {
mReqs = parseAndroidInfo(infoReader, c);
}
@@ -128,8 +128,7 @@ public class FlashingResourcesParser implements IFlashingResourcesParser {
* @param infoReader a {@link BufferedReader} containing the equivalent of android-info.txt to
* parse
*/
- public FlashingResourcesParser(BufferedReader infoReader) throws TargetSetupError,
- IOException {
+ public FlashingResourcesParser(BufferedReader infoReader) throws IOException {
this(infoReader, null);
}
diff --git a/src/com/android/tradefed/targetprep/FolderSaver.java b/src/com/android/tradefed/targetprep/FolderSaver.java
new file mode 100644
index 000000000..540fc930f
--- /dev/null
+++ b/src/com/android/tradefed/targetprep/FolderSaver.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tradefed.targetprep;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.ITestLogger;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.FileInputStreamSource;
+import com.android.tradefed.result.ITestLoggerReceiver;
+import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.result.LogDataType;
+import com.android.tradefed.util.FileUtil;
+import com.android.tradefed.util.StreamUtil;
+import com.android.tradefed.util.ZipUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A {@link ITargetCleaner} that pulls directories off device, compresses and saves it into logging
+ * backend.
+ */
+public class FolderSaver implements ITargetCleaner, ITestLoggerReceiver {
+
+ @Option(name = "device-path", description = "Location of directory on device to be pulled and "
+ + "logged, may be repeated.")
+ private List<String> mDevicePaths = new ArrayList<>();
+
+ private ITestLogger mTestLogger;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo)
+ throws TargetSetupError, BuildError, DeviceNotAvailableException {
+ // no-op
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setTestLogger(ITestLogger testLogger) {
+ mTestLogger = testLogger;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
+ throws DeviceNotAvailableException {
+ if (e instanceof DeviceNotAvailableException) {
+ CLog.i("Device %s not available, skipping.", device.getSerialNumber());
+ return;
+ }
+ if (mDevicePaths.isEmpty()) {
+ CLog.i("No device path provided, skipping.");
+ return;
+ }
+ for (String path : mDevicePaths) {
+ File tempDir = null;
+ try {
+ tempDir = FileUtil.createTempDir("tf-pulled-dir");
+ if (!device.pullDir(path, tempDir)) {
+ CLog.w("Failed to pull directory %s from device %s",
+ path, device.getSerialNumber());
+ } else {
+ File zip = null;
+ try {
+ zip = ZipUtil.createZip(tempDir);
+ InputStreamSource s = null;
+ try {
+ s = new FileInputStreamSource(zip);
+ mTestLogger.testLog(path, LogDataType.ZIP, s);
+ } finally {
+ StreamUtil.cancel(s);
+ }
+ } finally {
+ FileUtil.deleteFile(zip);
+ }
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException("exception while saving device directory", ioe);
+ } finally {
+ FileUtil.recursiveDelete(tempDir);
+ }
+ }
+ }
+}
diff --git a/src/com/android/tradefed/targetprep/NativeLeakCollector.java b/src/com/android/tradefed/targetprep/NativeLeakCollector.java
index 1298c6aab..9bc2e4e8d 100644
--- a/src/com/android/tradefed/targetprep/NativeLeakCollector.java
+++ b/src/com/android/tradefed/targetprep/NativeLeakCollector.java
@@ -26,12 +26,11 @@ import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ByteArrayInputStreamSource;
import com.android.tradefed.result.ITestLoggerReceiver;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.util.RunUtil;
import com.android.tradefed.util.StreamUtil;
import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
import java.util.List;
+import java.util.concurrent.TimeUnit;
/**
* A {@link ITargetCleaner} that runs 'dumpsys meminfo --unreachable -a' to identify the unreachable
diff --git a/src/com/android/tradefed/targetprep/companion/CompanionAllocator.java b/src/com/android/tradefed/targetprep/companion/CompanionAllocator.java
index 5d1a0cbde..e70e0cd29 100644
--- a/src/com/android/tradefed/targetprep/companion/CompanionAllocator.java
+++ b/src/com/android/tradefed/targetprep/companion/CompanionAllocator.java
@@ -52,8 +52,7 @@ public abstract class CompanionAllocator implements ITargetCleaner {
}
/**
- * Describe the selection options for the companion device
- * @return
+ * Describe the {@link DeviceSelectionOptions} for the companion device
*/
protected abstract DeviceSelectionOptions getCompanionDeviceSelectionOptions();
diff --git a/src/com/android/tradefed/targetprep/companion/CompanionAwarePreparer.java b/src/com/android/tradefed/targetprep/companion/CompanionAwarePreparer.java
index 2b434df77..451071086 100644
--- a/src/com/android/tradefed/targetprep/companion/CompanionAwarePreparer.java
+++ b/src/com/android/tradefed/targetprep/companion/CompanionAwarePreparer.java
@@ -33,7 +33,7 @@ public abstract class CompanionAwarePreparer implements ITargetPreparer {
* Retrieves the {@link ITestDevice} instance of companion device allocated for the primary
* {@link ITestDevice}
* @param primary
- * @return
+ * @return the {@link ITestDevice} instance of companion device allocated
* @throws TargetSetupError if no companion device has been allocated for the primary device
*/
protected ITestDevice getCompanion(ITestDevice primary) throws TargetSetupError {
diff --git a/src/com/android/tradefed/targetprep/companion/CompanionDeviceTracker.java b/src/com/android/tradefed/targetprep/companion/CompanionDeviceTracker.java
index 0d9b69053..2edd1f55e 100644
--- a/src/com/android/tradefed/targetprep/companion/CompanionDeviceTracker.java
+++ b/src/com/android/tradefed/targetprep/companion/CompanionDeviceTracker.java
@@ -43,7 +43,6 @@ public class CompanionDeviceTracker {
/**
* Retrieves singleton instance of the tracker
- * @return
*/
public static CompanionDeviceTracker getInstance() {
if (sInst == null) {
@@ -57,7 +56,6 @@ public class CompanionDeviceTracker {
*
* @param device the primary device. used to identify the companion device
* @param opt selection criteria
- * @param timeout time to wait before giving up on allocation
* @return the device allocated or <code>null</code> if none available
*/
public ITestDevice allocateCompanionDevice(ITestDevice device, DeviceSelectionOptions opt) {