| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 """A class to keep track of devices across builds and report state.""" | 7 """A class to keep track of devices across builds and report state.""" |
| 8 import logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 Returns: | 27 Returns: |
| 28 Tuple of device type, build id, report as a string, error messages, and | 28 Tuple of device type, build id, report as a string, error messages, and |
| 29 boolean indicating whether or not device can be used for testing. | 29 boolean indicating whether or not device can be used for testing. |
| 30 """ | 30 """ |
| 31 | 31 |
| 32 def AdbShellCmd(cmd): | 32 def AdbShellCmd(cmd): |
| 33 return GetCmdOutput('adb -s %s shell %s' % (serial, cmd), | 33 return GetCmdOutput('adb -s %s shell %s' % (serial, cmd), |
| 34 shell=True).strip() | 34 shell=True).strip() |
| 35 | 35 |
| 36 device_adb = android_commands.AndroidCommands(serial) |
| 37 |
| 38 # TODO(navabi): Replace AdbShellCmd with device_adb. |
| 36 device_type = AdbShellCmd('getprop ro.build.product') | 39 device_type = AdbShellCmd('getprop ro.build.product') |
| 37 device_build = AdbShellCmd('getprop ro.build.id') | 40 device_build = AdbShellCmd('getprop ro.build.id') |
| 38 device_build_type = AdbShellCmd('getprop ro.build.type') | 41 device_build_type = AdbShellCmd('getprop ro.build.type') |
| 39 device_product_name = AdbShellCmd('getprop ro.product.name') | 42 device_product_name = AdbShellCmd('getprop ro.product.name') |
| 40 | 43 |
| 41 setup_wizard_disabled = AdbShellCmd( | 44 setup_wizard_disabled = AdbShellCmd( |
| 42 'getprop ro.setupwizard.mode') == 'DISABLED' | 45 'getprop ro.setupwizard.mode') == 'DISABLED' |
| 43 battery = AdbShellCmd('dumpsys battery') | 46 battery = AdbShellCmd('dumpsys battery') |
| 44 install_output = GetCmdOutput( | 47 install_output = GetCmdOutput( |
| 45 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk', | 48 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 ' Battery temp: %s' % battery_temp, | 67 ' Battery temp: %s' % battery_temp, |
| 65 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' | 68 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' |
| 66 '| grep Device' | 69 '| grep Device' |
| 67 "| awk '{print $4}'")[-6:], | 70 "| awk '{print $4}'")[-6:], |
| 68 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), | 71 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), |
| 69 ' Install Speed: %s KB/s' % install_speed, | 72 ' Install Speed: %s KB/s' % install_speed, |
| 70 ''] | 73 ''] |
| 71 | 74 |
| 72 errors = [] | 75 errors = [] |
| 73 if battery_level < 15: | 76 if battery_level < 15: |
| 74 errors += ['Device critically low in battery. Do not use for testing.'] | 77 errors += ['Device critically low in battery. Turning off device.'] |
| 75 if not setup_wizard_disabled and device_build_type != 'user': | 78 if not setup_wizard_disabled and device_build_type != 'user': |
| 76 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] | 79 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] |
| 77 if device_product_name == 'mantaray' and ac_power != 'true': | 80 if device_product_name == 'mantaray' and ac_power != 'true': |
| 78 errors += ['Mantaray device not connected to AC power.'] | 81 errors += ['Mantaray device not connected to AC power.'] |
| 79 # TODO(navabi): Insert warning once we have a better handle of what install | 82 # TODO(navabi): Insert warning once we have a better handle of what install |
| 80 # speeds to expect. The following lines were causing too many alerts. | 83 # speeds to expect. The following lines were causing too many alerts. |
| 81 # if install_speed < 500: | 84 # if install_speed < 500: |
| 82 # errors += ['Device install speed too low. Do not use for testing.'] | 85 # errors += ['Device install speed too low. Do not use for testing.'] |
| 83 | 86 |
| 84 # TODO(navabi): Determine if device status check step should fail on slow | 87 # Causing the device status check step fail for slow install speed or low |
| 85 # install speed. The original CL caused the step to fail but was reverted | 88 # battery currently is too disruptive to the bots (especially try bots). |
| 86 # because it caused too many early failures. Determine if it was just flake. | 89 # Turn off devices with low battery and the step does not fail. |
| 87 # Also, do not fail on 'Unknown' caused by offline device, because other | 90 if battery_level < 15: |
| 88 # devices can still be used for tests. | 91 device_adb.EnableAdbRoot() |
| 89 fail_step = (battery_level == 'Unknown' or battery_level >= 15) | 92 AdbShellCmd('reboot -p') |
| 90 return device_type, device_build, '\n'.join(report), errors, fail_step | 93 return device_type, device_build, '\n'.join(report), errors, True |
| 91 | 94 |
| 92 | 95 |
| 93 def CheckForMissingDevices(options, adb_online_devs): | 96 def CheckForMissingDevices(options, adb_online_devs): |
| 94 """Uses file of previous online devices to detect broken phones. | 97 """Uses file of previous online devices to detect broken phones. |
| 95 | 98 |
| 96 Args: | 99 Args: |
| 97 options: out_dir parameter of options argument is used as the base | 100 options: out_dir parameter of options argument is used as the base |
| 98 directory to load and update the cache file. | 101 directory to load and update the cache file. |
| 99 adb_online_devs: A list of serial numbers of the currently visible | 102 adb_online_devs: A list of serial numbers of the currently visible |
| 100 and online attached devices. | 103 and online attached devices. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 # devices with critically low battery or install speed. Remove those devices | 221 # devices with critically low battery or install speed. Remove those devices |
| 219 # from testing, allowing build to continue with good devices. | 222 # from testing, allowing build to continue with good devices. |
| 220 return 1 | 223 return 1 |
| 221 | 224 |
| 222 if not devices: | 225 if not devices: |
| 223 return 1 | 226 return 1 |
| 224 | 227 |
| 225 | 228 |
| 226 if __name__ == '__main__': | 229 if __name__ == '__main__': |
| 227 sys.exit(main()) | 230 sys.exit(main()) |
| OLD | NEW |