OLD | NEW |
---|---|
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 if options.disable_network: | 288 if options.disable_network: |
289 device_settings.ConfigureContentSettings( | 289 device_settings.ConfigureContentSettings( |
290 device, device_settings.NETWORK_DISABLED_SETTINGS) | 290 device, device_settings.NETWORK_DISABLED_SETTINGS) |
291 | 291 |
292 if options.disable_system_chrome: | 292 if options.disable_system_chrome: |
293 # The system chrome version on the device interferes with some tests. | 293 # The system chrome version on the device interferes with some tests. |
294 device.RunShellCommand(['pm', 'disable', 'com.android.chrome'], | 294 device.RunShellCommand(['pm', 'disable', 'com.android.chrome'], |
295 check_return=True) | 295 check_return=True) |
296 | 296 |
297 if options.remove_system_webview: | 297 if options.remove_system_webview: |
298 if device.HasRoot(): | 298 original_webview_exist = False |
jbudorick
2016/05/10 22:28:44
These four lines can just be:
if any(device.Pat
Yoland Yan(Google)
2016/05/10 22:36:48
Nicee, done!
| |
299 # This is required, e.g., to replace the system webview on a device. | 299 for p in _SYSTEM_WEBVIEW_PATHS: |
300 device.adb.Remount() | 300 original_webview_exist = original_webview_exist or device.PathExists(p) |
301 device.RunShellCommand(['stop'], check_return=True) | 301 if original_webview_exist: |
302 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, | 302 logging.info('Original WebView exists and needs to be removed') |
303 check_return=True) | 303 if device.HasRoot(): |
304 device.RunShellCommand(['start'], check_return=True) | 304 # Disabled Marshmallow's Verity security feature |
305 if device.build_version_sdk >= version_codes.MARSHMALLOW: | |
306 device.adb.DisableVerity() | |
307 device.Reboot() | |
308 device.WaitUntilFullyBooted() | |
309 device.EnableRoot() | |
310 # This is required, e.g., to replace the system webview on a device. | |
jbudorick
2016/05/10 22:28:44
nit: line break before this line
Yoland Yan(Google)
2016/05/10 22:36:48
Done.
| |
311 device.adb.Remount() | |
312 device.RunShellCommand(['stop'], check_return=True) | |
313 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, | |
314 check_return=True) | |
315 device.RunShellCommand(['start'], check_return=True) | |
316 else: | |
317 logging.warning('Cannot remove system webview from a non-rooted device') | |
305 else: | 318 else: |
306 logging.warning('Cannot remove system webview from a non-rooted device') | 319 logging.info('Original WebView already removed') |
jbudorick
2016/05/10 22:28:44
nit: "system webview" instead of "original webview
Yoland Yan(Google)
2016/05/10 22:36:48
Done.
| |
307 | 320 |
308 # Some device types can momentarily disappear after setting properties. | 321 # Some device types can momentarily disappear after setting properties. |
309 device.adb.WaitForDevice() | 322 device.adb.WaitForDevice() |
310 | 323 |
311 | 324 |
312 def _ConfigureLocalProperties(device, java_debug=True): | 325 def _ConfigureLocalProperties(device, java_debug=True): |
313 """Set standard readonly testing device properties prior to reboot.""" | 326 """Set standard readonly testing device properties prior to reboot.""" |
314 local_props = [ | 327 local_props = [ |
315 'persist.sys.usb.config=adb', | 328 'persist.sys.usb.config=adb', |
316 'ro.monkey=1', | 329 'ro.monkey=1', |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 }, | 549 }, |
537 } | 550 } |
538 | 551 |
539 devil_chromium.Initialize(custom_deps=devil_custom_deps) | 552 devil_chromium.Initialize(custom_deps=devil_custom_deps) |
540 | 553 |
541 return ProvisionDevices(args) | 554 return ProvisionDevices(args) |
542 | 555 |
543 | 556 |
544 if __name__ == '__main__': | 557 if __name__ == '__main__': |
545 sys.exit(main()) | 558 sys.exit(main()) |
OLD | NEW |