• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Module containing utilities for apk packages."""
6
7import re
8
9from pylib import cmd_helper
10
11
12def GetPackageName(apk_path):
13  """Returns the package name of the apk."""
14  aapt_output = cmd_helper.GetCmdOutput(
15      ['aapt', 'dump', 'badging', apk_path]).split('\n')
16  package_name_re = re.compile(r'package: .*name=\'(\S*)\'')
17  for line in aapt_output:
18    m = package_name_re.match(line)
19    if m:
20      return m.group(1)
21  raise Exception('Failed to determine package name of %s' % apk_path)
22