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

Side by Side Diff: build/android/devil/android/battery_utils.py

Issue 1315743004: [Android] Add a custom pylintrc for build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix appurify_sanitized import-errors Created 5 years, 3 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
11 import csv 11 import csv
12 import logging 12 import logging
13 13
14 from devil.android import decorators 14 from devil.android import decorators
15 from devil.android import device_errors 15 from devil.android import device_errors
16 from devil.android import device_utils 16 from devil.android import device_utils
17 from devil.android.sdk import version_codes 17 from devil.android.sdk import version_codes
18 from devil.utils import timeout_retry 18 from devil.utils import timeout_retry
19 from pylib import constants
20 19
21 _DEFAULT_TIMEOUT = 30 20 _DEFAULT_TIMEOUT = 30
22 _DEFAULT_RETRIES = 3 21 _DEFAULT_RETRIES = 3
23 22
24 23
25 _DEVICE_PROFILES = [ 24 _DEVICE_PROFILES = [
26 { 25 {
27 'name': 'Nexus 4', 26 'name': 'Nexus 4',
28 'witness_file': '/sys/module/pm8921_charger/parameters/disabled', 27 'witness_file': '/sys/module/pm8921_charger/parameters/disabled',
29 'enable_command': ( 28 'enable_command': (
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 after_measurements() # Anything that runs after power 416 after_measurements() # Anything that runs after power
418 # measurements are collected 417 # measurements are collected
419 418
420 Args: 419 Args:
421 timeout: timeout in seconds 420 timeout: timeout in seconds
422 retries: number of retries 421 retries: number of retries
423 422
424 Raises: 423 Raises:
425 device_errors.DeviceVersionError: If device is not L or higher. 424 device_errors.DeviceVersionError: If device is not L or higher.
426 """ 425 """
427 if (self._device.build_version_sdk < version_codes.LOLLIPOP): 426 if self._device.build_version_sdk < version_codes.LOLLIPOP:
428 raise device_errors.DeviceVersionError('Device must be L or higher.') 427 raise device_errors.DeviceVersionError('Device must be L or higher.')
429 try: 428 try:
430 self.DisableBatteryUpdates(timeout=timeout, retries=retries) 429 self.DisableBatteryUpdates(timeout=timeout, retries=retries)
431 yield 430 yield
432 finally: 431 finally:
433 self.EnableBatteryUpdates(timeout=timeout, retries=retries) 432 self.EnableBatteryUpdates(timeout=timeout, retries=retries)
434 433
435 def _DischargeDevice(self, percent, wait_period=120): 434 def _DischargeDevice(self, percent, wait_period=120):
436 """Disables charging and waits for device to discharge given amount 435 """Disables charging and waits for device to discharge given amount
437 436
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 charging so that it will collect power data since last charge. 575 charging so that it will collect power data since last charge.
577 576
578 Returns: 577 Returns:
579 True if power data cleared. 578 True if power data cleared.
580 False if power data clearing is not supported (pre-L) 579 False if power data clearing is not supported (pre-L)
581 580
582 Raises: 581 Raises:
583 device_errors.DeviceVersionError: If power clearing is supported, 582 device_errors.DeviceVersionError: If power clearing is supported,
584 but fails. 583 but fails.
585 """ 584 """
586 if (self._device.build_version_sdk < version_codes.LOLLIPOP): 585 if self._device.build_version_sdk < version_codes.LOLLIPOP:
587 logging.warning('Dumpsys power data only available on 5.0 and above. ' 586 logging.warning('Dumpsys power data only available on 5.0 and above. '
588 'Cannot clear power data.') 587 'Cannot clear power data.')
589 return False 588 return False
590 589
591 self._device.RunShellCommand( 590 self._device.RunShellCommand(
592 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True) 591 ['dumpsys', 'battery', 'set', 'usb', '1'], check_return=True)
593 self._device.RunShellCommand( 592 self._device.RunShellCommand(
594 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True) 593 ['dumpsys', 'battery', 'set', 'ac', '1'], check_return=True)
595 self._device.RunShellCommand( 594 self._device.RunShellCommand(
596 ['dumpsys', 'batterystats', '--reset'], check_return=True) 595 ['dumpsys', 'batterystats', '--reset'], check_return=True)
(...skipping 28 matching lines...) Expand all
625 self._cache['profile'] = { 624 self._cache['profile'] = {
626 'name': None, 625 'name': None,
627 'witness_file': None, 626 'witness_file': None,
628 'enable_command': None, 627 'enable_command': None,
629 'disable_command': None, 628 'disable_command': None,
630 'charge_counter': None, 629 'charge_counter': None,
631 'voltage': None, 630 'voltage': None,
632 'current': None, 631 'current': None,
633 } 632 }
634 return False 633 return False
OLDNEW
« no previous file with comments | « build/android/devil/android/apk_helper.py ('k') | build/android/devil/android/battery_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698