Skip to content

Commit 023f1e9

Browse files
committed
modfied get_current_pkginfo.py
1 parent c744507 commit 023f1e9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

python/get_current_pkginfo.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/env python
12
# -*- coding: utf-8 -*-
23

34
'''
@@ -14,6 +15,7 @@
1415

1516
#获取设备上当前应用的包信息,结果存放于当前目录下的PackageInfo.txt中
1617

18+
PATH = lambda p: os.path.abspath(p)
1719
tempFile = tempfile.gettempdir()
1820

1921
def get_aapt():
@@ -22,6 +24,8 @@ def get_aapt():
2224
for path, subdir, files in os.walk(rootDir):
2325
if "aapt.exe" in files:
2426
return os.path.join(path, "aapt.exe")
27+
elif "aapt" in files:
28+
return os.path.join(path, "aapt")
2529
else:
2630
return "ANDROID_HOME not exist"
2731

@@ -30,11 +34,13 @@ def get_match_apk(package_name):
3034
for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
3135
list.append(packages.split(":")[-1].split("=")[0])
3236
apk_name = list[0].split("/")[-1]
37+
3338
utils.adb("pull %s %s" %(list[0], tempFile)).wait()
3439

35-
return "%s\\%s" %(tempFile, apk_name)
40+
return PATH("%s/%s" %(tempFile, apk_name))
3641

3742
if __name__ == "__main__":
38-
os.popen("%s dump badging %s > PackageInfo.txt" %(get_aapt(), utils.get_current_package_name()))
39-
os.popen("del %s\\*.apk" %tempFile)
40-
print "Completed"
43+
package_name = utils.get_current_package_name()
44+
os.popen("%s dump badging %s > PackageInfo.txt" %(get_aapt(), get_match_apk(package_name)))
45+
# os.popen("del %s\\*.apk" %tempFile)
46+
print "Completed"

0 commit comments

Comments
 (0)