===== GPS 诊断脚本(Xshell 直接粘贴)=====
用法:连接一台设备后执行;正常机、故障机各跑一遍,对比生成的 txt
SERIAL=(adbget−serialno2>/dev/null)TIME=(adb get-serialno 2>/dev/null) TIME=(adbget−serialno2>/dev/null)TIME=(date +%Y%m%d_%H%M%S)
OUT=“/tmp/gps_diag_KaTeX parse error: Expected group after '_' at position 9: {SERIAL}_̲{TIME}.txt”
LOG=“/tmp/gps_log_KaTeX parse error: Expected group after '_' at position 9: {SERIAL}_̲{TIME}.txt”
adb logcat -c
echo “"
echo “请现在在设备上:FactoryTest -> GPS”
echo “保持 YGPS 界面,等待 60 秒…”
echo "”
sleep 60
{
echo “========== GPS DIAG REPORT"
echo “Time : $(date ‘+%Y-%m-%d %H:%M:%S’)”
echo “Serial : ${SERIAL}”
echo "===========================”
echo
echo “=== location_mode ===”
adb shell settings get secure location_mode
echo
echo “=== YGPS permission ===”
adb shell dumpsys package com.mediatek.ygps | grep -E “ACCESS_FINE_LOCATION|ACCESS_COARSE_LOCATION|granted=”
echo
echo “=== mnld process ===”
adb shell “ps -A | grep -i mnl”
echo
echo “=== dev node ===”
adb shell “ls -l /dev/gps /dev/gps_emi /dev/stpgps 2>&1”
echo
echo “=== key log count ===”
echo -n "GnssStatus onStarted : "
adb logcat -d | grep -c “GnssStatus onStarted”
echo -n "GSV : "
adb logcat -d | grep -c “GSV”
echo -n "GGA : "
adb logcat -d | grep -c “GGA”
echo -n "setSatelliteStatus : "
adb logcat -d | grep -c “setSatelliteStatus”
echo -n "onFirstFix : "
adb logcat -d | grep -c “onFirstFix”
echo -n "mnl version : "
adb logcat -d | grep -c “mnl version”
echo -n "clearSateInfo : "
adb logcat -d | grep -c “clearSateInfo”
echo -n "SecurityException : "
adb logcat -d | grep -c “SecurityException”
echo
echo “=== sample GSV (first 5) ===”
adb logcat -d | grep -i GSV | head -5
echo
echo “=== sample mnl version ===”
adb logcat -d | grep -i “mnl version” | head -3
echo
echo “=== sample setSatelliteStatus ===”
adb logcat -d | grep -i “setSatelliteStatus” | head -3
echo
echo “=== quick judge ===”
GSV=(adblogcat−d∣grep−c"GSV")MNL=(adb logcat -d | grep -c "GSV") MNL=(adblogcat−d∣grep−c"GSV")MNL=(adb shell “ps -A | grep -i mnl” | wc -l)
START=$(adb logcat -d | grep -c “GnssStatus onStarted”)
if [ “MNL"−eq0];thenecho"[结论倾向]MNLD未运行−>驱动/软件"elif["MNL" -eq 0 ]; then echo "[结论倾向] MNLD 未运行 -> 驱动/软件" elif [ "MNL"−eq0];thenecho"[结论倾向]MNLD未运行−>驱动/软件"elif["START” -gt 0 ] && [ “GSV"−eq0];thenecho"[结论倾向]GPS已启动但无GSV−>硬件RF/天线/校准或MNLD无NMEA"elif["GSV" -eq 0 ]; then echo "[结论倾向] GPS 已启动但无 GSV -> 硬件RF/天线/校准 或 MNLD 无 NMEA" elif [ "GSV"−eq0];thenecho"[结论倾向]GPS已启动但无GSV−>硬件RF/天线/校准或MNLD无NMEA"elif["GSV” -gt 0 ]; then
echo “[结论倾向] 有 GSV -> GPS 有搜星数据,若 UI 仍空查 YGPS/FactoryTest”
else
echo “[结论倾向] GPS 未正常启动 -> 查权限/定位开关”
fi
echo
echo “Report file: ${OUT}”
echo “Full log :KaTeX parse error: Expected 'EOF', got '}' at position 53: …=============" }̲ | tee "{OUT}”
adb logcat -d | grep -iE “YGPS|NmeaParser|mnl|mnld|gps|gnss|GSV|GGA|RMC|onFirstFix|setSatelliteStatus|onStarted|clearSate|SecurityException|Factory_GPSTest|GpsTestResult” > “${LOG}”
echo “Done.”
echo “Summary: ${OUT}”
echo “Detail : ${LOG}”