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 import tempfile | 6 import tempfile |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.core import exceptions | 9 from telemetry.core import exceptions |
10 from telemetry.core import platform | 10 from telemetry.core import platform |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) | 48 self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) |
49 self._no_performance_mode = no_performance_mode | 49 self._no_performance_mode = no_performance_mode |
50 self._raw_display_frame_rate_measurements = [] | 50 self._raw_display_frame_rate_measurements = [] |
51 self._can_access_protected_file_contents = \ | 51 self._can_access_protected_file_contents = \ |
52 self._device.old_interface.CanAccessProtectedFileContents() | 52 self._device.old_interface.CanAccessProtectedFileContents() |
53 power_controller = power_monitor_controller.PowerMonitorController([ | 53 power_controller = power_monitor_controller.PowerMonitorController([ |
54 monsoon_power_monitor.MonsoonPowerMonitor(), | 54 monsoon_power_monitor.MonsoonPowerMonitor(), |
55 android_ds2784_power_monitor.DS2784PowerMonitor(device), | 55 android_ds2784_power_monitor.DS2784PowerMonitor(device), |
56 android_dumpsys_power_monitor.DumpsysPowerMonitor(device), | 56 android_dumpsys_power_monitor.DumpsysPowerMonitor(device), |
57 ]) | 57 ]) |
58 self._powermonitor = android_temperature_monitor.AndroidTemperatureMonitor( | 58 self._power_monitor = android_temperature_monitor.AndroidTemperatureMonitor( |
59 power_controller, device) | 59 power_controller, device) |
60 self._video_recorder = None | 60 self._video_recorder = None |
61 if self._no_performance_mode: | 61 if self._no_performance_mode: |
62 logging.warning('CPU governor will not be set!') | 62 logging.warning('CPU governor will not be set!') |
63 | 63 |
64 def IsRawDisplayFrameRateSupported(self): | 64 def IsRawDisplayFrameRateSupported(self): |
65 return True | 65 return True |
66 | 66 |
67 def StartRawDisplayFrameRateMeasurement(self): | 67 def StartRawDisplayFrameRateMeasurement(self): |
68 assert not self._surface_stats_collector | 68 assert not self._surface_stats_collector |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 def StopVideoCapture(self): | 238 def StopVideoCapture(self): |
239 assert self.is_video_capture_running, 'Must start video capture first' | 239 assert self.is_video_capture_running, 'Must start video capture first' |
240 self._video_recorder.Stop() | 240 self._video_recorder.Stop() |
241 video_file_obj = tempfile.NamedTemporaryFile() | 241 video_file_obj = tempfile.NamedTemporaryFile() |
242 self._video_recorder.Pull(video_file_obj.name) | 242 self._video_recorder.Pull(video_file_obj.name) |
243 self._video_recorder = None | 243 self._video_recorder = None |
244 | 244 |
245 return video.Video(video_file_obj) | 245 return video.Video(video_file_obj) |
246 | 246 |
247 def CanMonitorPower(self): | 247 def CanMonitorPower(self): |
248 return self._powermonitor.CanMonitorPower() | 248 return self._power_monitor.CanMonitorPower() |
249 | 249 |
250 def StartMonitoringPower(self, browser): | 250 def StartMonitoringPower(self, browser): |
251 self._powermonitor.StartMonitoringPower(browser) | 251 self._power_monitor.StartMonitoringPower(browser) |
252 | 252 |
253 def StopMonitoringPower(self): | 253 def StopMonitoringPower(self): |
254 return self._powermonitor.StopMonitoringPower() | 254 return self._power_monitor.StopMonitoringPower() |
255 | 255 |
256 def _GetFileContents(self, fname): | 256 def _GetFileContents(self, fname): |
257 if not self._can_access_protected_file_contents: | 257 if not self._can_access_protected_file_contents: |
258 logging.warning('%s cannot be retrieved on non-rooted device.' % fname) | 258 logging.warning('%s cannot be retrieved on non-rooted device.' % fname) |
259 return '' | 259 return '' |
260 return '\n'.join(self._device.ReadFile(fname, as_root=True)) | 260 return '\n'.join(self._device.ReadFile(fname, as_root=True)) |
261 | 261 |
262 def _GetPsOutput(self, columns, pid=None): | 262 def _GetPsOutput(self, columns, pid=None): |
263 assert columns == ['pid', 'name'] or columns == ['pid'], \ | 263 assert columns == ['pid', 'name'] or columns == ['pid'], \ |
264 'Only know how to return pid and name. Requested: ' + columns | 264 'Only know how to return pid and name. Requested: ' + columns |
265 command = 'ps' | 265 command = 'ps' |
266 if pid: | 266 if pid: |
267 command += ' -p %d' % pid | 267 command += ' -p %d' % pid |
268 ps = self._device.RunShellCommand(command)[1:] | 268 ps = self._device.RunShellCommand(command)[1:] |
269 output = [] | 269 output = [] |
270 for line in ps: | 270 for line in ps: |
271 data = line.split() | 271 data = line.split() |
272 curr_pid = data[1] | 272 curr_pid = data[1] |
273 curr_name = data[-1] | 273 curr_name = data[-1] |
274 if columns == ['pid', 'name']: | 274 if columns == ['pid', 'name']: |
275 output.append([curr_pid, curr_name]) | 275 output.append([curr_pid, curr_name]) |
276 else: | 276 else: |
277 output.append([curr_pid]) | 277 output.append([curr_pid]) |
278 return output | 278 return output |
OLD | NEW |