Index: tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py |
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py |
index 5e7f3079b7263d2ee0e4215cf5216356a969dcc5..e9fbfe630b0a7765df05cbc124a4d1081377a65e 100644 |
--- a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py |
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py |
@@ -6,8 +6,12 @@ from collections import defaultdict |
import csv |
import logging |
+from telemetry.core import util |
from telemetry.core.platform.power_monitor import sysfs_power_monitor |
+# Get build/android scripts into path |
+util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') |
+from pylib.device import battery_utils # pylint: disable=F0401 |
class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): |
"""PowerMonitor that relies on the dumpsys batterystats to monitor the power |
@@ -25,6 +29,7 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): |
super(DumpsysPowerMonitor, self).__init__(platform_backend) |
self._browser = None |
self._device = device |
+ self._battery = battery_utils.BatteryUtils(device) |
def CanMonitorPower(self): |
return self._device.old_interface.CanControlUsbCharging() |
@@ -35,14 +40,14 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): |
# Disable the charging of the device over USB. This is necessary because the |
# device only collects information about power usage when the device is not |
# charging. |
- self._device.DisableBatteryUpdates() |
+ self._battery.DisableBatteryUpdates() |
def StopMonitoringPower(self): |
if self._browser: |
package = self._browser._browser_backend.package |
self._browser = None |
cpu_stats = super(DumpsysPowerMonitor, self).StopMonitoringPower() |
- self._device.EnableBatteryUpdates() |
+ self._battery.EnableBatteryUpdates() |
# By default, 'dumpsys batterystats' measures power consumption during the |
# last unplugged period. |
result = self._platform.RunCommand('dumpsys batterystats -c %s' % package) |