aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tradefed/targetprep
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2016-05-12 14:21:11 -0700
committerGuang Zhu <guangzhu@google.com>2016-05-12 18:39:20 -0700
commit808cc9a8f0422b1a87a66b3f2f0d2ceef9155a2f (patch)
tree61afc368772ded2044744b8163718568fc25caed /src/com/android/tradefed/targetprep
parent3f22417d8e9a231a0ff31a1ee60f03b8404fc4b5 (diff)
downloadtradefederation-808cc9a8f0422b1a87a66b3f2f0d2ceef9155a2f.tar.gz
change device wiping to `fastboot -w` directly
In the past, device wiping equates to format/erase of userdata and cache. However, newer devices may not have cache partition, and `fastboot -w` has proper support for erasing and recreating the applicable partitions, so this change switches the approach for device wiping. Change-Id: I3e8c3353eaff034b18a0f56fb217be5d3a9ea485
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r--src/com/android/tradefed/targetprep/DeviceCleaner.java3
-rw-r--r--src/com/android/tradefed/targetprep/DeviceWiper.java7
-rw-r--r--src/com/android/tradefed/targetprep/FastbootDeviceFlasher.java23
3 files changed, 26 insertions, 7 deletions
diff --git a/src/com/android/tradefed/targetprep/DeviceCleaner.java b/src/com/android/tradefed/targetprep/DeviceCleaner.java
index e2d1c184d..60024f26a 100644
--- a/src/com/android/tradefed/targetprep/DeviceCleaner.java
+++ b/src/com/android/tradefed/targetprep/DeviceCleaner.java
@@ -104,8 +104,7 @@ public class DeviceCleaner implements ITargetCleaner {
break;
case FORMAT:
device.rebootIntoBootloader();
- device.executeLongFastbootCommand("format", "cache");
- device.executeLongFastbootCommand("format", "userdata");
+ device.executeLongFastbootCommand("-w");
device.executeFastbootCommand("reboot");
device.waitForDeviceAvailable();
break;
diff --git a/src/com/android/tradefed/targetprep/DeviceWiper.java b/src/com/android/tradefed/targetprep/DeviceWiper.java
index b3e1663c8..d916c364d 100644
--- a/src/com/android/tradefed/targetprep/DeviceWiper.java
+++ b/src/com/android/tradefed/targetprep/DeviceWiper.java
@@ -56,8 +56,11 @@ public class DeviceWiper implements ITargetPreparer {
}
private void doFormat(ITestDevice device) throws DeviceNotAvailableException, TargetSetupError {
- performFastbootOp(device, "format", "cache");
- performFastbootOp(device, "format", "userdata");
+ CLog.d("Attempting fastboot wiping");
+ CommandResult r = device.executeLongFastbootCommand("-w");
+ if (r.getStatus() != CommandStatus.SUCCESS) {
+ throw new TargetSetupError(String.format("fastboot wiping failed: %s", r.getStderr()));
+ }
}
private void doErase(ITestDevice device) throws DeviceNotAvailableException, TargetSetupError {
diff --git a/src/com/android/tradefed/targetprep/FastbootDeviceFlasher.java b/src/com/android/tradefed/targetprep/FastbootDeviceFlasher.java
index 75c7e5ee1..88575d2e2 100644
--- a/src/com/android/tradefed/targetprep/FastbootDeviceFlasher.java
+++ b/src/com/android/tradefed/targetprep/FastbootDeviceFlasher.java
@@ -119,15 +119,32 @@ public class FastbootDeviceFlasher implements IDeviceFlasher {
device.rebootIntoBootloader();
downloadFlashingResources(device, deviceBuild);
-
+ handleUserDataFlashing(device, deviceBuild);
checkAndFlashBootloader(device, deviceBuild);
checkAndFlashBaseband(device, deviceBuild);
- flashUserData(device, deviceBuild);
- wipeCache(device);
checkAndFlashSystem(device, systemBuildId, systemBuildFlavor, deviceBuild);
}
/**
+ * Handle flashing of userdata/cache partition
+ * @param device the {@link ITestDevice} to flash
+ * @param deviceBuild the {@link IDeviceBuildInfo} that contains the files to flash
+ * @throws DeviceNotAvailableException
+ * @throws TargetSetupError
+ */
+ protected void handleUserDataFlashing(ITestDevice device, IDeviceBuildInfo deviceBuild)
+ throws DeviceNotAvailableException, TargetSetupError {
+ if (UserDataFlashOption.FORCE_WIPE.equals(mUserDataFlashOption) ||
+ UserDataFlashOption.WIPE.equals(mUserDataFlashOption)) {
+ CommandResult result = device.executeFastbootCommand("-w");
+ handleFastbootResult(device, result, "-w");
+ } else {
+ flashUserData(device, deviceBuild);
+ wipeCache(device);
+ }
+ }
+
+ /**
* Flash an individual partition of a device
*
* @param device the {@link ITestDevice} to flash