OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Provides a variety of device interactions with power. | 5 """Provides a variety of device interactions with power. |
6 """ | 6 """ |
7 # pylint: disable=unused-argument | 7 # pylint: disable=unused-argument |
8 | 8 |
9 import collections | 9 import collections |
10 import contextlib | 10 import contextlib |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 if (self._device.build_version_sdk < | 287 if (self._device.build_version_sdk < |
288 constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP): | 288 constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP): |
289 raise device_errors.DeviceVersionError('Device must be L or higher.') | 289 raise device_errors.DeviceVersionError('Device must be L or higher.') |
290 | 290 |
291 self._device.RunShellCommand( | 291 self._device.RunShellCommand( |
292 ['dumpsys', 'battery', 'reset'], check_return=True) | 292 ['dumpsys', 'battery', 'reset'], check_return=True) |
293 self._device.RunShellCommand( | 293 self._device.RunShellCommand( |
294 ['dumpsys', 'batterystats', '--reset'], check_return=True) | 294 ['dumpsys', 'batterystats', '--reset'], check_return=True) |
295 battery_data = self._device.RunShellCommand( | 295 battery_data = self._device.RunShellCommand( |
296 ['dumpsys', 'batterystats', '--charged', '--checkin'], | 296 ['dumpsys', 'batterystats', '--charged', '--checkin'], |
297 check_return=True) | 297 check_return=True, large_output=True) |
298 ROW_TYPE_INDEX = 3 | 298 ROW_TYPE_INDEX = 3 |
299 PWI_POWER_INDEX = 5 | 299 PWI_POWER_INDEX = 5 |
300 for line in battery_data: | 300 for line in battery_data: |
301 l = line.split(',') | 301 l = line.split(',') |
302 if (len(l) > PWI_POWER_INDEX and l[ROW_TYPE_INDEX] == 'pwi' | 302 if (len(l) > PWI_POWER_INDEX and l[ROW_TYPE_INDEX] == 'pwi' |
303 and l[PWI_POWER_INDEX] != 0): | 303 and l[PWI_POWER_INDEX] != 0): |
304 raise device_errors.CommandFailedError( | 304 raise device_errors.CommandFailedError( |
305 'Non-zero pmi value found after reset.') | 305 'Non-zero pmi value found after reset.') |
306 self._device.RunShellCommand(['dumpsys', 'battery', 'set', 'ac', '0'], | 306 self._device.RunShellCommand(['dumpsys', 'battery', 'set', 'ac', '0'], |
307 check_return=True) | 307 check_return=True) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 if temp is None: | 396 if temp is None: |
397 logging.warning('Unable to find current battery temperature.') | 397 logging.warning('Unable to find current battery temperature.') |
398 temp = 0 | 398 temp = 0 |
399 else: | 399 else: |
400 logging.info('Current battery temperature: %s', temp) | 400 logging.info('Current battery temperature: %s', temp) |
401 return int(temp) <= target_temp | 401 return int(temp) <= target_temp |
402 | 402 |
403 logging.info('Waiting for the device to cool down to %s degrees.', | 403 logging.info('Waiting for the device to cool down to %s degrees.', |
404 target_temp) | 404 target_temp) |
405 timeout_retry.WaitFor(cool_device, wait_period=wait_period) | 405 timeout_retry.WaitFor(cool_device, wait_period=wait_period) |
OLD | NEW |