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 if any(device.PathExists(p) for p in _SYSTEM_WEBVIEW_PATHS): |
299 # This is required, e.g., to replace the system webview on a device. | 299 logging.info('System WebView exists and needs to be removed') |
300 device.adb.Remount() | 300 if device.HasRoot(): |
301 device.RunShellCommand(['stop'], check_return=True) | 301 # Disabled Marshmallow's Verity security feature |
302 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, | 302 if device.build_version_sdk >= version_codes.MARSHMALLOW: |
303 check_return=True) | 303 device.adb.DisableVerity() |
304 device.RunShellCommand(['start'], check_return=True) | 304 device.Reboot() |
| 305 device.WaitUntilFullyBooted() |
| 306 device.EnableRoot() |
| 307 |
| 308 # This is required, e.g., to replace the system webview on a device. |
| 309 device.adb.Remount() |
| 310 device.RunShellCommand(['stop'], check_return=True) |
| 311 device.RunShellCommand(['rm', '-rf'] + _SYSTEM_WEBVIEW_PATHS, |
| 312 check_return=True) |
| 313 device.RunShellCommand(['start'], check_return=True) |
| 314 else: |
| 315 logging.warning('Cannot remove system webview from a non-rooted device') |
305 else: | 316 else: |
306 logging.warning('Cannot remove system webview from a non-rooted device') | 317 logging.info('System WebView already removed') |
307 | 318 |
308 # Some device types can momentarily disappear after setting properties. | 319 # Some device types can momentarily disappear after setting properties. |
309 device.adb.WaitForDevice() | 320 device.adb.WaitForDevice() |
310 | 321 |
311 | 322 |
312 def _ConfigureLocalProperties(device, java_debug=True): | 323 def _ConfigureLocalProperties(device, java_debug=True): |
313 """Set standard readonly testing device properties prior to reboot.""" | 324 """Set standard readonly testing device properties prior to reboot.""" |
314 local_props = [ | 325 local_props = [ |
315 'persist.sys.usb.config=adb', | 326 'persist.sys.usb.config=adb', |
316 'ro.monkey=1', | 327 'ro.monkey=1', |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 }, | 547 }, |
537 } | 548 } |
538 | 549 |
539 devil_chromium.Initialize(custom_deps=devil_custom_deps) | 550 devil_chromium.Initialize(custom_deps=devil_custom_deps) |
540 | 551 |
541 return ProvisionDevices(args) | 552 return ProvisionDevices(args) |
542 | 553 |
543 | 554 |
544 if __name__ == '__main__': | 555 if __name__ == '__main__': |
545 sys.exit(main()) | 556 sys.exit(main()) |
OLD | NEW |