Example #1
0
    def logcat_get(target, out_file):
        """
        Collect the logs from logcat.

        :param target: instance of devlib Android target
        :type target: devlib.target.AndroidTarget

        :param out_file: output file name
        :type out_file: str
        """
        adb_command(target.adb_name, 'logcat * -d > {}'.format(out_file))
Example #2
0
    def install_apk(target, apk_path):
        """
        Get a dictionary of installed APKs and related information

        :param target: instance of devlib Android target
        :type target: devlib.target.AndroidTarget

        :param apk_path: path to application
        :type apk_path: str
        """
        adb_command(target.adb_name, ADB_INSTALL_CMD.format(apk_path))
Example #3
0
    def start(self, document_root, target):
        # Create the server, and find out the port we've been assigned...
        self._httpd = HTTPServer(("", 0), DifferentDirectoryHTTPRequestHandler)
        # (This property is expected to be read by the
        #  DifferentDirectoryHTTPRequestHandler.translate_path method.)
        self._httpd.document_root = document_root
        _, self._port = self._httpd.server_address

        self._thread = ArchiveServerThread(self._httpd)
        self._thread.start()

        adb_command(target.adb_name, "reverse tcp:{0} tcp:{0}".format(self._port))
Example #4
0
    def gfxinfo_get(target, apk_name, out_file):
        """
        Collect frame statistics for the given app.

        :param target: instance of devlib Android target
        :type target: devlib.target.AndroidTarget

        :param apk_name: name of the apk
        :type apk_name: str

        :param out_file: output file name
        :type out_file: str
        """
        adb_command(target.adb_name,
                    GET_FRAMESTATS_CMD.format(apk_name, out_file))
Example #5
0
    def gfxinfo_get(target, apk_name, out_file):
        """
        Collect frame statistics for the given app.

        :param target: instance of devlib Android target
        :type target: devlib.target.AndroidTarget

        :param apk_name: name of the apk
        :type apk_name: str

        :param out_file: output file name
        :type out_file: str
        """
        adb_command(target.adb_name,
                    GET_FRAMESTATS_CMD.format(apk_name, out_file))
Example #6
0
    def surfaceflinger_get(target, apk_name, out_file):
        """
        Collect SurfaceFlinger layer statistics for the given app.

        :param target: instance of devlib Android target
        :type target: devlib.target.AndroidTarget

        :param apk_name: name of the apk
        :type apk_name: str

        :param out_file: output file name
        :type out_file: str
        """
        adb_command(target.adb_name,
                    'shell dumpsys SurfaceFlinger {} > {}'.format(apk_name, out_file))
Example #7
0
 def install_apk(self, filepath, timeout=None):  # pylint: disable=W0221
     ext = os.path.splitext(filepath)[1].lower()
     if ext == '.apk':
         return adb_command(self.adb_name,
                            "install {}".format(filepath),
                            timeout=timeout)
     else:
         raise TargetError(
             'Can\'t install {}: unsupported format.'.format(filepath))
Example #8
0
 def clear_logcat(self):
     adb_command(self.adb_name, 'logcat -c', timeout=30)
Example #9
0
 def dump_logcat(self, filepath, filter=None, append=False, timeout=30):  # pylint: disable=redefined-builtin
     op = '>>' if append else '>'
     filtstr = ' -s {}'.format(filter) if filter else ''
     command = 'logcat -d{} {} {}'.format(filtstr, op, filepath)
     adb_command(self.adb_name, command, timeout=timeout)
Example #10
0
 def uninstall_package(self, package):
     adb_command(self.adb_name, "uninstall {}".format(package), timeout=30)
Example #11
0
 def install_apk(self, filepath, timeout=None):  # pylint: disable=W0221
     ext = os.path.splitext(filepath)[1].lower()
     if ext == '.apk':
         return adb_command(self.adb_name, "install '{}'".format(filepath), timeout=timeout)
     else:
         raise TargetError('Can\'t install {}: unsupported format.'.format(filepath))
Example #12
0
    def stop(self, target):
        adb_command(target.adb_name, "reverse --remove tcp:{}".format(self._port))

        self._httpd.shutdown()
        self._thread.join()
Example #13
0
 def hide_from_device(self, target):
     adb_command(target.adb_name,
                 "reverse --remove tcp:{}".format(self._port))
Example #14
0
 def expose_to_device(self, target):
     adb_command(target.adb_name,
                 "reverse tcp:{0} tcp:{0}".format(self._port))
Example #15
0
 def dump_logcat(self, filepath, filter=None, append=False, timeout=30):  # pylint: disable=redefined-builtin
     op = ">>" if append == True else ">"
     filtstr = " -s {}".format(filter) if filter else ""
     command = "logcat -d{} {} {}".format(filtstr, op, filepath)
     adb_command(self.adb_name, command, timeout=timeout)