| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.WriteFile( | 94 try: |
| 95 constants.DEVICE_LOCAL_PROPERTIES_PATH, | 95 device.WriteFile( |
| 96 '\n'.join(local_props), as_root=True) | 96 constants.DEVICE_LOCAL_PROPERTIES_PATH, |
| 97 # Android will not respect the local props file if it is world writable. | 97 '\n'.join(local_props), as_root=True) |
| 98 device.RunShellCommand( | 98 # Android will not respect the local props file if it is world writable. |
| 99 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH, | 99 device.RunShellCommand( |
| 100 as_root=True) | 100 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH, |
| 101 as_root=True) |
| 102 except device_errors.CommandFailedError as e: |
| 103 logging.warning(str(e)) |
| 101 | 104 |
| 102 # LOCAL_PROPERTIES_PATH = '/data/local.prop' | 105 # LOCAL_PROPERTIES_PATH = '/data/local.prop' |
| 103 | 106 |
| 104 | 107 |
| 105 def WipeDeviceData(device): | 108 def WipeDeviceData(device): |
| 106 """Wipes data from device, keeping only the adb_keys for authorization. | 109 """Wipes data from device, keeping only the adb_keys for authorization. |
| 107 | 110 |
| 108 After wiping data on a device that has been authorized, adb can still | 111 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 | 112 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/. | 113 re-authorized because the adb keys file is stored in /data/misc/adb/. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 227 |
| 225 if args: | 228 if args: |
| 226 print >> sys.stderr, 'Unused args %s' % args | 229 print >> sys.stderr, 'Unused args %s' % args |
| 227 return 1 | 230 return 1 |
| 228 | 231 |
| 229 ProvisionDevices(options) | 232 ProvisionDevices(options) |
| 230 | 233 |
| 231 | 234 |
| 232 if __name__ == '__main__': | 235 if __name__ == '__main__': |
| 233 sys.exit(main(sys.argv)) | 236 sys.exit(main(sys.argv)) |
| OLD | NEW |