text stringlengths 1 93.6k |
|---|
if i["id"] == f"config.{device.abi.replace('-', '_')}":
|
config["abi"] = i["file"]
|
for d in device.drawable:
|
if i == f"split_config.{d}.apk":
|
config["drawable"] = i
|
if i["id"] == f"config.{device.locale}":
|
config["language"].insert(0, i["file"])
|
elif (i["id"] in abi) or i["id"].endswith("dpi"):
|
config[i["id"].split(".")[1]] = i["file"]
|
elif i["id"] in language:
|
config["language"].append(i["file"])
|
else:
|
install.append(i["file"])
|
log.info(config)
|
return config, install
|
def check(ADB=None) -> List[str]:
|
if not ADB:
|
ADB = check_sth('adb')
|
run, msg = run_msg([ADB, 'devices'])
|
_devices = msg.strip().split("\n")[1:]
|
if _devices == ['* daemon started successfully']:
|
log.info('初次启动adb服务')
|
run, msg = run_msg([ADB, 'devices'])
|
_devices = msg.strip().split("\n")[1:]
|
devices = []
|
for i in _devices:
|
if i.split("\t")[1] != "offline":
|
devices.append(i.split("\t")[0])
|
# adb -s <device-id/ip:port> shell xxx
|
if run.returncode:
|
log.error(msg)
|
elif len(devices) == 0:
|
log.error("手机未连接电脑!")
|
elif len(devices) == 1:
|
pass
|
elif len(devices) > 1:
|
log.info('检测到1个以上的设备,将进行多设备安装')
|
return devices
|
def check_sth(key, conf='config.yaml'):
|
if key not in ['adb', 'java', 'aapt', 'bundletool']:
|
return None
|
conf = read_yaml(conf)
|
path = conf.get(key, key)
|
if not os.path.exists(path):
|
# 配置文件有误或为空时,使用系统环境中的adb
|
try:
|
if key in ['adb', 'java']:
|
run, msg = run_msg([key, '--version'])
|
elif key in ['aapt']:
|
run, msg = run_msg([key, 'v'])
|
elif key in ['bundletool']:
|
run, msg = run_msg([check_sth('java'), '-jar', key+'.jar', 'version'])
|
except FileNotFoundError:
|
run = None
|
if run and (run.returncode == 0):
|
log.info(f'check_sth({key!r})')
|
log.info(msg.strip())
|
return key
|
log.error(f'未配置{key}')
|
return None
|
return path
|
def check_by_manifest(device: Device, manifest: dict) -> None:
|
if device.sdk < manifest["min_sdk_version"]:
|
sys.exit(info_msg['sdktoolow'])
|
else:
|
try:
|
if device.sdk > manifest["target_sdk_version"]:
|
log.warning("警告:安卓版本过高!可能存在兼容性问题!")
|
except KeyError:
|
log.warning("`manifest['target_sdk_version']` no found.")
|
abilist = device.abilist
|
try:
|
if manifest.get("native_code") and not findabi(manifest["native_code"], abilist):
|
sys.exit(f"安装失败:{manifest['native_code']}\n应用程序二进制接口(abi)不匹配!该手机支持的abi列表为:{abilist}")
|
except UnboundLocalError:
|
log.exception('Failed in check_by_manifest->findabi.')
|
def checkVersion(device: Device, package_name: str, fileVersionCode: int, versionCode: int = -1, abis: list = []) -> None:
|
msg = device.shell(["pm", "dump", package_name])[1]
|
for i in msg.split("\n"):
|
if "versionCode" in i:
|
versionCode = int(i.strip().split("=")[1].split(" ")[0])
|
if versionCode == -1:
|
input("警告:首次安装需要在手机上点击允许安装!按回车继续...")
|
elif fileVersionCode < versionCode:
|
if input("警告:降级安装?请确保文件无误!(y/N)").lower() != "y":
|
sys.exit("降级安装,用户取消安装。")
|
elif fileVersionCode == versionCode:
|
if input("警告:版本一致!请确保文件无误!(y/N)").lower() != "y":
|
sys.exit("版本一致,用户取消安装。")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.