diff options
Diffstat (limited to 'src/com/android/tradefed/targetprep')
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 |