Add Android APK inspection and device verification gates
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][ValidatePattern('^[a-z0-9-]+$')][string]$Step,
|
||||
[string[]]$AdbArguments = @(), [string]$Serial = 'emulator-5554',
|
||||
[string]$EvidenceDir = 'artifacts/verification/FirstSlice', [int]$DelayMilliseconds = 800,
|
||||
[switch]$Audio
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$sdk = if ($env:ANDROID_SDK_ROOT) { $env:ANDROID_SDK_ROOT } else { Join-Path $env:LOCALAPPDATA 'Android/Sdk' }
|
||||
$adb = Join-Path $sdk 'platform-tools/adb.exe'
|
||||
New-Item -ItemType Directory -Path $EvidenceDir -Force | Out-Null
|
||||
$commands = [Collections.Generic.List[object]]::new()
|
||||
function Invoke-Adb([string[]]$Arguments) {
|
||||
$output = & $adb -s $Serial @Arguments 2>&1
|
||||
$code = $LASTEXITCODE
|
||||
$commands.Add([ordered]@{ command=('"' + $adb + '" -s ' + $Serial + ' ' + ($Arguments -join ' ')); exitCode=$code; output=($output -join "`n") })
|
||||
if ($code -ne 0) { throw "ADB 실패: $($Arguments -join ' '), 종료 코드 $code" }
|
||||
return $output
|
||||
}
|
||||
try {
|
||||
if ($AdbArguments.Count) { Invoke-Adb $AdbArguments | Out-Null }
|
||||
if ($Audio) { Invoke-Adb @('shell','dumpsys','media.audio_flinger') | Set-Content -LiteralPath (Join-Path $EvidenceDir "$Step-audio-flinger.txt") -Encoding utf8 }
|
||||
Start-Sleep -Milliseconds $DelayMilliseconds
|
||||
Invoke-Adb @('shell','screencap','-p',"/sdcard/magnetismheroes-$Step.png") | Out-Null
|
||||
Invoke-Adb @('pull',"/sdcard/magnetismheroes-$Step.png",(Join-Path $EvidenceDir "$Step.png")) | Out-Null
|
||||
Invoke-Adb @('shell','rm',"/sdcard/magnetismheroes-$Step.png") | Out-Null
|
||||
} finally {
|
||||
[ordered]@{ step=$Step; observedUtc=[DateTime]::UtcNow.ToString('o'); serial=$Serial; sourceCommit=(& git rev-parse HEAD);
|
||||
commands=$commands.ToArray() } | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $EvidenceDir "$Step-commands.json") -Encoding utf8
|
||||
}
|
||||
Reference in New Issue
Block a user