Chromium Code Reviews| 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 webview_removed = False | |
| 299 for p in _SYSTEM_WEBVIEW_PATHS: | |
| 300 output = device.RunShellCommand(['ls', p], check_return=False, | |
|
jbudorick
2016/05/10 21:52:44
Use DeviceUtils.PathExists: https://code.google.co
Yoland Yan(Google)
2016/05/10 22:19:20
Done.
| |
| 301 raw_output=True) | |
| 302 if 'No such file or directory' in output: | |
| 303 webview_removed = True | |
| 304 else: | |
| 305 webview_removed = False | |
| 306 break | |
| 307 if webview_removed: | |
| 308 logging.info('WebView already removed') | |
| 309 return | |
|
jbudorick
2016/05/10 21:52:44
This shouldn't return. It should simply skip the r
Yoland Yan(Google)
2016/05/10 22:19:20
Done.
| |
| 298 if device.HasRoot(): | 310 if device.HasRoot(): |
| 311 # Disabled Marshmallow's Verity security feature | |
| 312 if device.build_version_sdk >= version_codes.MARSHMALLOW: | |
| 313 device.adb.DisableVerity() | |
| 314 device.Reboot() | |
| 315 device.WaitUntilFullyBooted() | |
| 316 device.EnableRoot() | |
| 299 # This is required, e.g., to replace the system webview on a device. | 317 # This is required, e.g., to replace the system webview on a device. |
| 300 device.adb.Remount() | 318 device.adb.Remount() |
| 301 device.RunShellCommand(['stop'], check_return=True) | 319 device.RunShellCommand(['stop'], check_return=True) |
| 302 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, | 320 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, |
| 303 check_return=True) | 321 check_return=True) |
| 304 device.RunShellCommand(['start'], check_return=True) | 322 device.RunShellCommand(['start'], check_return=True) |
| 305 else: | 323 else: |
| 306 logging.warning('Cannot remove system webview from a non-rooted device') | 324 logging.warning('Cannot remove system webview from a non-rooted device') |
| 307 | 325 |
| 308 # Some device types can momentarily disappear after setting properties. | 326 # Some device types can momentarily disappear after setting properties. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 }, | 554 }, |
| 537 } | 555 } |
| 538 | 556 |
| 539 devil_chromium.Initialize(custom_deps=devil_custom_deps) | 557 devil_chromium.Initialize(custom_deps=devil_custom_deps) |
| 540 | 558 |
| 541 return ProvisionDevices(args) | 559 return ProvisionDevices(args) |
| 542 | 560 |
| 543 | 561 |
| 544 if __name__ == '__main__': | 562 if __name__ == '__main__': |
| 545 sys.exit(main()) | 563 sys.exit(main()) |
| OLD | NEW |