Index: build/android/pylib/android_commands.py |
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py |
index f000682b70641709bfe193dc6e13ebded47424c8..be2a5ec38689aa423687e9d406b6645ef84fc5c1 100644 |
--- a/build/android/pylib/android_commands.py |
+++ b/build/android/pylib/android_commands.py |
@@ -73,6 +73,14 @@ MD5SUM_DEVICE_FOLDER = constants.TEST_EXECUTABLE_DIR + '/md5sum/' |
MD5SUM_DEVICE_PATH = MD5SUM_DEVICE_FOLDER + 'md5sum_bin' |
MD5SUM_LD_LIBRARY_PATH = 'LD_LIBRARY_PATH=%s' % MD5SUM_DEVICE_FOLDER |
+CONTROL_BATTERY_CHARGING_COMMAND = [ |
Philippe
2014/04/01 09:51:58
Nit: s/COMMAND/COMMANDS?
qsr
2014/04/02 09:14:57
Done.
|
+ { |
tonyg
2014/04/01 16:13:18
WDYT about adding a comment listing some example d
qsr
2014/04/02 09:14:57
Done. This one if for the N4 and the only one I ha
|
+ 'witness_file': '/sys/module/pm8921_charger/parameters/disabled', |
+ 'enable_command': 'echo 0 > /sys/module/pm8921_charger/parameters/disabled', |
+ 'disable_command': |
+ 'echo 1 > /sys/module/pm8921_charger/parameters/disabled', |
+ }, |
+]; |
def GetAVDs(): |
"""Returns a list of AVDs.""" |
@@ -1825,6 +1833,30 @@ class AndroidCommands(object): |
logging.info('[%s]> %s', device_repr, line) |
self.RunShellCommand('rm %s' % temp_script_file) |
+ def _GetControlBatteryChargingCommand(self): |
+ for command in CONTROL_BATTERY_CHARGING_COMMAND: |
+ witness_file = command['witness_file'] |
+ if self.FileExistsOnDevice(witness_file): |
tonyg
2014/04/01 16:13:18
Maybe we should add an assert that all of the requ
qsr
2014/04/02 09:14:57
Done.
|
+ return command |
+ return None |
+ |
+ def CanControlBatteryCharging(self): |
tonyg
2014/04/01 16:13:18
Is BatteryCharging really the intent of this API?
qsr
2014/04/02 09:14:57
You are right. Will rename.
|
+ return self._GetControlBatteryChargingCommand() is not None |
+ |
+ def DisableBatteryCharging(self): |
+ command = self._GetControlBatteryChargingCommand() |
tonyg
2014/04/01 16:13:18
Can we cache the enable/disable command in _GetCon
qsr
2014/04/02 09:14:57
Done.
|
+ if not command: |
+ raise Exception('Unable to act on battery charing.') |
tonyg
2014/04/01 16:13:18
s/charing/charging/
qsr
2014/04/02 09:14:57
Done.
|
+ disable_command = command['disable_command'] |
+ self.RunShellCommand(disable_command) |
+ |
+ def EnableBatteryCharging(self): |
+ command = self._GetControlBatteryChargingCommand() |
+ if not command: |
+ raise Exception('Unable to act on battery charing.') |
+ disable_command = command['enable_command'] |
+ self.RunShellCommand(disable_command) |
+ |
class NewLineNormalizer(object): |
"""A file-like object to normalize EOLs to '\n'. |