If you have set the ANDROID_HOME environment variable, use the AAPT tool to get apk information and save it to the PackageInfo.txt file in the directory where the script resides:
Import OS import tempfile import re tempfile = Tempfile.gettempdir () def get_aapt (): If "Android_home" in Os.envir On: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_current_packa Ge_name (): pattern = Re.compile (r "[A-za-z0-9\.] +/. [A-za-z0-9\.] + ") os.popen (" adb wait-for-device ") out = Os.popen (" adb Shell Dumpsys Input | Findstr focusedapplication "). Read () Package_name = Pattern.findall (out) [0].split ("/") [0] return package_name def get_ MATCH_APK (package_name): list = [] for packages in Os.popen ("adb shell pm List packages-f" + package_name). ReadLines () : List.append (Packages.split (":") [ -1].split ("=") [0]) Apk_name = List[0].split ("/") [-1] os.popen ("adb pull" + list[0] + "" + tempfile) return tempfile + "\" + apk_name if __name__ = = "__main__": Os.popen (get_aapt () + \ "Dump badging " + \ get_match_apk (Get_current_package_name ()) + \ "> PackageInfo.txt") os.popen ("del" + Tempfile + "\\*.apk")