Files
2026-04-05 01:00:07 -05:00

73 lines
3.0 KiB
Bash
Raw Permalink 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
# 在 Ubuntu 上于工程根目录执行:提取设备上已装原版 APK、编译 gps-only 双包、可选安装到 USB 机
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
OUT="${GPS_ARTIFACT_DIR:-$HOME/gps_build_artifacts}"
export ANDROID_HOME="${ANDROID_HOME:-$HOME/android-sdk}"
if [[ -d /usr/lib/jvm/java-17-openjdk-amd64 ]]; then
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
fi
mkdir -p "$OUT"
cd "$ROOT_DIR"
chmod +x ./gradlew 2>/dev/null || true
chmod +x ./scripts/*.sh 2>/dev/null || true
./gradlew :app:assembleDebug :fl_xposed:assembleDebug --no-daemon
cp -f app/build/outputs/apk/debug/app-debug.apk "$OUT/fakelocation-gps-debug.apk"
cp -f fl_xposed/build/outputs/apk/debug/fl_xposed-debug.apk "$OUT/FL-Xposed-gps-debug.apk"
pick_serial() {
adb devices | awk 'NR>1 && $2=="device" && $1 !~ /^emulator/ && $1 !~ /^127/ && $1 !~ /^localhost/ {print $1; exit}'
}
SERIAL="$(pick_serial)"
if [[ -n "${SERIAL}" ]]; then
# 与商店版/其他签名冲突时必须先卸再装
adb -s "$SERIAL" uninstall com.lerist.fakelocation 2>/dev/null || true
adb -s "$SERIAL" uninstall com.lerist.fakelocation.common.xposed 2>/dev/null || true
adb -s "$SERIAL" install -r "$OUT/fakelocation-gps-debug.apk"
adb -s "$SERIAL" install -r "$OUT/FL-Xposed-gps-debug.apk"
for PKG in com.lerist.fakelocation com.lerist.fakelocation.rebuilt com.lerist.fakelocation.rebuilt.debug; do
LINE="$(adb -s "$SERIAL" shell pm path "$PKG" 2>/dev/null | head -1 | tr -d '\r' || true)"
if [[ -n "$LINE" && "$LINE" == package:* ]]; then
APK="${LINE#package:}"
SAFE="${PKG//./_}"
adb -s "$SERIAL" pull "$APK" "$OUT/original_${SAFE}_base.apk" || true
unzip -l "$OUT/original_${SAFE}_base.apk" 2>/dev/null | head -50 > "$OUT/original_${SAFE}_listing.txt" || true
fi
done
bash "$ROOT_DIR/scripts/adb_device_autosetup.sh" "$SERIAL"
else
echo "No USB/device serial found; skipped adb install/pull."
fi
# 可选GPS_JADX_REFERENCE=1 仅反编译拉取的原版包(与 CODEX_PIPELINE 并存时由后者覆盖完整 jadx 目录)
if [[ "${GPS_JADX_REFERENCE:-0}" == "1" && "${CODEX_PIPELINE:-0}" != "1" ]]; then
if command -v jadx >/dev/null 2>&1; then
for f in "$OUT"/original_com_lerist_fakelocation_base.apk; do
[[ -f "$f" ]] || continue
JOUT="$OUT/jadx_original_fakelocation"
rm -rf "$JOUT"
echo "Running jadx -> $JOUT"
jadx -d "$JOUT" --show-bad-code --quiet "$f" || true
done
else
echo "GPS_JADX_REFERENCE=1 but jadx not found (e.g. sudo apt install jadx)"
fi
fi
# Codex 式:双 APK jadx + 连接真机时运行时截图/dumpsys/内存摘要/logcat/Magisk&LSPosed 路径/私有数据枚举
if [[ "${CODEX_PIPELINE:-0}" == "1" ]]; then
bash "$ROOT_DIR/scripts/jadx_decompile_bundle.sh" "$OUT"
if [[ -n "${SERIAL}" ]]; then
bash "$ROOT_DIR/scripts/adb_runtime_forensics.sh" "$SERIAL" "$OUT"
else
echo "CODEX_PIPELINE: no adb serial, skipped runtime forensics"
fi
fi
ls -la "$OUT"
echo "Done. APKs in $OUT"