Bug 1035254 - [mozdevice] - Add ADBAndroid.get_battery_percentage(), r=wlach, DONTBUILD.
authorBob Clary <bclary@bclary.com>
Thu, 10 Jul 2014 06:46:23 -0700
changeset 193385 6f559ac34685e5a8817e18fb7e4b9303c6766722
parent 193384 6a05955e2dc02016c1a496899877ee7fd9b5fa4a
child 193386 a60165250783d2b7340cdd7b436a8c906ebb7b26
push id7693
push userryanvm@gmail.com
push dateThu, 10 Jul 2014 22:28:27 +0000
treeherderfx-team@e1a037c085d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswlach, DONTBUILD
bugs1035254
milestone33.0a1
Bug 1035254 - [mozdevice] - Add ADBAndroid.get_battery_percentage(), r=wlach, DONTBUILD.
testing/mozbase/docs/mozdevice.rst
testing/mozbase/mozdevice/mozdevice/adb.py
testing/mozbase/mozdevice/mozdevice/adb_android.py
--- a/testing/mozbase/docs/mozdevice.rst
+++ b/testing/mozbase/docs/mozdevice.rst
@@ -195,16 +195,20 @@ Process management methods
 .. automethod:: ADBDevice.pkill(self, appname, sig=None,   attempts=3, wait=5, timeout=None, root=False)
 .. automethod:: ADBDevice.process_exist(self, process_name, timeout=None)
 
 
 ADBAndroid
 ``````````
 .. autoclass:: ADBAndroid
 
+Informational methods
++++++++++++++++++++++
+.. automethod:: ADBAndroid.get_battery_percentage(self, timeout=None)
+
 System control methods
 ++++++++++++++++++++++
 .. automethod:: ADBAndroid.is_device_ready(self, timeout=None)
 .. automethod:: ADBAndroid.power_on(self, timeout=None)
 .. automethod:: ADBAndroid.reboot(self, timeout=None)
 
 Application management methods
 ++++++++++++++++++++++++++++++
--- a/testing/mozbase/mozdevice/mozdevice/adb.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb.py
@@ -219,20 +219,18 @@ class ADBCommand(object):
         :param timeout: optional integer specifying the maximum time in seconds
             for any spawned adb process to complete before throwing
             an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBCommand constructor is used.
         :returns: string - content of stdout.
 
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         adb_process = None
         try:
             # Need to force the use of the ADBCommand class's command
             # since ADBDevice will redefine command and call its
             # own version otherwise.
             adb_process = ADBCommand.command(self, cmds,
@@ -330,69 +328,61 @@ class ADBHost(ADBCommand):
         :param timeout: optional integer specifying the maximum time in seconds
             for any spawned adb process to complete before throwing
             an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBHost constructor is used.
         :returns: string - content of stdout.
 
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         return ADBCommand.command_output(self, cmds, timeout=timeout)
 
     def start_server(self, timeout=None):
         """Starts the adb server.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per adb call. The
             total time spent may exceed this value. If it is not
             specified, the value set in the ADBHost constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         self.command_output(["start-server"], timeout=timeout)
 
     def kill_server(self, timeout=None):
         """Kills the adb server.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per adb call. The
             total time spent may exceed this value. If it is not
             specified, the value set in the ADBHost constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         self.command_output(["kill-server"], timeout=timeout)
 
     def devices(self, timeout=None):
         """Executes adb devices -l and returns a list of objects describing attached devices.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per adb call. The
             total time spent may exceed this value. If it is not
             specified, the value set in the ADBHost constructor is used.
         :returns: an object contain
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         The output of adb devices -l ::
 
             $ adb devices -l
             List of devices attached
             b313b945               device usb:1-7 product:d2vzw model:SCH_I535 device:d2vzw
 
         is parsed and placed into an object as in
@@ -587,18 +577,17 @@ class ADBDevice(ADBCommand):
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :raises: * ADBTimeoutError
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+                 * ADBRootError
                  * ADBError
 
         """
         # In order to catch situations where the file
         # system is temporily read only, attempt to
         # remove the old test root if it exists, then
         # recreate it.
         if self.test_root:
@@ -685,20 +674,18 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in seconds
             for any spawned adb process to complete before throwing
             an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :returns: string - content of stdout.
 
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         return ADBCommand.command_output(self, cmds,
                                          device_serial=self._device_serial,
                                          timeout=timeout)
 
     # Device Shell methods
 
@@ -713,18 +700,17 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per adb call. The
             total time spent may exceed this value. If it is not
             specified, the value set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :returns: :class:`mozdevice.ADBProcess`
-        :raises: ADBRootError - raised if root is requested but the
-                 device is not rooted.
+        :raises: ADBRootError
 
         shell() provides a low level interface for executing commands
         on the device via adb shell.
 
         shell() executes on the host in such as fashion that stdout
         contains the stdout of the host abd process combined with the
         combined stdout/stderr of the shell command on the device
         while stderr is still the stderr of the adb process on the
@@ -821,20 +807,18 @@ class ADBDevice(ADBCommand):
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :returns: boolean
 
-        :raises: * ADBTimeoutError  - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
 
         """
         adb_process = None
         try:
             adb_process = self.shell(cmd, env=env, cwd=cwd,
                                      timeout=timeout, root=root)
             if adb_process.timedout:
                 raise ADBTimeoutError("%s" % adb_process)
@@ -856,22 +840,19 @@ class ADBDevice(ADBCommand):
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per
             adb call. The total time spent may exceed this
             value. If it is not specified, the value set
             in the ADBDevice constructor is used.  :param root:
             optional boolean specifying if the command
             should be executed as root.
         :returns: string - content of stdout.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         adb_process = None
         try:
             adb_process = self.shell(cmd, env=env, cwd=cwd,
                                      timeout=timeout, root=root)
             if adb_process.timedout:
                 raise ADBTimeoutError("%s" % adb_process)
@@ -902,20 +883,18 @@ class ADBDevice(ADBCommand):
         """Clears logcat via adb logcat -c.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per
             adb call. The total time spent may exceed this
             value. If it is not specified, the value set
             in the ADBDevice constructor is used.
-        :raises: * ADBTimeoutError - raised if adb logcat takes longer than
-                   timeout seconds.
-                 * ADBError - raised if adb logcat exits with a non-zero
-                   exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         self.command_output(["logcat", "-c"], timeout=timeout)
 
     def get_logcat(self,
                   filter_specs=[
                       "dalvikvm:I",
                       "ConnectivityService:S",
@@ -935,20 +914,18 @@ class ADBDevice(ADBCommand):
             excluded.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :returns: list of lines logcat output.
-        :raises: * ADBTimeoutError - raised if adb logcat takes longer than
-                   timeout seconds.
-                 * ADBError - raised if adb logcat exits with a non-zero
-                   exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         cmds = ["logcat", "-v", format, "-d"] + filter_specs
         lines = self.command_output(cmds, timeout=timeout).split('\r')
 
         for regex in filter_out_regexps:
             lines = [line for line in lines if not re.search(regex, line)]
 
@@ -960,39 +937,35 @@ class ADBDevice(ADBCommand):
         :param prop: string containing the propery name.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :returns: string value of property.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if adb shell getprop exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         output = self.shell_output('getprop %s' % prop, timeout=timeout)
         return output
 
     def get_state(self, timeout=None):
         """Returns the device's state via adb get-state.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before throwing
             an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :returns: string value of adb get-state.
-        :raises: * ADBTimeoutError - raised if adb get-state takes longer
-                   than timeout seconds.
-                 * ADBError - raised if adb get-state exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         output = self.command_output(["get-state"], timeout=timeout).strip()
         return output
 
     # File management methods
 
     def chmod(self, path, recursive=False, mask="777", timeout=None, root=False):
@@ -1006,22 +979,19 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before throwing
             an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
-        :raises: * ADBTimeoutError - raised if any of the adb commands takes
-                   longer than timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError  - raised if any of the adb commands raises
-                   an uncaught ADBError.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         path = posixpath.normpath(path.strip())
         self._logger.debug('chmod: path=%s, recursive=%s, mask=%s, root=%s' %
                            (path, recursive, mask, root))
         self.shell_output("chmod %s %s" % (mask, path),
                           timeout=timeout, root=root)
         if recursive and self.is_dir(path, timeout=timeout, root=root):
@@ -1056,20 +1026,18 @@ class ADBDevice(ADBCommand):
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should be
             executed as root.
         :returns: boolean - True if path exists.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
 
         """
         path = posixpath.normpath(path)
         return self.shell_bool('ls -a %s' % path, timeout=timeout, root=root)
 
     def is_dir(self, path, timeout=None, root=False):
         """Returns True if path is an existing directory on the device.
 
@@ -1079,20 +1047,18 @@ class ADBDevice(ADBCommand):
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :returns: boolean - True if path exists on the device and is a
             directory.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
 
         """
         path = posixpath.normpath(path)
         return self.shell_bool('ls -a %s/' % path, timeout=timeout, root=root)
 
     def is_file(self, path, timeout=None, root=False):
         """Returns True if path is an existing file on the device.
 
@@ -1102,20 +1068,18 @@ class ADBDevice(ADBCommand):
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :returns: boolean - True if path exists on the device and is a
             file.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
 
         """
         path = posixpath.normpath(path)
         return (
             self.exists(path, timeout=timeout, root=root) and
             not self.is_dir(path, timeout=timeout, root=root))
 
     def list_files(self, path, timeout=None, root=False):
@@ -1127,20 +1091,18 @@ class ADBDevice(ADBCommand):
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
         :returns: list of files/directories contained in the directory.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
 
         """
         path = posixpath.normpath(path.strip())
         data = []
         if self.is_dir(path, timeout=timeout, root=root):
             try:
                 data = self.shell_output("%s %s" % (self._ls, path),
                                          timeout=timeout,
@@ -1163,23 +1125,19 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
-        :raises: * ADBTimeoutError - raised if any adb command takes longer
-                   than timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if adb shell mkdir exits with a
-                   non-zero exit code or if the directory is not
-                   created.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         path = posixpath.normpath(path)
         if parents:
             if self._mkdir_p is None or self._mkdir_p:
                 # Use shell_bool to catch the possible
                 # non-zero exitcode if -p is not supported.
                 if self.shell_bool('mkdir -p %s' % path, timeout=timeout):
@@ -1210,20 +1168,18 @@ class ADBDevice(ADBCommand):
         :param remote: string containing the name of the remote file or
             directory name.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
-        :raises: * ADBTimeoutError - raised if the adb push takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the adb push exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         self.command_output(["push", os.path.realpath(local), remote],
                             timeout=timeout)
 
     def rm(self, path, recursive=False, force=False, timeout=None, root=False):
         """Delete files or directories on the device.
 
@@ -1236,24 +1192,19 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
-        :raises: * ADBTimeoutError - raised if any of the adb commands takes
-                   longer than timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if the adb shell rm command exits
-                   with a non-zero exit code or if the file is not
-                   removed, or if force was not specified and the
-                   file did not exist.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         cmd = "rm"
         if recursive:
             cmd += " -r"
         try:
             self.shell_output("%s %s" % (cmd, path), timeout=timeout, root=root)
             if self.is_file(path, timeout=timeout, root=root):
@@ -1269,23 +1220,19 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if the adb shell rmdir command
-                   exits with a non-zero exit code or if the
-                   directory was not removed..
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         self.shell_output("rmdir %s" % path, timeout=timeout, root=root)
         if self.is_dir(path, timeout=timeout, root=root):
             raise ADBError('rmdir("%s") failed to remove directory.' % path)
 
     # Process management methods
 
@@ -1296,21 +1243,18 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time
             in seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified,
             the value set in the ADBDevice constructor is used.
         :returns: list of (pid, name, user) tuples for running processes
             on the device.
-        :raises: * ADBTimeoutError - raised if the adb shell ps command
-                   takes longer than timeout seconds.
-                 * ADBError - raised if the adb shell ps command exits
-                   with a non-zero exit code or if the ps output
-                   is not in the expected format.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         adb_process = None
         try:
             adb_process = self.shell("ps", timeout=timeout)
             if adb_process.timedout:
                 raise ADBTimeoutError("%s" % adb_process)
             elif adb_process.exitcode:
@@ -1360,23 +1304,19 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
-        :raises: * ADBTimeoutError - raised if adb shell kill takes longer
-                   than timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if adb shell kill exits with a
-                   non-zero exit code or not all of the processes have
-                   been killed.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         pid_list = [str(pid) for pid in pids]
         for attempt in range(attempts):
             args = ["kill"]
             if sig:
                 args.append("-%d" % sig)
             args.extend(pid_list)
@@ -1412,22 +1352,19 @@ class ADBDevice(ADBCommand):
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :param root: optional boolean specifying if the command should
             be executed as root.
 
-        :raises: * ADBTimeoutError - raised if any of the adb commands takes
-                   longer than timeout seconds.
-                 * ADBRootError - raised if root is requested but the
-                   device is not rooted.
-                 * ADBError - raised if any of the adb commands raises
-                   ADBError or if the process is not killed.
+        :raises: * ADBTimeoutError
+                 * ADBRootError
+                 * ADBError
 
         """
         procs = self.get_process_list(timeout=timeout)
         # limit the comparion to the first 75 characters due to a
         # limitation in processname length in android.
         pids = [proc[0] for proc in procs if proc[1] == appname[:75]]
         if not pids:
             return
@@ -1449,21 +1386,18 @@ class ADBDevice(ADBCommand):
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADBDevice constructor is used.
         :returns: boolean - True if process exists.
 
-        :raises: * ADBTimeoutError - raised if any of the adb commands takes
-                   longer than timeout seconds.
-                 * ADBError - raised if the adb shell ps command exits
-                   with a non-zero exit code or if the ps output is
-                   not in the expected format.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         if not isinstance(process_name, basestring):
             raise ADBError("Process name %s is not a string" % process_name)
 
         # Filter out extra spaces.
         parts = [x for x in process_name.split(' ') if x != '']
         process_name = ' '.join(parts)
--- a/testing/mozbase/mozdevice/mozdevice/adb_android.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb_android.py
@@ -1,39 +1,75 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
+import re
 import time
 
 from adb import ADBDevice, ADBError
 from distutils.version import StrictVersion
 
 
 class ADBAndroidMixin(object):
     """Mixin to extend ADB with Android-specific functionality"""
 
+    # Informational methods
+
+    def get_battery_percentage(self, timeout=None):
+        """Returns the battery charge as a percentage.
+
+        :param timeout: optional integer specifying the maximum time in
+            seconds for any spawned adb process to complete before
+            throwing an ADBTimeoutError.
+            This timeout is per adb call. The total time spent
+            may exceed this value. If it is not specified, the value
+            set in the ADBDevice constructor is used.
+        :returns: battery charge as a percentage.
+        :raises: * ADBTimeoutError
+                 * ADBError
+
+        """
+        level = None
+        scale = None
+        percentage = 0
+        cmd = "dumpsys battery"
+        re_parameter = re.compile(r'\s+(\w+):\s+(\d+)')
+        lines = self.shell_output(cmd, timeout=timeout).split('\r')
+        for line in lines:
+            match = re_parameter.match(line)
+            if match:
+                parameter = match.group(1)
+                value = match.group(2)
+                if parameter == 'level':
+                    level = float(value)
+                elif parameter == 'scale':
+                    scale = float(value)
+                if parameter is not None and scale is not None:
+                    percentage = 100.0*level/scale
+                    break
+        return percentage
+
     # System control methods
 
     def is_device_ready(self, timeout=None):
         """Checks if a device is ready for testing.
 
         This method uses the android only package manager to check for
         readiness.
 
         :param timeout: optional integer specifying the maximum time
             in seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the wait-for-device command fails.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         self.command_output(["wait-for-device"], timeout=timeout)
         pm_error_string = "Error: Could not access the Package Manager"
         pm_list_commands = ["packages", "permission-groups", "permissions",
                             "instrumentation", "features", "libraries"]
         ready_path = os.path.join(self.test_root, "ready")
         for attempt in range(self._device_ready_retry_attempts):
@@ -70,20 +106,18 @@ class ADBAndroidMixin(object):
         """Sets the device's power stayon value.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         try:
             self.shell_output('svc power stayon true', timeout=timeout)
         except ADBError, e:
             # Executing this via adb shell errors, but not interactively.
             # Any other exitcode is a real error.
             if 'exitcode: 137' not in e.message:
@@ -97,20 +131,18 @@ class ADBAndroidMixin(object):
         if the device is ready after the reboot.
 
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         reboot() reboots the device, issues an adb wait-for-device in order to
         wait for the device to complete rebooting, then calls is_device_ready()
         to determine if the device has completed booting.
 
         """
         self.command_output(["reboot"], timeout=timeout)
         self.command_output(["wait-for-device"], timeout=timeout)
@@ -124,20 +156,18 @@ class ADBAndroidMixin(object):
         :param apk_path: string containing the apk file name to be
             installed.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         data = self.command_output(["install", apk_path], timeout=timeout)
         if data.find('Success') == -1:
             raise ADBError("install failed for %s. Got: %s" %
                            (apk_path, data))
 
     def is_app_installed(self, app_name, timeout=None):
@@ -146,20 +176,18 @@ class ADBAndroidMixin(object):
         :param app_name: string containing the name of the app to be
             checked.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         pm_error_string = 'Error: Could not access the Package Manager'
         data = self.shell_output("pm list package %s" % app_name, timeout=timeout)
         if pm_error_string in data:
             raise ADBError(pm_error_string)
         if app_name not in data:
             return False
@@ -180,20 +208,18 @@ class ADBAndroidMixin(object):
         :param fail_if_running: Raise an exception if instance of
             application is already running.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         # If fail_if_running is True, we throw an exception here. Only one
         # instance of an application can be running at once on Android,
         # starting a new instance may not be what we want depending on what
         # we want to do
         if fail_if_running and self.process_exist(app_name, timeout=timeout):
             raise ADBError("Only one instance of an application may be running "
@@ -239,20 +265,18 @@ class ADBAndroidMixin(object):
         :param fail_if_running: Raise an exception if instance of
             application is already running
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         extras = {}
 
         if moz_env:
             # moz_env is expected to be a dictionary of environment variables:
             # Fennec itself will set them when launched
             for (env_count, (env_key, env_val)) in enumerate(moz_env.iteritems()):
@@ -278,20 +302,18 @@ class ADBAndroidMixin(object):
 
         :param app_name: Name of application (e.g. `com.android.chrome`)
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         version = self.shell_output("getprop ro.build.version.release",
                                     timeout=timeout, root=root)
         if StrictVersion(version) >= StrictVersion('3.0'):
             self.shell_output("am force-stop %s" % app_name,
                               timeout=timeout, root=root)
         else:
@@ -319,20 +341,18 @@ class ADBAndroidMixin(object):
             be rebooted after the app is uninstalled. No reboot occurs
             if the app is not installed.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         if self.is_app_installed(app_name, timeout=timeout):
             data = self.command_output(["uninstall", app_name], timeout=timeout)
             if data.find('Success') == -1:
                 self._logger.debug('uninstall_app failed: %s' % data)
                 raise ADBError("uninstall failed for %s. Got: %s" % (app_name, data))
             if reboot:
@@ -344,20 +364,18 @@ class ADBAndroidMixin(object):
         :param apk_path: string containing the apk file name to be
             updated.
         :param timeout: optional integer specifying the maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.
             This timeout is per adb call. The total time spent
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
-        :raises: * ADBTimeoutError - raised if the command takes longer than
-                   timeout seconds.
-                 * ADBError - raised if the command exits with a
-                   non-zero exit code.
+        :raises: * ADBTimeoutError
+                 * ADBError
 
         """
         output = self.command_output(["install", "-r", apk_path],
                                      timeout=timeout)
         self.reboot(timeout=timeout)
         return output