mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 05:30:44 +00:00
AndroidTarget: add get_pacakge_info
Add a method to get info (apk path) for an installed package.
This commit is contained in:
parent
c585a4e489
commit
335fa77e4e
@ -35,6 +35,9 @@ KVERSION_REGEX =re.compile(
|
||||
GOOGLE_DNS_SERVER_ADDRESS = '8.8.8.8'
|
||||
|
||||
|
||||
installed_package_info = namedtuple('installed_package_info', 'apk_path package')
|
||||
|
||||
|
||||
class Target(object):
|
||||
|
||||
path = None
|
||||
@ -1190,6 +1193,15 @@ class AndroidTarget(Target):
|
||||
return line.split('=', 1)[1]
|
||||
return None
|
||||
|
||||
def get_package_info(self, package):
|
||||
output = self.execute('pm list packages -f {}'.format(package))
|
||||
for entry in output.strip().split('\n'):
|
||||
rest, entry_package = entry.rsplit('=', 1)
|
||||
if entry_package != package:
|
||||
continue
|
||||
_, apk_path = rest.split(':')
|
||||
return installed_package_info(apk_path, entry_package)
|
||||
|
||||
def get_sdk_version(self):
|
||||
try:
|
||||
return int(self.getprop('ro.build.version.sdk'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user