Files
baji-vc/scripts/install-avatar-windows.ps1

27 lines
1.7 KiB
PowerShell

# Run with an existing authorized Windows USB adb. Does not configure ADB/network or start app.
param(
[string]$Adb = 'adb',
[string]$Serial = '',
[Parameter(Mandatory = $true)][string]$Sha256,
[string]$Url = 'http://192.168.31.124:8080/lan-voice-v060-arm64-debug.apk'
)
$ErrorActionPreference = 'Stop'
if ($Sha256 -notmatch '^[0-9a-fA-F]{64}$') { throw 'Supply the release SHA256 from the handoff.' }
$artifact = Join-Path $PSScriptRoot '..\artifacts\lan-voice-v060-arm64-debug.apk'
New-Item -ItemType Directory -Force (Split-Path $artifact) | Out-Null
if (!(Test-Path $artifact)) { Invoke-WebRequest -Uri $Url -OutFile $artifact -UseBasicParsing }
if ((Get-FileHash -Algorithm SHA256 $artifact).Hash -ne $Sha256) { throw 'APK hash mismatch; existing file preserved.' }
$devices = @(& $Adb devices | Select-String '^([^\s]+)\s+device$' | ForEach-Object { $_.Matches[0].Groups[1].Value })
if ($LASTEXITCODE -ne 0) { throw 'Existing adb unavailable.' }
if (!$Serial) {
if ($devices.Count -ne 1) { throw 'Select an already authorized USB device using -Serial.' }
$Serial = $devices[0]
}
if ($Serial -notin $devices) { throw 'Device is not already authorized.' }
& $Adb -s $Serial install -r $artifact
if ($LASTEXITCODE -ne 0) { throw 'Installation failed; no uninstall or data clearing performed.' }
$version = & $Adb -s $Serial shell dumpsys package com.gorios.lanvoice | Select-String 'versionCode=|versionName='
if ($LASTEXITCODE -ne 0 -or !($version -match 'versionCode=11') -or !($version -match 'versionName=0.6.0')) { throw 'Installed version did not verify.' }
$version
Write-Output 'Installed 0.6.0/code11. Open manually; recording and camera require explicit user actions.'