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

Side by Side Diff: build/android/provision_devices.py

Issue 358993003: [Android] Switch to DeviceUtils versions of file functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « build/android/gyp/util/build_device.py ('k') | build/android/pylib/android_commands.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Provisions Android devices with settings required for bots. 7 """Provisions Android devices with settings required for bots.
8 8
9 Usage: 9 Usage:
10 ./provision_devices.py [-d <device serial number>] 10 ./provision_devices.py [-d <device serial number>]
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 # running at all. 65 # running at all.
66 device.KillAll('adb_reboot', blocking=True, timeout=2, retries=0) 66 device.KillAll('adb_reboot', blocking=True, timeout=2, retries=0)
67 except device_errors.CommandFailedError: 67 except device_errors.CommandFailedError:
68 # We can safely ignore the exception because we don't expect adb_reboot 68 # We can safely ignore the exception because we don't expect adb_reboot
69 # to be running. 69 # to be running.
70 pass 70 pass
71 # Push adb_reboot 71 # Push adb_reboot
72 print ' Pushing adb_reboot ...' 72 print ' Pushing adb_reboot ...'
73 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT, 73 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT,
74 'out/%s/adb_reboot' % target) 74 'out/%s/adb_reboot' % target)
75 device.old_interface.PushIfNeeded(adb_reboot, '/data/local/tmp/') 75 device.PushChangedFiles(adb_reboot, '/data/local/tmp/')
76 # Launch adb_reboot 76 # Launch adb_reboot
77 print ' Launching adb_reboot ...' 77 print ' Launching adb_reboot ...'
78 device.old_interface.GetAndroidToolStatusAndOutput( 78 device.old_interface.GetAndroidToolStatusAndOutput(
79 '/data/local/tmp/adb_reboot') 79 '/data/local/tmp/adb_reboot')
80 LaunchHostHeartbeat() 80 LaunchHostHeartbeat()
81 81
82 82
83 def _ConfigureLocalProperties(device, is_perf): 83 def _ConfigureLocalProperties(device, is_perf):
84 """Set standard readonly testing device properties prior to reboot.""" 84 """Set standard readonly testing device properties prior to reboot."""
85 local_props = [ 85 local_props = [
86 'ro.monkey=1', 86 'ro.monkey=1',
87 'ro.test_harness=1', 87 'ro.test_harness=1',
88 'ro.audio.silent=1', 88 'ro.audio.silent=1',
89 'ro.setupwizard.mode=DISABLED', 89 'ro.setupwizard.mode=DISABLED',
90 ] 90 ]
91 if not is_perf: 91 if not is_perf:
92 local_props.append('%s=all' % android_commands.JAVA_ASSERT_PROPERTY) 92 local_props.append('%s=all' % android_commands.JAVA_ASSERT_PROPERTY)
93 local_props.append('debug.checkjni=1') 93 local_props.append('debug.checkjni=1')
94 device.old_interface.SetProtectedFileContents( 94 device.WriteFile(
95 constants.DEVICE_LOCAL_PROPERTIES_PATH, 95 constants.DEVICE_LOCAL_PROPERTIES_PATH,
96 '\n'.join(local_props)) 96 '\n'.join(local_props), as_root=True)
97 # Android will not respect the local props file if it is world writable. 97 # Android will not respect the local props file if it is world writable.
98 device.RunShellCommand( 98 device.RunShellCommand(
99 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH, 99 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH,
100 as_root=True) 100 as_root=True)
101 101
102 # LOCAL_PROPERTIES_PATH = '/data/local.prop' 102 # LOCAL_PROPERTIES_PATH = '/data/local.prop'
103 103
104 104
105 def WipeDeviceData(device): 105 def WipeDeviceData(device):
106 """Wipes data from device, keeping only the adb_keys for authorization. 106 """Wipes data from device, keeping only the adb_keys for authorization.
107 107
108 After wiping data on a device that has been authorized, adb can still 108 After wiping data on a device that has been authorized, adb can still
109 communicate with the device, but after reboot the device will need to be 109 communicate with the device, but after reboot the device will need to be
110 re-authorized because the adb keys file is stored in /data/misc/adb/. 110 re-authorized because the adb keys file is stored in /data/misc/adb/.
111 Thus, adb_keys file is rewritten so the device does not need to be 111 Thus, adb_keys file is rewritten so the device does not need to be
112 re-authorized. 112 re-authorized.
113 113
114 Arguments: 114 Arguments:
115 device: the device to wipe 115 device: the device to wipe
116 """ 116 """
117 device_authorized = device.old_interface.FileExistsOnDevice( 117 device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
118 constants.ADB_KEYS_FILE)
119 if device_authorized: 118 if device_authorized:
120 adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE, 119 adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE,
121 as_root=True) 120 as_root=True)
122 device.RunShellCommand('wipe data', as_root=True) 121 device.RunShellCommand('wipe data', as_root=True)
123 if device_authorized: 122 if device_authorized:
124 path_list = constants.ADB_KEYS_FILE.split('/') 123 path_list = constants.ADB_KEYS_FILE.split('/')
125 dir_path = '/'.join(path_list[:len(path_list)-1]) 124 dir_path = '/'.join(path_list[:len(path_list)-1])
126 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) 125 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True)
127 device.RunShellCommand('echo %s > %s' % 126 device.RunShellCommand('echo %s > %s' %
128 (adb_keys[0], constants.ADB_KEYS_FILE)) 127 (adb_keys[0], constants.ADB_KEYS_FILE))
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 if args: 224 if args:
226 print >> sys.stderr, 'Unused args %s' % args 225 print >> sys.stderr, 'Unused args %s' % args
227 return 1 226 return 1
228 227
229 ProvisionDevices(options) 228 ProvisionDevices(options)
230 229
231 230
232 if __name__ == '__main__': 231 if __name__ == '__main__':
233 sys.exit(main(sys.argv)) 232 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/gyp/util/build_device.py ('k') | build/android/pylib/android_commands.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698