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

Unified Diff: tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py

Issue 1057563002: [Android] Convert to BatteryUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698