Chromium Code Reviews| Index: build/android/provision_devices.py |
| diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py |
| index 824e64202e78787d1096eedd73ddaa4e7b704dc1..bb60e79ddebe2c7b471c51c32ecb5b72417377dd 100755 |
| --- a/build/android/provision_devices.py |
| +++ b/build/android/provision_devices.py |
| @@ -25,6 +25,7 @@ from pylib.device import device_blacklist |
| from pylib.device import device_errors |
| from pylib.device import device_utils |
| from pylib.utils import run_tests_helper |
| +from pylib.utils import timeout_retry |
| sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, |
| 'third_party', 'android_testrunner')) |
| @@ -84,8 +85,9 @@ def PushAndLaunchAdbReboot(device, target): |
| device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')]) |
| # Launch adb_reboot |
| logging.info(' Launching adb_reboot ...') |
| - device.old_interface.GetAndroidToolStatusAndOutput( |
| - '/data/local/tmp/adb_reboot') |
| + device.RunShellCommand([ |
| + device.GetDevicePieWrapper(), |
| + '/data/local/tmp/adb_reboot']) |
| def _ConfigureLocalProperties(device, java_debug=True): |
| @@ -149,6 +151,15 @@ def WipeDeviceIfPossible(device, timeout): |
| pass |
| +def ChargeDeviceToLevel(device, level): |
| + def device_charged(): |
| + battery_level = int(device.GetBatteryInfo().get('level', 100)) |
|
perezju
2015/02/23 10:43:32
I see this was also on the previous version of the
jbudorick
2015/02/24 15:44:53
I'm not sure when or why the default was added, bu
|
| + logging.info('current battery level: %d', battery_level) |
| + return battery_level >= level |
| + |
| + timeout_retry.WaitFor(device_charged, wait_period=60) |
| + |
| + |
| def ProvisionDevice(device, options): |
| if options.reboot_timeout: |
| reboot_timeout = options.reboot_timeout |
| @@ -179,24 +190,9 @@ def ProvisionDevice(device, options): |
| device_settings.ConfigureContentSettings( |
| device, device_settings.NETWORK_DISABLED_SETTINGS) |
| if options.min_battery_level is not None: |
| - try: |
| - battery_info = device.old_interface.GetBatteryInfo() |
| - except Exception as e: |
| - battery_info = {} |
| - logging.error('Unable to obtain battery info for %s, %s', |
| - str(device), e) |
| - |
| - while int(battery_info.get('level', 100)) < options.min_battery_level: |
| - 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.SetUsbCharging(True) |
|
perezju
2015/02/23 10:43:32
There seems to be a change of logic w.r.t. previou
jbudorick
2015/02/24 15:44:53
These changes were both intentional, but on recons
|
| + ChargeDeviceToLevel(device, options.min_battery_level) |
| + |
| if not options.skip_wipe: |
| device.Reboot(True, timeout=reboot_timeout, retries=0) |
| device.RunShellCommand('date -s %s' % time.strftime('%Y%m%d.%H%M%S', |