OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 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 """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 json | 8 import json |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ' Build: %s (%s)' % | 74 ' Build: %s (%s)' % |
75 (device_build, device_adb.GetProp('ro.build.fingerprint')), | 75 (device_build, device_adb.GetProp('ro.build.fingerprint')), |
76 ' Current Battery Service state: ', | 76 ' Current Battery Service state: ', |
77 '\n'.join([' %s: %s' % (k, v) | 77 '\n'.join([' %s: %s' % (k, v) |
78 for k, v in battery_info.iteritems()]), | 78 for k, v in battery_info.iteritems()]), |
79 ' IMEI slice: %s' % imei_slice, | 79 ' IMEI slice: %s' % imei_slice, |
80 ' Wifi IP: %s' % device_adb.GetProp('dhcp.wlan0.ipaddress'), | 80 ' Wifi IP: %s' % device_adb.GetProp('dhcp.wlan0.ipaddress'), |
81 ''] | 81 ''] |
82 | 82 |
83 errors = [] | 83 errors = [] |
| 84 dev_good = True |
84 if battery_level < 15: | 85 if battery_level < 15: |
85 errors += ['Device critically low in battery. Turning off device.'] | 86 errors += ['Device critically low in battery. Turning off device.'] |
| 87 dev_good = False |
86 if not options.no_provisioning_check: | 88 if not options.no_provisioning_check: |
87 setup_wizard_disabled = ( | 89 setup_wizard_disabled = ( |
88 device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED') | 90 device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED') |
89 if not setup_wizard_disabled and device_build_type != 'user': | 91 if not setup_wizard_disabled and device_build_type != 'user': |
90 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] | 92 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] |
91 if (device_product_name == 'mantaray' and | 93 if (device_product_name == 'mantaray' and |
92 battery_info.get('AC powered', None) != 'true'): | 94 battery_info.get('AC powered', None) != 'true'): |
93 errors += ['Mantaray device not connected to AC power.'] | 95 errors += ['Mantaray device not connected to AC power.'] |
94 | 96 |
95 # Turn off devices with low battery. | 97 # Turn off devices with low battery. |
96 if battery_level < 15: | 98 if battery_level < 15: |
97 try: | 99 try: |
98 device_adb.EnableRoot() | 100 device_adb.EnableRoot() |
99 except device_errors.CommandFailedError as e: | 101 except device_errors.CommandFailedError as e: |
100 # Attempt shutdown anyway. | 102 # Attempt shutdown anyway. |
101 # TODO(jbudorick) Handle this exception appropriately after interface | 103 # TODO(jbudorick) Handle this exception appropriately after interface |
102 # conversions are finished. | 104 # conversions are finished. |
103 logging.error(str(e)) | 105 logging.error(str(e)) |
104 device_adb.old_interface.Shutdown() | 106 device_adb.old_interface.Shutdown() |
105 full_report = '\n'.join(report) | 107 full_report = '\n'.join(report) |
106 return device_type, device_build, battery_level, full_report, errors, True | 108 return device_type, device_build, battery_level, full_report, errors, dev_good |
107 | 109 |
108 | 110 |
109 def CheckForMissingDevices(options, adb_online_devs): | 111 def CheckForMissingDevices(options, adb_online_devs): |
110 """Uses file of previous online devices to detect broken phones. | 112 """Uses file of previous online devices to detect broken phones. |
111 | 113 |
112 Args: | 114 Args: |
113 options: out_dir parameter of options argument is used as the base | 115 options: out_dir parameter of options argument is used as the base |
114 directory to load and update the cache file. | 116 directory to load and update the cache file. |
115 adb_online_devs: A list of serial numbers of the currently visible | 117 adb_online_devs: A list of serial numbers of the currently visible |
116 and online attached devices. | 118 and online attached devices. |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 # devices with critically low battery. Remove those devices from testing, | 379 # devices with critically low battery. Remove those devices from testing, |
378 # allowing build to continue with good devices. | 380 # allowing build to continue with good devices. |
379 return 2 | 381 return 2 |
380 | 382 |
381 if not devices: | 383 if not devices: |
382 return 1 | 384 return 1 |
383 | 385 |
384 | 386 |
385 if __name__ == '__main__': | 387 if __name__ == '__main__': |
386 sys.exit(main()) | 388 sys.exit(main()) |
OLD | NEW |