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

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

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased 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
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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 device_errors.DeviceVersionError: If device is not L or higher. 282 device_errors.DeviceVersionError: If device is not L or higher.
283 """ 283 """
284 def battery_updates_disabled(): 284 def battery_updates_disabled():
285 return self.GetCharging() is False 285 return self.GetCharging() is False
286 286
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', 'set', 'usb', '1'], check_return=True)
293 self._device.RunShellCommand(
294 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True)
293 self._device.RunShellCommand( 295 self._device.RunShellCommand(
294 ['dumpsys', 'batterystats', '--reset'], check_return=True) 296 ['dumpsys', 'batterystats', '--reset'], check_return=True)
295 battery_data = self._device.RunShellCommand( 297 battery_data = self._device.RunShellCommand(
296 ['dumpsys', 'batterystats', '--charged', '--checkin'], 298 ['dumpsys', 'batterystats', '--charged', '--checkin'],
297 check_return=True) 299 check_return=True, large_output=True)
298 ROW_TYPE_INDEX = 3 300 ROW_TYPE_INDEX = 3
299 PWI_POWER_INDEX = 5 301 PWI_POWER_INDEX = 5
300 for line in battery_data: 302 for line in battery_data:
301 l = line.split(',') 303 l = line.split(',')
302 if (len(l) > PWI_POWER_INDEX and l[ROW_TYPE_INDEX] == 'pwi' 304 if (len(l) > PWI_POWER_INDEX and l[ROW_TYPE_INDEX] == 'pwi'
303 and l[PWI_POWER_INDEX] != 0): 305 and l[PWI_POWER_INDEX] != 0):
304 raise device_errors.CommandFailedError( 306 raise device_errors.CommandFailedError(
305 'Non-zero pmi value found after reset.') 307 'Non-zero pmi value found after reset.')
306 self._device.RunShellCommand(['dumpsys', 'battery', 'set', 'ac', '0'], 308 self._device.RunShellCommand(['dumpsys', 'battery', 'set', 'ac', '0'],
307 check_return=True) 309 check_return=True)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if temp is None: 398 if temp is None:
397 logging.warning('Unable to find current battery temperature.') 399 logging.warning('Unable to find current battery temperature.')
398 temp = 0 400 temp = 0
399 else: 401 else:
400 logging.info('Current battery temperature: %s', temp) 402 logging.info('Current battery temperature: %s', temp)
401 return int(temp) <= target_temp 403 return int(temp) <= target_temp
402 404
403 logging.info('Waiting for the device to cool down to %s degrees.', 405 logging.info('Waiting for the device to cool down to %s degrees.',
404 target_temp) 406 target_temp)
405 timeout_retry.WaitFor(cool_device, wait_period=wait_period) 407 timeout_retry.WaitFor(cool_device, wait_period=wait_period)
OLDNEW
« no previous file with comments | « build/android/pylib/device/adb_wrapper.py ('k') | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698