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

Unified Diff: build/android/provision_devices.py

Issue 949323003: Write adb public key to devices during provision. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Write adb keys from $HOME/.android/ directory. Created 5 years, 10 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 | « no previous file | no next file » | 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 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()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698