Chromium Code Reviews| Index: build/android/provision_devices.py |
| diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py |
| index 824e64202e78787d1096eedd73ddaa4e7b704dc1..a7994973d84dda1bb35b2d5ed1ca4bd7b5f56bca 100755 |
| --- a/build/android/provision_devices.py |
| +++ b/build/android/provision_devices.py |
| @@ -113,6 +113,14 @@ def _ConfigureLocalProperties(device, java_debug=True): |
| # LOCAL_PROPERTIES_PATH = '/data/local.prop' |
| +def WriteAdbKeysFile(device, adb_keys_string): |
| + dir_path = os.path.dirname(constants.ADB_KEYS_FILE) |
|
jbudorick
2015/02/25 21:47:39
Since this is a device path, not a host path, I th
navabi
2015/02/25 23:02:09
Done. Using posixpath.
|
| + device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) |
| + device.RunShellCommand('restorecon %s' % dir_path, as_root=True) |
| + device.WriteFile(constants.ADB_KEYS_FILE, adb_keys_string, as_root=True) |
| + device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE, |
| + as_root=True) |
| + |
| def WipeDeviceData(device): |
| """Wipes data from device, keeping only the adb_keys for authorization. |
| @@ -131,13 +139,7 @@ def WipeDeviceData(device): |
| adb_keys = device.ReadFile(constants.ADB_KEYS_FILE, as_root=True) |
| device.RunShellCommand('wipe data', as_root=True) |
| if device_authorized: |
| - path_list = constants.ADB_KEYS_FILE.split('/') |
| - dir_path = '/'.join(path_list[:len(path_list)-1]) |
| - device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) |
| - device.RunShellCommand('restorecon %s' % dir_path, as_root=True) |
| - device.WriteFile(constants.ADB_KEYS_FILE, adb_keys, as_root=True) |
| - device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE, |
| - as_root=True) |
| + WriteAdbKeysFile(device, adb_keys) |
| def WipeDeviceIfPossible(device, timeout): |
| @@ -158,6 +160,15 @@ def ProvisionDevice(device, options): |
| else: |
| reboot_timeout = _DEFAULT_TIMEOUTS.PRE_LOLLIPOP |
| + if options.adb_key_files: |
| + adb_keys = set() |
| + for adb_key_file in options.adb_key_files: |
| + with open(adb_key_file, 'r') as f: |
| + adb_public_keys = f.readlines() |
| + adb_keys.update(adb_public_keys) |
| + adb_key_contents = '\n'.join(adb_keys) |
| + WriteAdbKeysFile(device, adb_key_contents) |
|
jbudorick
2015/02/25 21:47:38
optional nit: these two lines could be collapsed i
navabi
2015/02/25 23:02:09
Done.
|
| + |
| try: |
| if not options.skip_wipe: |
| WipeDeviceIfPossible(device, reboot_timeout) |
| @@ -276,6 +287,8 @@ def main(): |
| parser.add_argument('-r', '--auto-reconnect', action='store_true', |
| help='push binary which will reboot the device on adb' |
| ' disconnections') |
| + parser.add_argument('--adb-key-files', type=str, nargs='+', |
| + help='list of adb keys to push to device') |
| args = parser.parse_args() |
| constants.SetBuildType(args.target) |