用Python写脚本 在linux可运行 需求:检索指定目录下的所有apk文件,按序打印出结果:apk路径,apk大小单位mb, apk是否配置了ShareUid,persistent
时间: 2024-05-31 14:08:19 浏览: 7
import os
import subprocess
# 指定目录
dir_path = "/path/to/apk/directory"
# 检索apk文件
apk_files = [os.path.join(dir_path, f) for f in os.listdir(dir_path) if f.endswith(".apk")]
# 遍历apk文件
for apk_file in apk_files:
# 获取apk文件大小
size_mb = os.path.getsize(apk_file) / (1024 * 1024)
# 判断apk是否配置了ShareUid和persistent
output = subprocess.check_output(["aapt", "d", "badging", apk_file]).decode("utf-8")
share_uid = "configChanges=''" in output
persistent = "persistableMode='2'" in output
# 打印结果
print("APK路径:", apk_file)
print("APK大小:", size_mb, "MB")
print("是否配置了ShareUid:", share_uid)
print("是否配置了persistent:", persistent)
print("------------------------------")