63 lines
2.5 KiB
Bash
63 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
||
# 安装后尽量全自动:权限、模拟位置 appops/settings、冷启动(不依赖人手点设置)
|
||
# 用法: adb_device_autosetup.sh <adb_serial>
|
||
set +e
|
||
S="${1:?serial required}"
|
||
MAIN=com.lerist.fakelocation
|
||
XP=com.lerist.fakelocation.common.xposed
|
||
|
||
A() { adb -s "$S" "$@" 2>/dev/null; }
|
||
|
||
grant_main() {
|
||
A shell pm grant "$MAIN" android.permission.ACCESS_FINE_LOCATION
|
||
A shell pm grant "$MAIN" android.permission.ACCESS_COARSE_LOCATION
|
||
A shell pm grant "$MAIN" android.permission.READ_PHONE_STATE
|
||
A shell pm grant "$MAIN" android.permission.POST_NOTIFICATIONS
|
||
A shell pm grant "$MAIN" android.permission.NEARBY_WIFI_DEVICES
|
||
A shell pm grant "$MAIN" android.permission.ACCESS_WIFI_STATE
|
||
A shell pm grant "$MAIN" android.permission.CHANGE_WIFI_STATE
|
||
}
|
||
|
||
mock_location_ops() {
|
||
A shell appops set "$MAIN" android:mock_location allow
|
||
A shell cmd appops set "$MAIN" android:mock_location allow
|
||
# 部分 ROM
|
||
A shell appops set "$MAIN" mock_location allow
|
||
A shell settings put secure mock_location_app "$MAIN"
|
||
A shell settings put secure mock_location 1
|
||
}
|
||
|
||
# 若 adb shell 能 su(Magisk「超级用户」里给 shell/root 或 adb root)
|
||
mock_location_su() {
|
||
A shell su -c "settings put secure mock_location_app $MAIN"
|
||
A shell su -c "appops set $MAIN android:mock_location allow"
|
||
A shell su -c "cmd appops set $MAIN android:mock_location allow"
|
||
A shell su 0 settings put secure mock_location_app "$MAIN"
|
||
A shell su 0 appops set "$MAIN" android:mock_location allow
|
||
}
|
||
|
||
echo "== adb_device_autosetup: grants + mock_location ($S) =="
|
||
echo "-- pm path --"
|
||
A shell pm path "$MAIN"
|
||
A shell pm path "$XP"
|
||
|
||
grant_main
|
||
mock_location_ops
|
||
mock_location_su
|
||
|
||
A shell am force-stop "$XP"
|
||
A shell am force-stop "$MAIN"
|
||
|
||
echo "== cold start + logcat tail (FakeLocation / FLXposed) =="
|
||
A logcat -c
|
||
A shell am start -W -n "$MAIN/.MainActivity"
|
||
sleep 2
|
||
A logcat -d -t 250 | grep -iE 'fakelocation|FLXposed|lerist|MockState|AndroidRuntime' | tail -80 || true
|
||
|
||
echo "== adb shell su(Magisk 里可单独给「ADB」或 shell root,与应用内 root 无关)=="
|
||
adb -s "$S" shell su -c id || adb -s "$S" shell su 0 id || echo "(本机 adb shell 未 root — 已尽量写 appops;应用内弹 Magisk 仍正常)"
|
||
echo "== Xposed / LSPosed 管理器包名(模块需在管理器里启用一次;无公开稳定 adb API)=="
|
||
adb -s "$S" shell pm list packages 2>/dev/null | grep -iE 'org\.lsposed|lsposed\.manager|edxposed|xposed\.installer|de\.robv\.android\.xposed' || echo "(未列出常见管理器)"
|
||
|
||
exit 0
|