| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import logging | 5 import logging |
| 6 from pylib import android_commands | |
| 7 from pylib.device import device_utils | 6 from pylib.device import device_utils |
| 8 | 7 |
| 9 | 8 |
| 10 class OmapThrottlingDetector(object): | 9 class OmapThrottlingDetector(object): |
| 11 """Class to detect and track thermal throttling on an OMAP 4.""" | 10 """Class to detect and track thermal throttling on an OMAP 4.""" |
| 12 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/' | 11 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/' |
| 13 'temperature') | 12 'temperature') |
| 14 | 13 |
| 15 @staticmethod | 14 @staticmethod |
| 16 def IsSupported(device): | 15 def IsSupported(device): |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 class ThermalThrottle(object): | 65 class ThermalThrottle(object): |
| 67 """Class to detect and track thermal throttling. | 66 """Class to detect and track thermal throttling. |
| 68 | 67 |
| 69 Usage: | 68 Usage: |
| 70 Wait for IsThrottled() to be False before running test | 69 Wait for IsThrottled() to be False before running test |
| 71 After running test call HasBeenThrottled() to find out if the | 70 After running test call HasBeenThrottled() to find out if the |
| 72 test run was affected by thermal throttling. | 71 test run was affected by thermal throttling. |
| 73 """ | 72 """ |
| 74 | 73 |
| 75 def __init__(self, device): | 74 def __init__(self, device): |
| 76 # TODO(jbudorick) Remove once telemetry gets switched over. | |
| 77 assert not isinstance(device, android_commands.AndroidCommands) | |
| 78 self._device = device | 75 self._device = device |
| 79 self._throttled = False | 76 self._throttled = False |
| 80 self._detector = None | 77 self._detector = None |
| 81 if OmapThrottlingDetector.IsSupported(device): | 78 if OmapThrottlingDetector.IsSupported(device): |
| 82 self._detector = OmapThrottlingDetector(device) | 79 self._detector = OmapThrottlingDetector(device) |
| 83 elif ExynosThrottlingDetector.IsSupported(device): | 80 elif ExynosThrottlingDetector.IsSupported(device): |
| 84 self._detector = ExynosThrottlingDetector(device) | 81 self._detector = ExynosThrottlingDetector(device) |
| 85 | 82 |
| 86 def HasBeenThrottled(self): | 83 def HasBeenThrottled(self): |
| 87 """True if there has been any throttling since the last call to | 84 """True if there has been any throttling since the last call to |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 # Print temperature of battery, to give a system temperature | 124 # Print temperature of battery, to give a system temperature |
| 128 dumpsys_log = self._device.RunShellCommand('dumpsys battery') | 125 dumpsys_log = self._device.RunShellCommand('dumpsys battery') |
| 129 for line in dumpsys_log: | 126 for line in dumpsys_log: |
| 130 if 'temperature' in line: | 127 if 'temperature' in line: |
| 131 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 | 128 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 |
| 132 logging.debug(u'Current battery temperature of %s = %3.1f%sC', | 129 logging.debug(u'Current battery temperature of %s = %3.1f%sC', |
| 133 serial_number, btemp, degree_symbol) | 130 serial_number, btemp, degree_symbol) |
| 134 | 131 |
| 135 return has_been_throttled | 132 return has_been_throttled |
| 136 | 133 |
| OLD | NEW |