forked from gb112211/AndroidTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_current_pkginfo.py
More file actions
40 lines (30 loc) · 1.09 KB
/
get_current_pkginfo.py
File metadata and controls
40 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
'''
Created on 2015年1月26日
@author: xuxu
'''
import os
import tempfile
import re
from scriptUtils import utils
#获取设备上当前应用的包信息,结果存放于当前目录下的PackageInfo.txt中
tempFile = tempfile.gettempdir()
def get_aapt():
if "ANDROID_HOME" in os.environ:
rootDir = os.path.join(os.environ["ANDROID_HOME"], "build-tools")
for path, subdir, files in os.walk(rootDir):
if "aapt.exe" in files:
return os.path.join(path, "aapt.exe")
else:
return "ANDROID_HOME not exist"
def get_match_apk(package_name):
list = []
for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
list.append(packages.split(":")[-1].split("=")[0])
apk_name = list[0].split("/")[-1]
utils.adb("pull %s %s" %(list[0], tempFile)).wait()
return "%s\\%s" %(tempFile, apk_name)
if __name__ == "__main__":
os.popen("%s dump badging %s > PackageInfo.txt" %(get_aapt(), utils.get_current_package_name()))
os.popen("del %s\\*.apk" %tempFile)
print "Completed"