Commit 6d11d3ee authored by tonyg's avatar tonyg Committed by Commit bot

[Telemetry] Support dumpsys power monitoring on the Nexus 5.

This adds the necessary commands to programmatically disable charging
on the Nexus 5 as well as fixing a bug in the dumpsys power monitor.

BUG=314481

Review URL: https://codereview.chromium.org/617453004

Cr-Commit-Position: refs/heads/master@{#297428}
parent 34010918
...@@ -78,6 +78,20 @@ CONTROL_USB_CHARGING_COMMANDS = [ ...@@ -78,6 +78,20 @@ CONTROL_USB_CHARGING_COMMANDS = [
'disable_command': 'disable_command':
'echo 1 > /sys/module/pm8921_charger/parameters/disabled', 'echo 1 > /sys/module/pm8921_charger/parameters/disabled',
}, },
{
# Nexus 5
# Setting the HIZ bit of the bq24192 causes the charger to actually ignore
# energy coming from USB. Setting the power_supply offline just updates the
# Android system to reflect that.
'witness_file': '/sys/kernel/debug/bq24192/INPUT_SRC_CONT',
'enable_command': (
'echo 0x4A > /sys/kernel/debug/bq24192/INPUT_SRC_CONT && '
'echo 1 > /sys/class/power_supply/usb/online'),
'disable_command': (
'echo 0xCA > /sys/kernel/debug/bq24192/INPUT_SRC_CONT && '
'chmod 644 /sys/class/power_supply/usb/online && '
'echo 0 > /sys/class/power_supply/usb/online'),
},
] ]
class DeviceTempFile(object): class DeviceTempFile(object):
......
...@@ -45,7 +45,8 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): ...@@ -45,7 +45,8 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor):
result = self._platform.RunCommand('dumpsys batterystats -c %s' % package) result = self._platform.RunCommand('dumpsys batterystats -c %s' % package)
assert result, 'Dumpsys produced no output' assert result, 'Dumpsys produced no output'
return super(DumpsysPowerMonitor, self).CombineResults( return super(DumpsysPowerMonitor, self).CombineResults(
cpu_stats, DumpsysPowerMonitor.ParseSamplingOutput(package, result)) cpu_stats, DumpsysPowerMonitor.ParseSamplingOutput(package,
result.split('\n')))
@staticmethod @staticmethod
def ParseSamplingOutput(package, dumpsys_output): def ParseSamplingOutput(package, dumpsys_output):
...@@ -103,8 +104,9 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): ...@@ -103,8 +104,9 @@ class DumpsysPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor):
# Find the uid of for the given package. # Find the uid of for the given package.
if not package in uid_entries: if not package in uid_entries:
logging.warning('Unable to parse dumpsys output. ' + logging.warning('Unable to parse dumpsys output. '
'Please upgrade the OS version of the device.') 'Please upgrade the OS version of the device.'
'package=%s, uid_entries=%s' % (package, uid_entries))
out_dict['energy_consumption_mwh'] = 0 out_dict['energy_consumption_mwh'] = 0
return out_dict return out_dict
uid = uid_entries[package] uid = uid_entries[package]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment