| Index: tools/telemetry/telemetry/internal/platform/power_monitor/android_temperature_monitor.py
|
| diff --git a/tools/telemetry/telemetry/internal/platform/power_monitor/android_temperature_monitor.py b/tools/telemetry/telemetry/internal/platform/power_monitor/android_temperature_monitor.py
|
| index 436dac47cf27f8a642aaf7238cd5796303808257..ebf5774eb44e1fe8b96d5c2eb7e8654d6a631288 100644
|
| --- a/tools/telemetry/telemetry/internal/platform/power_monitor/android_temperature_monitor.py
|
| +++ b/tools/telemetry/telemetry/internal/platform/power_monitor/android_temperature_monitor.py
|
| @@ -2,6 +2,8 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import logging
|
| +
|
| from telemetry.internal.platform import power_monitor
|
|
|
| try:
|
| @@ -25,35 +27,26 @@ class AndroidTemperatureMonitor(power_monitor.PowerMonitor):
|
| return self._GetBoardTemperatureCelsius() is not None
|
|
|
| def StartMonitoringPower(self, browser):
|
| + # don't call _CheckStart() because this is temperature, not power
|
| + # therefore, StartMonitoringPower and StopMonitoringPower
|
| + # do not need to be paired
|
| pass
|
|
|
| def StopMonitoringPower(self):
|
| - power_data = {'identifier': 'android_temperature_monitor'}
|
| -
|
| - # Take the current temperature as average based on the assumption that the
|
| - # temperature changes slowly during measurement time.
|
| - average_temperature = self._GetBoardTemperatureCelsius()
|
| - if average_temperature is None:
|
| - return power_data
|
| -
|
| - # Insert temperature into the appropriate position in the dictionary
|
| - # returned by StopMonitoringPower() creating appropriate sub-dictionaries on
|
| - # the way if necessary.
|
| - temperature_path = [
|
| - 'platform_info', 'average_temperature_c']
|
| - temperature_insertion_point = power_data
|
| - for path_element in temperature_path[:-1]:
|
| - if not path_element in temperature_insertion_point:
|
| - temperature_insertion_point[path_element] = {}
|
| - temperature_insertion_point = temperature_insertion_point[path_element]
|
| - assert temperature_path[-1] not in temperature_insertion_point
|
| - temperature_insertion_point[temperature_path[-1]] = average_temperature
|
| -
|
| - return power_data
|
| + avg_temp = self._GetBoardTemperatureCelsius()
|
| + if avg_temp is None:
|
| + return {'identifier': 'android_temperature_monitor'}
|
| + else:
|
| + return {'identifier': 'android_temperature_monitor',
|
| + 'platform_info': {'average_temperature_c': avg_temp}}
|
|
|
| def _GetBoardTemperatureCelsius(self):
|
| try:
|
| contents = self._device.ReadFile(_TEMPERATURE_FILE)
|
| return float(contents) if contents else None
|
| + except ValueError:
|
| + logging.warning('String returned from device.ReadFile(_TEMPERATURE_FILE) '
|
| + 'in invalid format.')
|
| + return None
|
| except device_errors.CommandFailedError:
|
| return None
|
|
|