Skip to content

Commit f037be2

Browse files
committed
新增 apktool 回编译后自动接上签名 apk 的流程
1 parent 23bd342 commit f037be2

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

shell/package-tools/SignatureApk.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ unset scriptDirPath
1616
unset originalDirPath
1717

1818
waitUserInputParameter() {
19-
echo "请输入要进行签名的 apk 文件或所在目录路径:"
20-
read -r sourcePath
21-
sourcePath=$(parseComputerFilePath "${sourcePath}")
19+
local sourcePath=$1
20+
if [[ -f "${sourcePath}" ]]; then
21+
sourcePath=$(parseComputerFilePath "${sourcePath}")
22+
else
23+
echo "请输入要进行签名的 apk 文件或所在目录路径:"
24+
read -r sourcePath
25+
sourcePath=$(parseComputerFilePath "${sourcePath}")
26+
fi
2227
if [[ -z "${sourcePath}" ]]; then
2328
echo "❌ 路径为空,请检查输入是否正确"
2429
exit 1
@@ -264,9 +269,9 @@ signatureApkInParallel() {
264269
main() {
265270
printCurrentSystemType
266271
checkJavaEnvironment
267-
waitUserInputParameter
272+
waitUserInputParameter "$1"
268273
signatureApkInParallel
269274
}
270275

271276
clear
272-
main
277+
main "$@"

shell/reverse-tools/apktool/RecompileApk.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,29 @@ recompileApk() {
7676
echo "✅ 回编译 apk 完成,输出文件:${outputApkFilePath}"
7777
}
7878

79+
signatureApk() {
80+
echo "是否要对回编译输出的 apk 进行签名?(y/n)"
81+
while true; do
82+
read -r signConfirm
83+
if [[ "${signConfirm}" =~ ^[yY]$ ]]; then
84+
selfDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
85+
bash "${selfDir}/../../package-tools/SignatureApk.sh" "${outputApkFilePath}"
86+
break
87+
elif [[ "${signConfirm}" =~ ^[nN]$ ]]; then
88+
break
89+
else
90+
echo "👻 输入不正确,请输入正确的选项(y/n)"
91+
continue
92+
fi
93+
done
94+
}
95+
7996
main() {
8097
printCurrentSystemType
8198
checkJavaEnvironment
8299
waitUserInputParameter
83100
recompileApk
101+
signatureApk
84102
}
85103

86104
clear

0 commit comments

Comments
 (0)