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

Side by Side Diff: build/android/pylib/perf/thermal_throttle.py

Issue 333933003: [Android] Switch to DeviceUtils version of RunShellCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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 | « build/android/pylib/perf/surface_stats_collector.py ('k') | build/android/pylib/ports.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 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 def IsThrottled(self): 95 def IsThrottled(self):
96 """True if currently throttled.""" 96 """True if currently throttled."""
97 self._ReadLog() 97 self._ReadLog()
98 return self._throttled 98 return self._throttled
99 99
100 def _ReadLog(self): 100 def _ReadLog(self):
101 if not self._detector: 101 if not self._detector:
102 return False 102 return False
103 has_been_throttled = False 103 has_been_throttled = False
104 serial_number = self._device.old_interface.GetDevice() 104 serial_number = self._device.old_interface.GetDevice()
105 log = self._device.old_interface.RunShellCommand('dmesg -c') 105 log = self._device.RunShellCommand('dmesg -c')
106 degree_symbol = unichr(0x00B0) 106 degree_symbol = unichr(0x00B0)
107 for line in log: 107 for line in log:
108 if self._detector.BecameThrottled(line): 108 if self._detector.BecameThrottled(line):
109 if not self._throttled: 109 if not self._throttled:
110 logging.warning('>>> Device %s thermally throttled', serial_number) 110 logging.warning('>>> Device %s thermally throttled', serial_number)
111 self._throttled = True 111 self._throttled = True
112 has_been_throttled = True 112 has_been_throttled = True
113 elif self._detector.BecameUnthrottled(line): 113 elif self._detector.BecameUnthrottled(line):
114 if self._throttled: 114 if self._throttled:
115 logging.warning('>>> Device %s thermally unthrottled', serial_number) 115 logging.warning('>>> Device %s thermally unthrottled', serial_number)
116 self._throttled = False 116 self._throttled = False
117 has_been_throttled = True 117 has_been_throttled = True
118 temperature = self._detector.GetThrottlingTemperature(line) 118 temperature = self._detector.GetThrottlingTemperature(line)
119 if temperature is not None: 119 if temperature is not None:
120 logging.info(u'Device %s thermally throttled at %3.1f%sC', 120 logging.info(u'Device %s thermally throttled at %3.1f%sC',
121 serial_number, temperature, degree_symbol) 121 serial_number, temperature, degree_symbol)
122 122
123 if logging.getLogger().isEnabledFor(logging.DEBUG): 123 if logging.getLogger().isEnabledFor(logging.DEBUG):
124 # Print current temperature of CPU SoC. 124 # Print current temperature of CPU SoC.
125 temperature = self._detector.GetCurrentTemperature() 125 temperature = self._detector.GetCurrentTemperature()
126 if temperature is not None: 126 if temperature is not None:
127 logging.debug(u'Current SoC temperature of %s = %3.1f%sC', 127 logging.debug(u'Current SoC temperature of %s = %3.1f%sC',
128 serial_number, temperature, degree_symbol) 128 serial_number, temperature, degree_symbol)
129 129
130 # Print temperature of battery, to give a system temperature 130 # Print temperature of battery, to give a system temperature
131 dumpsys_log = self._device.old_interface.RunShellCommand( 131 dumpsys_log = self._device.RunShellCommand('dumpsys battery')
132 'dumpsys battery')
133 for line in dumpsys_log: 132 for line in dumpsys_log:
134 if 'temperature' in line: 133 if 'temperature' in line:
135 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 134 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0
136 logging.debug(u'Current battery temperature of %s = %3.1f%sC', 135 logging.debug(u'Current battery temperature of %s = %3.1f%sC',
137 serial_number, btemp, degree_symbol) 136 serial_number, btemp, degree_symbol)
138 137
139 return has_been_throttled 138 return has_been_throttled
140 139
OLDNEW
« no previous file with comments | « build/android/pylib/perf/surface_stats_collector.py ('k') | build/android/pylib/ports.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698