Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: build/android/provision_devices.py

Issue 255783008: Add option to wipe device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/provision_devices.py
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py
index 1faa4d22a8c3942ef0008c20038826e851cda85f..83c02a2a607a3fb75aed1c0258ac59571e9491bb 100755
--- a/build/android/provision_devices.py
+++ b/build/android/provision_devices.py
@@ -95,8 +95,8 @@ def WipeDeviceData(device):
After wiping data on a device that has been authorized, adb can still
communicate with the device, but after reboot the device will need to be
re-authorized because the adb keys file is stored in /data/misc/adb/.
- Thus, before reboot the adb_keys file is rewritten so the device does not need
- to be re-authorized.
+ Thus, adb_keys file is rewritten so the device does not need to be
+ re-authorized.
Arguments:
device: the device to wipe
@@ -105,15 +105,17 @@ def WipeDeviceData(device):
constants.ADB_KEYS_FILE)
if device_authorized:
adb_keys = device.old_interface.RunShellCommandWithSU(
- 'cat %s' % constants.ADB_KEYS_FILE)[0]
+ 'cat %s' % constants.ADB_KEYS_FILE)
device.old_interface.RunShellCommandWithSU('wipe data')
if device_authorized:
path_list = constants.ADB_KEYS_FILE.split('/')
dir_path = '/'.join(path_list[:len(path_list)-1])
device.old_interface.RunShellCommandWithSU('mkdir -p %s' % dir_path)
- adb_keys = device.old_interface.RunShellCommand(
- 'echo %s > %s' % (adb_keys, constants.ADB_KEYS_FILE))
- device.old_interface.Reboot()
+ device.old_interface.RunShellCommand('echo %s > %s' %
+ (adb_keys[0], constants.ADB_KEYS_FILE))
+ for adb_key in adb_keys[1:]:
+ device.old_interface.RunShellCommand(
+ 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE))
def ProvisionDevices(options):
@@ -152,6 +154,8 @@ def main(argv):
logging.basicConfig(level=logging.INFO)
parser = optparse.OptionParser()
+ parser.add_option('-w', '--wipe', action='store_true',
+ help='Wipe device data from all attached devices.')
parser.add_option('-d', '--device',
help='The serial number of the device to be provisioned')
parser.add_option('-t', '--target', default='Debug', help='The build target')
@@ -165,7 +169,14 @@ def main(argv):
print >> sys.stderr, 'Unused args %s' % args
return 1
- ProvisionDevices(options)
+ if options.wipe:
+ devices = android_commands.GetAttachedDevices()
+ for device_serial in devices:
+ device = device_utils.DeviceUtils(device_serial)
+ WipeDeviceData(device)
+ device_utils.RebootDevices()
+ else:
+ ProvisionDevices(options)
if __name__ == '__main__':
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698