Files
workphone-sdk/sdk/scripts/install_wechat_8.0.51.sh
Manus AI 42fe10401a 1
1
2026-05-24 17:50:04 +08:00

95 lines
2.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 下载并安装微信 8.0.51 到当前 ADB 设备
# 用法: bash install_wechat_8.0.51.sh [APK路径] [设备序列号]
# 若未指定 APK会尝试从 Uptodown 下载;若失败则提示手动下载后重试。
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SDK_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
APKS_DIR="${SDK_DIR}/apks"
APK_NAME="wechat-8.0.51.apk"
DEFAULT_APK="${APKS_DIR}/${APK_NAME}"
# 可选: 传入 APK 路径 或 设备序列号
CUSTOM_APK="${1:-}"
DEVICE_SERIAL="${2:-}"
# 确定要安装的 APK
if [[ -n "$CUSTOM_APK" && -f "$CUSTOM_APK" ]]; then
INSTALL_APK="$CUSTOM_APK"
elif [[ -f "$DEFAULT_APK" ]]; then
INSTALL_APK="$DEFAULT_APK"
else
# 尝试从用户 Downloads 中找最近下载的微信/WeChat 相关 APK
DOWNLOADS_APK=""
if [[ -d "${HOME}/Downloads" ]]; then
for f in "${HOME}/Downloads/"*[Ww]echat*.apk "${HOME}/Downloads/"*8.0.51*.apk "${HOME}/Downloads/"*[Ww]eixin*.apk; do
[[ -f "$f" ]] && DOWNLOADS_APK="$f" && break
done
if [[ -z "$DOWNLOADS_APK" ]]; then
DOWNLOADS_APK=$(ls -t "${HOME}/Downloads/"*.apk 2>/dev/null | head -1)
fi
fi
if [[ -n "$DOWNLOADS_APK" && -f "$DOWNLOADS_APK" ]]; then
INSTALL_APK="$DOWNLOADS_APK"
echo "使用 Downloads 中的 APK: $INSTALL_APK"
else
INSTALL_APK=""
fi
fi
# 若本地没有 APK提示手动下载APKMirror/Uptodown 需浏览器验证,无法命令行直下)
download_apk() {
mkdir -p "$APKS_DIR"
return 1
}
# 主流程
echo "=== 微信 8.0.51 安装脚本 ==="
echo "APK 目录: $APKS_DIR"
echo ""
if [[ -z "$INSTALL_APK" ]]; then
if ! download_apk; then
echo "未找到本地 APK。请先下载微信 8.0.51 后重试:"
echo ""
echo " 1) 在浏览器中打开以下任一链接:"
echo " • https://wechat.en.uptodown.com/android/versions (选择 8.0.51"
echo " • https://www.apkmirror.com/apk/wechat-tencent/wechat/wechat-8-0-51-release/wechat-8-0-51-android-apk-download/"
echo " 2) 将下载的 APK 保存为: $DEFAULT_APK"
echo " 3) 重新运行: $0"
echo ""
echo "或指定已下载的 APK 路径: $0 /path/to/wechat-8.0.51.apk"
exit 1
fi
INSTALL_APK="$DEFAULT_APK"
fi
# 检查设备
ADB_DEVICES=$(adb devices -l 2>/dev/null | grep -w "device" | awk '{print $1}')
if [[ -z "$ADB_DEVICES" ]]; then
echo "未检测到 ADB 设备,请连接设备并开启 USB 调试。"
exit 1
fi
if [[ -n "$DEVICE_SERIAL" ]]; then
SERIAL="$DEVICE_SERIAL"
else
# 多设备时取第一个
SERIAL=$(echo "$ADB_DEVICES" | head -1)
fi
echo "使用设备: $SERIAL"
echo "安装包: $INSTALL_APK"
echo ""
# 覆盖安装(-r若失败可先手动卸载: adb uninstall com.tencent.mm
echo "正在安装..."
if adb -s "$SERIAL" install -r -t "$INSTALL_APK"; then
echo ""
echo "安装完成。设备上的微信已为 8.0.51 版本。"
else
echo "安装失败。若为签名冲突,请先卸载设备上的微信后再运行本脚本。"
exit 1
fi