OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os | 6 import os |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.core.platform.profiler import android_prebuilt_profiler_helper | 9 from telemetry.core.platform.profiler import android_prebuilt_profiler_helper |
10 import telemetry.core.platform.power_monitor as power_monitor | 10 import telemetry.core.platform.power_monitor as power_monitor |
(...skipping 11 matching lines...) Expand all Loading... |
22 def __init__(self, device): | 22 def __init__(self, device): |
23 super(DS2784PowerMonitor, self).__init__() | 23 super(DS2784PowerMonitor, self).__init__() |
24 self._device = device | 24 self._device = device |
25 self._powermonitor_process_port = None | 25 self._powermonitor_process_port = None |
26 self._file_poller_binary = android_prebuilt_profiler_helper.GetDevicePath( | 26 self._file_poller_binary = android_prebuilt_profiler_helper.GetDevicePath( |
27 'file_poller') | 27 'file_poller') |
28 | 28 |
29 | 29 |
30 @decorators.Cache | 30 @decorators.Cache |
31 def _HasFuelGauge(self): | 31 def _HasFuelGauge(self): |
32 return self._device.old_interface.FileExistsOnDevice(CHARGE_COUNTER) | 32 return self._device.FileExists(CHARGE_COUNTER) |
33 | 33 |
34 def CanMonitorPower(self): | 34 def CanMonitorPower(self): |
35 if not self._HasFuelGauge(): | 35 if not self._HasFuelGauge(): |
36 return False | 36 return False |
37 if self._device.old_interface.IsDeviceCharging(): | 37 if self._device.old_interface.IsDeviceCharging(): |
38 logging.warning('Can\'t monitor power usage since device is charging.') | 38 logging.warning('Can\'t monitor power usage since device is charging.') |
39 return False | 39 return False |
40 return True | 40 return True |
41 | 41 |
42 def StartMonitoringPower(self, browser): | 42 def StartMonitoringPower(self, browser): |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 total_energy_consumption_mwh += remaining_energy_consumption_mwh | 119 total_energy_consumption_mwh += remaining_energy_consumption_mwh |
120 | 120 |
121 # -------- Collect and Process Data ------------- | 121 # -------- Collect and Process Data ------------- |
122 out_dict = {} | 122 out_dict = {} |
123 # Raw power usage samples. | 123 # Raw power usage samples. |
124 out_dict['identifier'] = 'ds2784' | 124 out_dict['identifier'] = 'ds2784' |
125 out_dict['power_samples_mw'] = power_samples | 125 out_dict['power_samples_mw'] = power_samples |
126 out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh | 126 out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh |
127 | 127 |
128 return out_dict | 128 return out_dict |
OLD | NEW |