Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / build / android / buildbot / bb_device_status_check.py
index e7d8c54..94c741f 100755 (executable)
@@ -29,7 +29,8 @@ 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 device_blacklist
+from pylib.device import device_utils
 
 def DeviceInfo(serial, options):
   """Gathers info on a device via various adb calls.
@@ -42,16 +43,14 @@ def DeviceInfo(serial, options):
     boolean indicating whether or not device can be used for testing.
   """
 
-  device_adb = android_commands.AndroidCommands(serial)
-
-  # TODO(navabi): Replace AdbShellCmd with device_adb.
-  device_type = device_adb.GetBuildProduct()
-  device_build = device_adb.GetBuildId()
-  device_build_type = device_adb.GetBuildType()
-  device_product_name = device_adb.GetProductName()
+  device_adb = device_utils.DeviceUtils(serial)
+  device_type = device_adb.old_interface.GetBuildProduct()
+  device_build = device_adb.old_interface.GetBuildId()
+  device_build_type = device_adb.old_interface.GetBuildType()
+  device_product_name = device_adb.old_interface.GetProductName()
 
   try:
-    battery = device_adb.GetBatteryInfo()
+    battery = device_adb.old_interface.GetBatteryInfo()
   except Exception as e:
     battery = None
     logging.error('Unable to obtain battery info for %s, %s', serial, e)
@@ -66,25 +65,23 @@ def DeviceInfo(serial, options):
 
   ac_power = _GetData('AC powered: (\w+)', battery)
   battery_level = _GetData('level: (\d+)', battery)
-  battery_temp = _GetData('temperature: (\d+)', battery,
-                          lambda x: float(x) / 10.0)
   imei_slice = _GetData('Device ID = (\d+)',
-                        device_adb.GetSubscriberInfo(),
+                        device_adb.old_interface.GetSubscriberInfo(),
                         lambda x: x[-6:])
   report = ['Device %s (%s)' % (serial, device_type),
             '  Build: %s (%s)' %
-              (device_build, device_adb.GetBuildFingerprint()),
-            '  Battery: %s%%' % battery_level,
-            '  Battery temp: %s' % battery_temp,
+              (device_build, device_adb.old_interface.GetBuildFingerprint()),
+            '  %s' % '\n  '.join(battery.split('\n')),
             '  IMEI slice: %s' % imei_slice,
-            '  Wifi IP: %s' % device_adb.GetWifiIP(),
+            '  Wifi IP: %s' % device_adb.old_interface.GetWifiIP(),
             '']
 
   errors = []
   if battery_level < 15:
     errors += ['Device critically low in battery. Turning off device.']
   if not options.no_provisioning_check:
-    setup_wizard_disabled = device_adb.GetSetupWizardStatus() == 'DISABLED'
+    setup_wizard_disabled = (
+        device_adb.old_interface.GetSetupWizardStatus() == '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 ac_power != 'true':
@@ -92,8 +89,8 @@ def DeviceInfo(serial, options):
 
   # Turn off devices with low battery.
   if battery_level < 15:
-    device_adb.EnableAdbRoot()
-    device_adb.Shutdown()
+    device_adb.old_interface.EnableAdbRoot()
+    device_adb.old_interface.Shutdown()
   full_report = '\n'.join(report)
   return device_type, device_build, battery_level, full_report, errors, True
 
@@ -176,7 +173,7 @@ def CheckForMissingDevices(options, adb_online_devs):
             'Cache file: %s\n\n' % last_devices_path,
             'adb devices: %s' % GetCmdOutput(['adb', 'devices']),
             'adb devices(GetAttachedDevices): %s' %
-            android_commands.GetAttachedDevices()]
+                android_commands.GetAttachedDevices()]
   else:
     new_devs = set(adb_online_devs) - set(last_devices)
     if new_devs and os.path.exists(last_devices_path):
@@ -275,8 +272,8 @@ def main():
   if args:
     parser.error('Unknown options %s' % args)
 
-  # Remove the last builds "bad devices" before checking device statuses.
-  android_commands.ResetBadDevices()
+  # Remove the last build's "bad devices" before checking device statuses.
+  device_blacklist.ResetBlacklist()
 
   if options.restart_usb:
     expected_devices = GetLastDevices(os.path.abspath(options.out_dir))
@@ -304,9 +301,8 @@ def main():
 
   devices = android_commands.GetAttachedDevices()
   # TODO(navabi): Test to make sure this fails and then fix call
-  offline_devices = android_commands.GetAttachedDevices(hardware=False,
-                                                        emulator=False,
-                                                        offline=True)
+  offline_devices = android_commands.GetAttachedDevices(
+      hardware=False, emulator=False, offline=True)
 
   types, builds, batteries, reports, errors = [], [], [], [], []
   fail_step_lst = []