[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}


CrOS-Libchrome-Original-Commit: 6d11d3ee12a5ef05d5570661737a900105186fc6
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 0a4b2f0..ea86e6d 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -78,6 +78,20 @@
     'disable_command':
         '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):