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..f6de2e28afb99f32dc36dc003c62bd39ec53651c 100755 |
| --- a/build/android/provision_devices.py |
| +++ b/build/android/provision_devices.py |
| @@ -113,6 +113,15 @@ def _ConfigureLocalProperties(device, java_debug=True): |
| # LOCAL_PROPERTIES_PATH = '/data/local.prop' |
| +def WriteAdbKeysFile(device, adb_keys_string): |
| + path_list = constants.ADB_KEYS_FILE.split('/') |
| + dir_path = '/'.join(path_list[:len(path_list)-1]) |
|
perezju
2015/02/25 09:35:41
nit: maybe that's just me, but I would go for:
d
jbudorick
2015/02/25 14:09:07
I didn't know about posixpath. We should be using
navabi
2015/02/25 18:57:25
Yeah I don't like this split. But how about using:
jbudorick
2015/02/25 21:47:38
It depends on the path being manipulated:
- for h
|
| + 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 +140,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 +161,15 @@ def ProvisionDevice(device, options): |
| else: |
| reboot_timeout = _DEFAULT_TIMEOUTS.PRE_LOLLIPOP |
| + if options.adb_key_files: |
| + adb_keys = set() |
|
perezju
2015/02/25 09:35:41
nit: does it really need to be a set? do we expect
navabi
2015/02/25 18:57:25
Not the way the current adb keys on the host are,
|
| + for adb_key_file in options.adb_key_files: |
| + with open(adb_key_file, 'r') as f: |
| + adb_public_key = f.readlines()[0] |
|
perezju
2015/02/25 09:35:41
why do we keep only the first line? (earlier versi
navabi
2015/02/25 18:57:25
Because before we were reading the adb keys file o
|
| + adb_keys.add(adb_public_key) |
| + adb_key_contents = '\n'.join(adb_keys) |
| + WriteAdbKeysFile(device, adb_key_contents) |
|
jbudorick
2015/02/25 14:09:07
This will wipe existing keys from the device. Woul
navabi
2015/02/25 18:57:25
This will not cause problems before the hosts have
jbudorick
2015/02/25 21:47:38
This makes me a little nervous, but ok.
|
| + |
| try: |
| if not options.skip_wipe: |
| WipeDeviceIfPossible(device, reboot_timeout) |
| @@ -276,6 +288,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) |