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 | 6 from pylib import android_commands |
7 from pylib.device import device_utils | 7 from pylib.device import device_utils |
8 | 8 |
9 | 9 |
10 class OmapThrottlingDetector(object): | 10 class OmapThrottlingDetector(object): |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 def IsThrottled(self): | 93 def IsThrottled(self): |
94 """True if currently throttled.""" | 94 """True if currently throttled.""" |
95 self._ReadLog() | 95 self._ReadLog() |
96 return self._throttled | 96 return self._throttled |
97 | 97 |
98 def _ReadLog(self): | 98 def _ReadLog(self): |
99 if not self._detector: | 99 if not self._detector: |
100 return False | 100 return False |
101 has_been_throttled = False | 101 has_been_throttled = False |
102 serial_number = self._device.old_interface.GetDevice() | 102 serial_number = str(self._device) |
103 log = self._device.RunShellCommand('dmesg -c') | 103 log = self._device.RunShellCommand('dmesg -c') |
104 degree_symbol = unichr(0x00B0) | 104 degree_symbol = unichr(0x00B0) |
105 for line in log: | 105 for line in log: |
106 if self._detector.BecameThrottled(line): | 106 if self._detector.BecameThrottled(line): |
107 if not self._throttled: | 107 if not self._throttled: |
108 logging.warning('>>> Device %s thermally throttled', serial_number) | 108 logging.warning('>>> Device %s thermally throttled', serial_number) |
109 self._throttled = True | 109 self._throttled = True |
110 has_been_throttled = True | 110 has_been_throttled = True |
111 elif self._detector.BecameUnthrottled(line): | 111 elif self._detector.BecameUnthrottled(line): |
112 if self._throttled: | 112 if self._throttled: |
(...skipping 15 matching lines...) Expand all Loading... |
128 # Print temperature of battery, to give a system temperature | 128 # Print temperature of battery, to give a system temperature |
129 dumpsys_log = self._device.RunShellCommand('dumpsys battery') | 129 dumpsys_log = self._device.RunShellCommand('dumpsys battery') |
130 for line in dumpsys_log: | 130 for line in dumpsys_log: |
131 if 'temperature' in line: | 131 if 'temperature' in line: |
132 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 | 132 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 |
133 logging.debug(u'Current battery temperature of %s = %3.1f%sC', | 133 logging.debug(u'Current battery temperature of %s = %3.1f%sC', |
134 serial_number, btemp, degree_symbol) | 134 serial_number, btemp, degree_symbol) |
135 | 135 |
136 return has_been_throttled | 136 return has_been_throttled |
137 | 137 |
OLD | NEW |