Example #1
0
def _RunApkAnalyzer(apk_path, output_directory):
  args = [path_util.GetApkAnalyzerPath(output_directory), 'dex', 'packages',
          apk_path]
  mapping_path = apk_path + '.mapping'
  if os.path.exists(mapping_path):
    args.extend(['--proguard-mappings', mapping_path])
  output = subprocess.check_output(args)
  data = []
  for line in output.splitlines():
    vals = line.split()
    # We want to name these columns so we know exactly which is which.
    # pylint: disable=unused-variable
    node_type, state, defined_methods, referenced_methods, size, name = (
        vals[0], vals[1], vals[2], vals[3], vals[4], vals[5:])
    data.append((' '.join(name), int(size)))
  return data
Example #2
0
def _RunApkAnalyzer(apk_path, mapping_path):
    args = [path_util.GetApkAnalyzerPath(), 'dex', 'packages', apk_path]
    if mapping_path and os.path.exists(mapping_path):
        args.extend(['--proguard-mappings', mapping_path])
    env = os.environ.copy()
    env['JAVA_HOME'] = path_util.GetJavaHome()
    output = subprocess.check_output(args, env=env).decode('ascii')
    data = []
    for line in output.splitlines():
        try:
            vals = line.split()
            # We want to name these columns so we know exactly which is which.
            # pylint: disable=unused-variable
            node_type, state, defined_methods, referenced_methods, size, name = (
                vals[0], vals[1], vals[2], vals[3], vals[4], vals[5:])
            data.append((node_type, ' '.join(name), int(size)))
        except Exception:
            logging.error('Problem line was: %s', line)
            raise
    return data