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

Side by Side Diff: build/android/pylib/device/battery_utils.py

Issue 1174633002: [Android] Use large_output for calls to "ps" and "dumpsys batterystats". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698