Exemplo n.º 1
0
def try_create_agent(config):
    """Create an Atrace agent.

  Args:
      config: Command line config.
  """
    if config.target != 'android':
        return None
    if config.from_file is not None:
        return None

    if not config.atrace_categories:
        return None

    # Check device SDK version.
    device_sdk_version = util.get_device_sdk_version()
    if device_sdk_version <= 17:
        print(
            'Device SDK versions <= 17 not supported.\n'
            'Your device SDK version is %d.' % device_sdk_version)
        return None
    if device_sdk_version <= 22 and config.boot:
        print(
            '--boot option does not work on the device SDK '
            'version 22 or before.\nYour device SDK version '
            'is %d.' % device_sdk_version)
        return None
    return BootAgent() if config.boot else AtraceAgent()
Exemplo n.º 2
0
def try_create_agent(options):
  """Create an Atrace agent.

  Args:
      options: Command line options.
      categories: Categories of trace events to capture.
  """
  if options.target != 'android':
    return False
  if options.from_file is not None:
    return False

  # Check device SDK version.
  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version <= 17:
    print ('Device SDK versions <= 17 not supported.\n'
           'Your device SDK version is %d.' % device_sdk_version)
    return False
  if device_sdk_version <= 22 and options.boot:
    print ('--boot option does not work on the device SDK '
           'version 22 or before.\nYour device SDK version '
           'is %d.' % device_sdk_version)
    return False

  return BootAgent() if options.boot else AtraceAgent()
Exemplo n.º 3
0
def try_create_agent(config):
  """Create an Atrace agent.

  Args:
      config: Command line config.
  """
  if config.target != 'android':
    return None
  if config.from_file is not None:
    return None

  if not config.atrace_categories:
    return None

  # Check device SDK version.
  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version <= 17:
    print ('Device SDK versions <= 17 not supported.\n'
           'Your device SDK version is %d.' % device_sdk_version)
    return None
  if device_sdk_version <= 22 and config.boot:
    print ('--boot option does not work on the device SDK '
           'version 22 or before.\nYour device SDK version '
           'is %d.' % device_sdk_version)
    return None
  return BootAgent() if config.boot else AtraceAgent()
Exemplo n.º 4
0
def try_create_agent(options):
  """Create an Atrace agent.

  Args:
      options: Command line options.
      categories: Categories of trace events to capture.
  """
  if options.target != 'android':
    return False
  if options.from_file is not None:
    return False

  # Check device SDK version.
  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version <= 17:
    print ('Device SDK versions <= 17 not supported.\n'
           'Your device SDK version is %d.' % device_sdk_version)
    return False
  if device_sdk_version <= 22 and options.boot:
    print ('--boot option does not work on the device SDK '
           'version 22 or before.\nYour device SDK version '
           'is %d.' % device_sdk_version)
    return False

  return BootAgent() if options.boot else AtraceAgent()
Exemplo n.º 5
0
def list_categories(config):
  """List the possible trace event categories.

  This function needs the tracing config since it needs to get the serial
  number of the device to send a command to.

  Args:
      config: Tracing config.
  """
  devutils = device_utils.DeviceUtils(config.device_serial_number)
  categories = devutils.RunShellCommand(
      LIST_CATEGORIES_ARGS, check_return=True)

  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version < version_codes.MARSHMALLOW:
    # work around platform bug where rs tag would corrupt trace until M(Api23)
    categories = [c for c in categories if not re.match(r'^\s*rs\s*-', c)]

  print '\n'.join(categories)
  if not devutils.HasRoot():
    print '\nNOTE: more categories may be available with adb root\n'
Exemplo n.º 6
0
def list_categories(config):
    """List the possible trace event categories.

  This function needs the tracing config since it needs to get the serial
  number of the device to send a command to.

  Args:
      config: Tracing config.
  """
    devutils = device_utils.DeviceUtils(config.device_serial_number)
    categories = devutils.RunShellCommand(LIST_CATEGORIES_ARGS,
                                          check_return=True)

    device_sdk_version = util.get_device_sdk_version()
    if device_sdk_version < version_codes.MARSHMALLOW:
        # work around platform bug where rs tag would corrupt trace until M(Api23)
        categories = [c for c in categories if not re.match(r'^\s*rs\s*-', c)]

    print '\n'.join(categories)
    if not devutils.HasRoot():
        print '\nNOTE: more categories may be available with adb root\n'
Exemplo n.º 7
0
def try_create_agent(options, categories):
  if options.target != 'android':
    return False
  if options.from_file is not None:
    return AtraceAgent(options, categories)

  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version >= 18:
    if options.boot:
      # atrace --async_stop, which is used by BootAgent, does not work properly
      # on the device SDK version 22 or before.
      if device_sdk_version <= 22:
        print >> sys.stderr, ('--boot option does not work on the device SDK '
                              'version 22 or before.\nYour device SDK version '
                              'is %d.' % device_sdk_version)
        sys.exit(1)
      return BootAgent(options, categories)
    else:
      return AtraceAgent(options, categories)
  elif device_sdk_version >= 16:
    return AtraceLegacyAgent(options, categories)
Exemplo n.º 8
0
def try_create_agent(config):
  """Create an Atrace agent.

  Args:
      config: Command line config.
  """
  if config.target != 'android':
    return None
  if config.from_file is not None:
    return None

  if not config.atrace_categories:
    return None

  # Check device SDK version.
  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version < version_codes.JELLY_BEAN_MR2:
    print ('Device SDK versions < 18 (Jellybean MR2) not supported.\n'
           'Your device SDK version is %d.' % device_sdk_version)
    return None

  return AtraceAgent(device_sdk_version)
Exemplo n.º 9
0
def try_create_agent(config):
  """Create an Atrace agent.

  Args:
      config: Command line config.
  """
  if config.target != 'android':
    return None
  if config.from_file is not None:
    return None

  if not config.atrace_categories:
    return None

  # Check device SDK version.
  device_sdk_version = util.get_device_sdk_version()
  if device_sdk_version < version_codes.JELLY_BEAN_MR2:
    print ('Device SDK versions < 18 (Jellybean MR2) not supported.\n'
           'Your device SDK version is %d.' % device_sdk_version)
    return None

  return AtraceAgent(device_sdk_version)
Exemplo n.º 10
0
def try_create_agent(options, categories):
    if options.target != 'android':
        return False
    if options.from_file is not None:
        return AtraceAgent(options, categories)

    device_sdk_version = util.get_device_sdk_version()
    if device_sdk_version >= 18:
        if options.boot:
            # atrace --async_stop, which is used by BootAgent, does not work properly
            # on the device SDK version 22 or before.
            if device_sdk_version <= 22:
                print >> sys.stderr, (
                    '--boot option does not work on the device SDK '
                    'version 22 or before.\nYour device SDK version '
                    'is %d.' % device_sdk_version)
                sys.exit(1)
            return BootAgent(options, categories)
        else:
            return AtraceAgent(options, categories)
    elif device_sdk_version >= 16:
        return AtraceLegacyAgent(options, categories)