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

Unified Diff: build/android/buildbot/bb_device_status_check.py

Issue 1046343002: [Android] Clean up old_inteface in build/android/buildbot/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/buildbot/bb_device_status_check.py
diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py
index 8561c0104b4724168cc20eda531e95f7849a6edb..2479c32dcbecedfb513ba85b0318b83109a888c0 100755
--- a/build/android/buildbot/bb_device_status_check.py
+++ b/build/android/buildbot/bb_device_status_check.py
@@ -30,10 +30,14 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from pylib import android_commands
from pylib import constants
from pylib.cmd_helper import GetCmdOutput
+from pylib.device import battery_utils
from pylib.device import device_blacklist
+from pylib.device import device_errors
from pylib.device import device_list
from pylib.device import device_utils
+_RE_DEVICE_ID = re.compile('Device ID = (\d+)')
+
def DeviceInfo(serial, options):
"""Gathers info on a device via various adb calls.
@@ -44,73 +48,72 @@ def DeviceInfo(serial, options):
Tuple of device type, build id, report as a string, error messages, and
boolean indicating whether or not device can be used for testing.
"""
+ device = device_utils.DeviceUtils(serial)
+ battery = battery_utils.BatteryUtils(device)
- device_adb = device_utils.DeviceUtils(serial)
- device_type = device_adb.build_product
- device_build = device_adb.build_id
- device_build_type = device_adb.build_type
- device_product_name = device_adb.product_name
-
+ battery_info = {}
try:
- battery_info = device_adb.old_interface.GetBatteryInfo()
+ battery_info = battery.GetBatteryInfo()
except Exception as e:
battery_info = {}
logging.error('Unable to obtain battery info for %s, %s', serial, e)
- def _GetData(re_expression, line, lambda_function=lambda x: x):
- if not line:
- return 'Unknown'
- found = re.findall(re_expression, line)
- if found and len(found):
- return lambda_function(found[0])
- return 'Unknown'
-
battery_level = int(battery_info.get('level', 100))
- imei_slice = _GetData(r'Device ID = (\d+)',
- device_adb.old_interface.GetSubscriberInfo(),
- lambda x: x[-6:])
+
+ imei_slice = 'Unknown'
+ try:
jbudorick 2015/04/06 17:29:30 Note that catching exceptions here is a functional
navabi 2015/04/07 17:55:17 Acknowledged.
+ for l in device.RunShellCommand(['dumpsys', 'iphonesubinfo'],
+ check_return=True):
+ m = _RE_DEVICE_ID.match(l)
+ if m:
+ imei_slice = m.group(1)[-6:]
+ except device_errors.CommandFailedError:
+ logging.exception('Failed to get IMEI slice.')
+ except device_errors.CommandTimeoutError:
+ logging.exception('Timed out while attempting to get IMEI slice.')
+
json_data = {
'serial': serial,
- 'type': device_type,
- 'build': device_build,
- 'build_detail': device_adb.GetProp('ro.build.fingerprint'),
+ 'type': device.build_product,
+ 'build': device.build_id,
+ 'build_detail': device.GetProp('ro.build.fingerprint'),
'battery': battery_info,
'imei_slice': imei_slice,
- 'wifi_ip': device_adb.GetProp('dhcp.wlan0.ipaddress'),
+ 'wifi_ip': device.GetProp('dhcp.wlan0.ipaddress'),
}
- report = ['Device %s (%s)' % (serial, device_type),
- ' Build: %s (%s)' %
- (device_build, json_data['build_detail']),
- ' Current Battery Service state: ',
- '\n'.join([' %s: %s' % (k, v)
- for k, v in battery_info.iteritems()]),
- ' IMEI slice: %s' % imei_slice,
- ' Wifi IP: %s' % json_data['wifi_ip'],
- '']
+ report = [
+ 'Device %s (%s)' % (str(device), device.build_product),
+ ' Build: %s (%s)' % (device.build_id, json_data['build_detail']),
+ ' Current Battery Service state: ',
+ '\n'.join(' %s: %s' % (k, v) for k, v in battery_info.iteritems()),
+ ' IMEI slice: %s' % imei_slice,
+ ' Wifi IP: %s' % json_data['wifi_ip'],
+ ''
+ ]
errors = []
dev_good = True
if battery_level < 15:
errors += ['Device critically low in battery. Will add to blacklist.']
dev_good = False
- if not device_adb.old_interface.IsDeviceCharging():
- if device_adb.old_interface.CanControlUsbCharging():
- device_adb.old_interface.EnableUsbCharging()
- else:
- logging.error('Device %s is not charging' % serial)
+ if not battery.GetCharging():
+ try:
+ battery.SetCharging(True)
+ except device_errors.CommandFailedError:
+ logging.exception('Device %s is not charging', str(device))
if not options.no_provisioning_check:
setup_wizard_disabled = (
- device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED')
- if not setup_wizard_disabled and device_build_type != 'user':
+ device.GetProp('ro.setupwizard.mode') == 'DISABLED')
+ if not setup_wizard_disabled and device.build_type != 'user':
errors += ['Setup wizard not disabled. Was it provisioned correctly?']
- if (device_product_name == 'mantaray' and
+ if (device.product_name == 'mantaray' and
battery_info.get('AC powered', None) != 'true'):
errors += ['Mantaray device not connected to AC power.']
full_report = '\n'.join(report)
- return (device_type, device_build, battery_level, full_report, errors,
- dev_good, json_data)
+ return (device.build_product, device.build_id, battery_level, full_report,
+ errors, dev_good, json_data)
def CheckForMissingDevices(options, adb_online_devs):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698