feat: add optional Windows virtual USB ADB device

This commit is contained in:
tongtong committed 2026-11-12 17:34:23 +08:00
1 parent 2abfb63da9
commit 08d60de364
23 files changed
+802 -26

No files matched your search

+5 -3
View File
@@ -12,9 +12,11 @@ try {
if ($LASTEXITCODE -ne 0) { throw 'Desktop publish failed' }
} finally { Pop-Location }
$suffix = if ($Runtime.StartsWith('win-')) { '.exe' } else { '' }
$client = Join-Path $projectRoot ('bin/ads-client' + $suffix)
if (Test-Path -LiteralPath $client) {
Copy-Item -LiteralPath $client -Destination (Join-Path $outputDirectory ('ads-client' + $suffix)) -Force
foreach ($toolName in @('ads-client', 'ads-usb')) {
$client = Join-Path $projectRoot ('bin/' + $toolName + $suffix)
if (Test-Path -LiteralPath $client) {
Copy-Item -LiteralPath $client -Destination (Join-Path $outputDirectory ($toolName + $suffix)) -Force
}
}
if ($Runtime.StartsWith('win-') -and (Test-Path -LiteralPath (Join-Path $projectRoot 'bin/tools/scrcpy/scrcpy.exe'))) {
$tools = Join-Path $outputDirectory 'tools/scrcpy'
+2 -2
View File
@@ -8,7 +8,7 @@ try {
else { cargo build --workspace --release --locked }
if ($LASTEXITCODE -ne 0) { throw 'Rust build failed' }
New-Item -ItemType Directory -Force -Path (Join-Path $projectRoot 'bin') | Out-Null
foreach ($name in @('ads-agent', 'ads-client')) {
foreach ($name in @('ads-agent', 'ads-client', 'ads-usb')) {
Copy-Item -LiteralPath (Join-Path $projectRoot "target/$configuration/$name.exe") -Destination (Join-Path $projectRoot "bin/$name.exe") -Force
}
Push-Location (Join-Path $projectRoot 'server')
@@ -19,4 +19,4 @@ try {
if ($LASTEXITCODE -ne 0) { throw 'Relay build failed' }
} finally { Pop-Location }
} finally { Pop-Location }
Write-Host "Built control server, relay node, agent and client in $projectRoot/bin"
Write-Host "Built control server, relay node, agent, client and optional USB bridge in $projectRoot/bin"
+1 -1
View File
@@ -4,7 +4,7 @@ project_root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
cargo build --workspace --release --locked
mkdir -p bin
cp target/release/ads-agent target/release/ads-client bin/
cp target/release/ads-agent target/release/ads-client target/release/ads-usb bin/
cd server
go build -trimpath -o ../bin/ads-server .
go build -trimpath -o ../bin/ads-relay ./cmd/ads-relay
+21
View File
@@ -0,0 +1,21 @@
param([switch]$Install)
$ErrorActionPreference = 'Stop'
if (-not $IsWindows) { throw 'Windows only; run using PowerShell 7' }
if ([Runtime.InteropServices.RuntimeInformation]::OSArchitecture -ne 'X64') { throw 'This pinned installer supports Windows x64 only' }
$projectRoot = Split-Path $PSScriptRoot -Parent
$installer = Join-Path $projectRoot 'work/USBip-0.9.8.1-x64.exe'
$expectedHash = '38CAD6D4432B52D5BB9409D9AD03B72FDFFC4ADA4CD3A48FBECA1A2752A8518A'
New-Item -ItemType Directory -Force -Path (Split-Path $installer -Parent) | Out-Null
if (-not (Test-Path -LiteralPath $installer)) {
Invoke-WebRequest 'https://github.com/vadimgrn/usbip-win2/releases/download/v.0.9.8.1/USBip-0.9.8.1-x64.exe' -OutFile $installer
}
if ((Get-FileHash -LiteralPath $installer -Algorithm SHA256).Hash -ne $expectedHash) { throw 'Installer SHA256 mismatch' }
$signature = Get-AuthenticodeSignature -LiteralPath $installer
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Thumbprint -ne '9AC56B6C76141395D74FFF6652818376E80B9C95') { throw 'Unexpected installer signature' }
Write-Output "Verified upstream USBip 0.9.8.1 installer: $installer"
if ($Install) {
# Interactive installation retains user control. Never change test signing or Secure Boot.
$process = Start-Process -FilePath $installer -ArgumentList '/NORESTART' -Verb RunAs -PassThru -Wait
if ($process.ExitCode -notin @(0,3010)) { throw "USBip installer exited with code $($process.ExitCode)" }
if ($process.ExitCode -eq 3010) { Write-Output 'Reboot required; no reboot was started.' }
}