Beispiel #1
0
    def start(self):
        super(AtraceLegacyAgent, self).start()
        if self.expect_trace():
            SHELL_ARGS = ['getprop', 'debug.atrace.tags.enableflags']
            output, return_code = util.run_adb_shell(
                SHELL_ARGS, self._options.device_serial)
            if return_code != 0:
                print >> sys.stderr, (
                    '\nThe command "%s" failed with the following message:' %
                    ' '.join(SHELL_ARGS))
                print >> sys.stderr, str(output)
                sys.exit(1)

            flags = 0
            try:
                if output.startswith('0x'):
                    flags = int(output, 16)
                elif output.startswith('0'):
                    flags = int(output, 8)
                else:
                    flags = int(output)
            except ValueError:
                pass

            if flags:
                tags = []
                for desc, bit in LEGACY_TRACE_TAG_BITS:
                    if bit & flags:
                        tags.append(desc)
                categories = tags + self._categories
                print 'Collecting data with following categories:', ' '.join(
                    categories)
Beispiel #2
0
  def start(self):
    super(AtraceLegacyAgent, self).start()
    if self.expect_trace():
      SHELL_ARGS = ['getprop', 'debug.atrace.tags.enableflags']
      output, return_code = util.run_adb_shell(SHELL_ARGS,
                                               self._options.device_serial)
      if return_code != 0:
        print >> sys.stderr, (
            '\nThe command "%s" failed with the following message:'
            % ' '.join(SHELL_ARGS))
        print >> sys.stderr, str(output)
        sys.exit(1)

      flags = 0
      try:
        if output.startswith('0x'):
          flags = int(output, 16)
        elif output.startswith('0'):
          flags = int(output, 8)
        else:
          flags = int(output)
      except ValueError:
        pass

      if flags:
        tags = []
        for desc, bit in LEGACY_TRACE_TAG_BITS:
          if bit & flags:
            tags.append(desc)
        categories = tags + self._categories
        print 'Collecting data with following categories:', ' '.join(categories)
Beispiel #3
0
def do_preprocess_adb_cmd(command, serial):
    args = [command]
    dump, ret_code = util.run_adb_shell(args, serial)
    if ret_code != 0:
        return None

    dump = ''.join(dump)
    return dump
Beispiel #4
0
def do_preprocess_adb_cmd(command, serial):
  args = [command]
  dump, ret_code = util.run_adb_shell(args, serial)
  if ret_code != 0:
    return None

  dump = ''.join(dump)
  return dump
Beispiel #5
0
def get_default_categories(device_serial):
  categories_output, return_code = util.run_adb_shell(LIST_CATEGORIES_ARGS,
                                                    device_serial)

  if return_code == 0 and categories_output:
    categories = [c.split('-')[0].strip()
                  for c in categories_output.splitlines()]
    return [c for c in categories if c in DEFAULT_CATEGORIES]

  return []
Beispiel #6
0
def get_default_categories(device_serial):
    categories_output, return_code = util.run_adb_shell(
        LIST_CATEGORIES_ARGS, device_serial)

    if return_code == 0 and categories_output:
        categories = [
            c.split('-')[0].strip() for c in categories_output.splitlines()
        ]
        return [c for c in categories if c in DEFAULT_CATEGORIES]

    return []
Beispiel #7
0
def do_preprocess_adb_cmd(command, serial):
    """Run an ADB command for preprocessing of output.

  Run an ADB command and get the results. This function is used for
  running commands relating to preprocessing of output data.

  Args:
      command: Command to run.
      serial: Serial number of device.
  """

    args = [command]
    dump, ret_code = util.run_adb_shell(args, serial)
    if ret_code != 0:
        return None

    dump = ''.join(dump)
    return dump
Beispiel #8
0
def do_preprocess_adb_cmd(command, serial):
  """Run an ADB command for preprocessing of output.

  Run an ADB command and get the results. This function is used for
  running commands relating to preprocessing of output data.

  Args:
      command: Command to run.
      serial: Serial number of device.
  """

  args = [command]
  dump, ret_code = util.run_adb_shell(args, serial)
  if ret_code != 0:
    return None

  dump = ''.join(dump)
  return dump