Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: build/android/buildbot/bb_device_status_check.py

Issue 371813005: [Android] Switch to DeviceUtils versions of Ls, SetJavaAsserts, GetProp, and SetProp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/enable_asserts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 8 import logging
9 import optparse 9 import optparse
10 import os 10 import os
(...skipping 28 matching lines...) Expand all
39 39
40 Args: 40 Args:
41 serial: The serial of the attached device to construct info about. 41 serial: The serial of the attached device to construct info about.
42 42
43 Returns: 43 Returns:
44 Tuple of device type, build id, report as a string, error messages, and 44 Tuple of device type, build id, report as a string, error messages, and
45 boolean indicating whether or not device can be used for testing. 45 boolean indicating whether or not device can be used for testing.
46 """ 46 """
47 47
48 device_adb = device_utils.DeviceUtils(serial) 48 device_adb = device_utils.DeviceUtils(serial)
49 device_type = device_adb.old_interface.GetBuildProduct() 49 device_type = device_adb.GetProp('ro.build.product')
50 device_build = device_adb.old_interface.GetBuildId() 50 device_build = device_adb.GetProp('ro.build.id')
51 device_build_type = device_adb.old_interface.GetBuildType() 51 device_build_type = device_adb.GetProp('ro.build.type')
52 device_product_name = device_adb.old_interface.GetProductName() 52 device_product_name = device_adb.GetProp('ro.product.name')
53 53
54 try: 54 try:
55 battery_info = device_adb.old_interface.GetBatteryInfo() 55 battery_info = device_adb.old_interface.GetBatteryInfo()
56 except Exception as e: 56 except Exception as e:
57 battery_info = {} 57 battery_info = {}
58 logging.error('Unable to obtain battery info for %s, %s', serial, e) 58 logging.error('Unable to obtain battery info for %s, %s', serial, e)
59 59
60 def _GetData(re_expression, line, lambda_function=lambda x:x): 60 def _GetData(re_expression, line, lambda_function=lambda x:x):
61 if not line: 61 if not line:
62 return 'Unknown' 62 return 'Unknown'
63 found = re.findall(re_expression, line) 63 found = re.findall(re_expression, line)
64 if found and len(found): 64 if found and len(found):
65 return lambda_function(found[0]) 65 return lambda_function(found[0])
66 return 'Unknown' 66 return 'Unknown'
67 67
68 battery_level = int(battery_info.get('level', 100)) 68 battery_level = int(battery_info.get('level', 100))
69 imei_slice = _GetData('Device ID = (\d+)', 69 imei_slice = _GetData('Device ID = (\d+)',
70 device_adb.old_interface.GetSubscriberInfo(), 70 device_adb.old_interface.GetSubscriberInfo(),
71 lambda x: x[-6:]) 71 lambda x: x[-6:])
72 report = ['Device %s (%s)' % (serial, device_type), 72 report = ['Device %s (%s)' % (serial, device_type),
73 ' Build: %s (%s)' % 73 ' Build: %s (%s)' %
74 (device_build, device_adb.old_interface.GetBuildFingerprint()), 74 (device_build, device_adb.GetProp('ro.build.fingerprint')),
75 ' Current Battery Service state: ', 75 ' Current Battery Service state: ',
76 '\n'.join([' %s: %s' % (k, v) 76 '\n'.join([' %s: %s' % (k, v)
77 for k, v in battery_info.iteritems()]), 77 for k, v in battery_info.iteritems()]),
78 ' IMEI slice: %s' % imei_slice, 78 ' IMEI slice: %s' % imei_slice,
79 ' Wifi IP: %s' % device_adb.old_interface.GetWifiIP(), 79 ' Wifi IP: %s' % device_adb.GetProp('dhcp.wlan0.ipaddress'),
80 ''] 80 '']
81 81
82 errors = [] 82 errors = []
83 if battery_level < 15: 83 if battery_level < 15:
84 errors += ['Device critically low in battery. Turning off device.'] 84 errors += ['Device critically low in battery. Turning off device.']
85 if not options.no_provisioning_check: 85 if not options.no_provisioning_check:
86 setup_wizard_disabled = ( 86 setup_wizard_disabled = (
87 device_adb.old_interface.GetSetupWizardStatus() == 'DISABLED') 87 device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED')
88 if not setup_wizard_disabled and device_build_type != 'user': 88 if not setup_wizard_disabled and device_build_type != 'user':
89 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] 89 errors += ['Setup wizard not disabled. Was it provisioned correctly?']
90 if (device_product_name == 'mantaray' and 90 if (device_product_name == 'mantaray' and
91 battery_info.get('AC powered', None) != 'true'): 91 battery_info.get('AC powered', None) != 'true'):
92 errors += ['Mantaray device not connected to AC power.'] 92 errors += ['Mantaray device not connected to AC power.']
93 93
94 # Turn off devices with low battery. 94 # Turn off devices with low battery.
95 if battery_level < 15: 95 if battery_level < 15:
96 try: 96 try:
97 device_adb.EnableRoot() 97 device_adb.EnableRoot()
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 # devices with critically low battery. Remove those devices from testing, 364 # devices with critically low battery. Remove those devices from testing,
365 # allowing build to continue with good devices. 365 # allowing build to continue with good devices.
366 return 2 366 return 2
367 367
368 if not devices: 368 if not devices:
369 return 1 369 return 1
370 370
371 371
372 if __name__ == '__main__': 372 if __name__ == '__main__':
373 sys.exit(main()) 373 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/enable_asserts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698