Index: build/android/provision_devices.py |
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py |
index 824e64202e78787d1096eedd73ddaa4e7b704dc1..ed947c347fbe55f11f3081617caebb9770c04ec5 100755 |
--- a/build/android/provision_devices.py |
+++ b/build/android/provision_devices.py |
@@ -25,6 +25,7 @@ from pylib.device import device_blacklist |
from pylib.device import device_errors |
from pylib.device import device_utils |
from pylib.utils import run_tests_helper |
+from sets import Set |
sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, |
'third_party', 'android_testrunner')) |
@@ -126,20 +127,30 @@ def WipeDeviceData(device): |
Arguments: |
device: the device to wipe |
""" |
- device_authorized = device.FileExists(constants.ADB_KEYS_FILE) |
- if device_authorized: |
- adb_keys = device.ReadFile(constants.ADB_KEYS_FILE, as_root=True) |
+ adb_dir_exists = device.FileExists(os.path.dirname(constants.ADB_KEYS_FILE)) |
jbudorick
2015/02/24 23:44:49
I still think it'd be better to pass in a file via
navabi
2015/02/25 01:22:35
Done.
|
+ if adb_dir_exists: |
+ adb_key_files = [adb_key_file for adb_key_file in |
+ os.listdir('%s/.android' % os.environ['HOME']) |
+ if adb_key_file.endswith('adbkey.pub')] |
+ adb_keys = Set([]) |
+ for adb_key_file in adb_key_files: |
+ file_path = os.path.join(os.environ['HOME'], '.android', adb_key_file) |
+ with open(file_path, 'r') as f: |
+ adb_public_key = f.readlines() |
+ adb_keys.add(''.join(adb_public_key)) |
device.RunShellCommand('wipe data', as_root=True) |
- if device_authorized: |
+ if adb_dir_exists: |
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) |
+ adb_key_contents = '' |
+ for adb_key in adb_keys: |
jbudorick
2015/02/24 23:44:49
this is just
adb_key_contents = ''.join('%s\n'
navabi
2015/02/25 01:22:35
Done.
|
+ adb_key_contents = '%s\n%s' % (adb_key, adb_key_contents) |
+ device.WriteFile(constants.ADB_KEYS_FILE, adb_key_contents, as_root=True) |
device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE, |
as_root=True) |
- |
def WipeDeviceIfPossible(device, timeout): |
try: |
device.EnableRoot() |