示例#1
0
def ProvisionDevices(options):
  if options.device is not None:
    devices = [options.device]
  else:
    devices = android_commands.GetAttachedDevices()
  for device_serial in devices:
    device = device_utils.DeviceUtils(device_serial)
    device.old_interface.EnableAdbRoot()
    install_output = GetCmdOutput(
      ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT,
       '--apk',
       '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT
       ])
    failure_string = 'Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]'
    if failure_string in install_output:
      WipeDeviceData(device)
    _ConfigureLocalProperties(device)
    device_settings.ConfigureContentSettingsDict(
        device, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
    # TODO(tonyg): We eventually want network on. However, currently radios
    # can cause perfbots to drain faster than they charge.
    if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
      device_settings.ConfigureContentSettingsDict(
          device, device_settings.NETWORK_DISABLED_SETTINGS)
    device.old_interface.RunShellCommandWithSU('date -u %f' % time.time())
    (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
    for prop in props:
      print prop
  if options.auto_reconnect:
    PushAndLaunchAdbReboot(devices, options.target)
示例#2
0
def ProvisionDevices(options):
    if options.device is not None:
        devices = [options.device]
    else:
        devices = android_commands.GetAttachedDevices()
    for device in devices:
        android_cmd = android_commands.AndroidCommands(device)
        _ConfigureLocalProperties(android_cmd)
        device_settings.ConfigureContentSettingsDict(
            android_cmd, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
        # TODO(tonyg): We eventually want network on. However, currently radios
        # can cause perfbots to drain faster than they charge.
        if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
            device_settings.ConfigureContentSettingsDict(
                android_cmd, device_settings.NETWORK_DISABLED_SETTINGS)
        android_cmd.RunShellCommandWithSU('date -u %f' % time.time())
    if options.auto_reconnect:
        PushAndLaunchAdbReboot(devices, options.target)
示例#3
0
def ProvisionDevices(options):
    # TODO(jbudorick): Parallelize provisioning of all attached devices after
    # swithcing from AndroidCommands.
    if options.device is not None:
        devices = [options.device]
    else:
        devices = android_commands.GetAttachedDevices()
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        device.old_interface.EnableAdbRoot()
        WipeDeviceData(device)
    try:
        device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True)
    except errors.DeviceUnresponsiveError:
        pass
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        device.WaitUntilFullyBooted(timeout=90)
        device.old_interface.EnableAdbRoot()
        _ConfigureLocalProperties(device)
        device_settings.ConfigureContentSettingsDict(
            device, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
        # TODO(tonyg): We eventually want network on. However, currently radios
        # can cause perfbots to drain faster than they charge.
        if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
            device_settings.ConfigureContentSettingsDict(
                device, device_settings.NETWORK_DISABLED_SETTINGS)
        device.old_interface.RunShellCommandWithSU('date -u %f' % time.time())
    try:
        device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True)
    except errors.DeviceUnresponsiveError:
        pass
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        device.WaitUntilFullyBooted(timeout=90)
        (_, props
         ) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
        for prop in props:
            print prop
    if options.auto_reconnect:
        PushAndLaunchAdbReboot(devices, options.target)
示例#4
0
def ProvisionDevice(device_serial, is_perf, disable_location):
    device = device_utils.DeviceUtils(device_serial)
    device.old_interface.EnableAdbRoot()
    _ConfigureLocalProperties(device, is_perf)
    device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS
    if disable_location:
        device_settings_map.update(device_settings.DISABLE_LOCATION_SETTING)
    else:
        device_settings_map.update(device_settings.ENABLE_LOCATION_SETTING)
    device_settings.ConfigureContentSettingsDict(device, device_settings_map)
    device_settings.SetLockScreenSettings(device)
    if is_perf:
        # TODO(tonyg): We eventually want network on. However, currently radios
        # can cause perfbots to drain faster than they charge.
        device_settings.ConfigureContentSettingsDict(
            device, device_settings.NETWORK_DISABLED_SETTINGS)
        # Some perf bots run benchmarks with USB charging disabled which leads
        # to gradual draining of the battery. We must wait for a full charge
        # before starting a run in order to keep the devices online.
        try:
            battery_info = device.old_interface.GetBatteryInfo()
        except Exception as e:
            battery_info = {}
            logging.error('Unable to obtain battery info for %s, %s',
                          device_serial, e)

        while int(battery_info.get('level', 100)) < 95:
            if not device.old_interface.IsDeviceCharging():
                if device.old_interface.CanControlUsbCharging():
                    device.old_interface.EnableUsbCharging()
                else:
                    logging.error('Device is not charging')
                    break
            logging.info('Waiting for device to charge. Current level=%s',
                         battery_info.get('level', 0))
            time.sleep(60)
            battery_info = device.old_interface.GetBatteryInfo()
    device.RunShellCommand('date -u %f' % time.time(), as_root=True)
示例#5
0
def ProvisionDevices(options):
    is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower()
    # TODO(jbudorick): Parallelize provisioning of all attached devices after
    # switching from AndroidCommands.
    if options.device is not None:
        devices = [options.device]
    else:
        devices = android_commands.GetAttachedDevices()

    # Wipe devices (unless --skip-wipe was specified)
    if not options.skip_wipe:
        for device_serial in devices:
            device = device_utils.DeviceUtils(device_serial)
            device.old_interface.EnableAdbRoot()
            WipeDeviceData(device)
        try:
            device_utils.DeviceUtils.parallel(devices).Reboot(True)
        except errors.DeviceUnresponsiveError:
            pass
        for device_serial in devices:
            device.WaitUntilFullyBooted(timeout=90)

    # Provision devices
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        device.old_interface.EnableAdbRoot()
        _ConfigureLocalProperties(device, is_perf)
        device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS
        if options.disable_location:
            device_settings_map.update(
                device_settings.DISABLE_LOCATION_SETTING)
        else:
            device_settings_map.update(device_settings.ENABLE_LOCATION_SETTING)
        device_settings.ConfigureContentSettingsDict(device,
                                                     device_settings_map)
        device_settings.SetLockScreenSettings(device)
        if is_perf:
            # TODO(tonyg): We eventually want network on. However, currently radios
            # can cause perfbots to drain faster than they charge.
            device_settings.ConfigureContentSettingsDict(
                device, device_settings.NETWORK_DISABLED_SETTINGS)
            # Some perf bots run benchmarks with USB charging disabled which leads
            # to gradual draining of the battery. We must wait for a full charge
            # before starting a run in order to keep the devices online.
            try:
                battery_info = device.old_interface.GetBatteryInfo()
            except Exception as e:
                battery_info = {}
                logging.error('Unable to obtain battery info for %s, %s',
                              device_serial, e)

            while int(battery_info.get('level', 100)) < 95:
                if not device.old_interface.IsDeviceCharging():
                    if device.old_interface.CanControlUsbCharging():
                        device.old_interface.EnableUsbCharging()
                    else:
                        logging.error('Device is not charging')
                        break
                logging.info('Waiting for device to charge. Current level=%s',
                             battery_info.get('level', 0))
                time.sleep(60)
                battery_info = device.old_interface.GetBatteryInfo()
        device.RunShellCommand('date -u %f' % time.time(), as_root=True)
    try:
        device_utils.DeviceUtils.parallel(devices).Reboot(True)
    except errors.DeviceUnresponsiveError:
        pass
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        device.WaitUntilFullyBooted(timeout=90)
        (_, props
         ) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
        for prop in props:
            print prop
    if options.auto_reconnect:
        PushAndLaunchAdbReboot(devices, options.target)