# 启动 PC 调试转发服务
$ErrorActionPreference = "Stop"
$ProjectRoot = Split-Path -Parent $PSScriptRoot
$Server = Join-Path $ProjectRoot "debug-server\server.py"

$sdk = "C:\Users\Administrator\AppData\Local\Android\Sdk"
$adb = Join-Path $sdk "platform-tools\adb.exe"
if (Test-Path $adb) {
    Write-Host "Setting adb reverse tcp:8765 ..."
    & $adb reverse tcp:8765 tcp:8765 2>$null
}

Write-Host "Starting debug server on http://127.0.0.1:8765"
if (Get-Command py -ErrorAction SilentlyContinue) {
    py -3 $Server
} else {
    python $Server
}
