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

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

Issue 1410553004: Reland of Android: Trust large random numbers for temp files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: provision_devices Created 5 years, 2 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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 blacklist.Extend([str(device)]) 130 blacklist.Extend([str(device)])
131 131
132 def CheckExternalStorage(device): 132 def CheckExternalStorage(device):
133 """Checks that storage is writable and if not makes it writable. 133 """Checks that storage is writable and if not makes it writable.
134 134
135 Arguments: 135 Arguments:
136 device: The device to check. 136 device: The device to check.
137 """ 137 """
138 try: 138 try:
139 with device_temp_file.DeviceTempFile( 139 with device_temp_file.DeviceTempFile(
140 device.adb, suffix='.sh', dir=device.GetExternalStoragePath()): 140 device.adb, suffix='.sh', dir=device.GetExternalStoragePath()) as f:
141 pass 141 device.WriteFile(f.name, 'test')
142 except device_errors.CommandFailedError: 142 except device_errors.CommandFailedError:
143 logging.info('External storage not writable. Remounting / as RW') 143 logging.info('External storage not writable. Remounting / as RW')
144 device.RunShellCommand(['mount', '-o', 'remount,rw', '/'], 144 device.RunShellCommand(['mount', '-o', 'remount,rw', '/'],
145 check_return=True, as_root=True) 145 check_return=True, as_root=True)
146 device.EnableRoot() 146 device.EnableRoot()
147 with device_temp_file.DeviceTempFile( 147 with device_temp_file.DeviceTempFile(
148 device.adb, suffix='.sh', dir=device.GetExternalStoragePath()): 148 device.adb, suffix='.sh', dir=device.GetExternalStoragePath()) as f:
149 pass 149 device.WriteFile(f.name, 'test')
150 150
151 def WipeChromeData(device, options): 151 def WipeChromeData(device, options):
152 """Wipes chrome specific data from device 152 """Wipes chrome specific data from device
153 153
154 (1) uninstall any app whose name matches *chrom*, except 154 (1) uninstall any app whose name matches *chrom*, except
155 com.android.chrome, which is the chrome stable package. Doing so also 155 com.android.chrome, which is the chrome stable package. Doing so also
156 removes the corresponding dirs under /data/data/ and /data/app/ 156 removes the corresponding dirs under /data/data/ and /data/app/
157 (2) remove any dir under /data/app-lib/ whose name matches *chrom* 157 (2) remove any dir under /data/app-lib/ whose name matches *chrom*
158 (3) remove any files under /data/tombstones/ whose name matches "tombstone*" 158 (3) remove any files under /data/tombstones/ whose name matches "tombstone*"
159 (4) remove /data/local.prop if there is any 159 (4) remove /data/local.prop if there is any
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 args = parser.parse_args() 482 args = parser.parse_args()
483 constants.SetBuildType(args.target) 483 constants.SetBuildType(args.target)
484 484
485 run_tests_helper.SetLogLevel(args.verbose) 485 run_tests_helper.SetLogLevel(args.verbose)
486 486
487 return ProvisionDevices(args) 487 return ProvisionDevices(args)
488 488
489 489
490 if __name__ == '__main__': 490 if __name__ == '__main__':
491 sys.exit(main()) 491 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698