From 987e90cd90540e7790acd50fc8fb2fe92761bc47 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 5 Jun 2026 19:27:32 +0100 Subject: [PATCH] Force Android landscape parity captures --- scripts/capture-android-screenshot.ps1 | 21 +++++++++++++++++++++ scripts/run-parity-smoke.ps1 | 3 ++- tools/parity/parity-manifest.json | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/capture-android-screenshot.ps1 b/scripts/capture-android-screenshot.ps1 index 3a072f1..4f8e4f8 100644 --- a/scripts/capture-android-screenshot.ps1 +++ b/scripts/capture-android-screenshot.ps1 @@ -6,6 +6,8 @@ param( [int] $LaunchDelaySeconds = 3, [int] $Width = 0, [int] $Height = 0, + [ValidateSet("portrait", "landscape", "natural")] + [string] $Orientation = "natural", [switch] $ForceInstall ) @@ -26,7 +28,18 @@ if (-not (Test-Path $absoluteApk)) { } $overrideSize = $Width -gt 0 -and $Height -gt 0 +$overrideRotation = $Orientation -ne "natural" +$previousAccelerometerRotation = $null +$previousUserRotation = $null try { + if ($overrideRotation) { + $previousAccelerometerRotation = (adb shell settings get system accelerometer_rotation).Trim() + $previousUserRotation = (adb shell settings get system user_rotation).Trim() + $rotation = if ($Orientation -eq "landscape") { "1" } else { "0" } + adb shell settings put system accelerometer_rotation 0 | Out-Host + adb shell settings put system user_rotation $rotation | Out-Host + } + if ($overrideSize) { adb shell am force-stop $PackageName | Out-Host adb shell wm size "${Width}x${Height}" | Out-Host @@ -58,6 +71,14 @@ try { if ($overrideSize) { adb shell wm size reset | Out-Host } + if ($overrideRotation) { + if ($previousAccelerometerRotation -and $previousAccelerometerRotation -ne "null") { + adb shell settings put system accelerometer_rotation $previousAccelerometerRotation | Out-Host + } + if ($previousUserRotation -and $previousUserRotation -ne "null") { + adb shell settings put system user_rotation $previousUserRotation | Out-Host + } + } } if (-not (Test-Path $absoluteOutput) -or (Get-Item $absoluteOutput).Length -le 0) { diff --git a/scripts/run-parity-smoke.ps1 b/scripts/run-parity-smoke.ps1 index 1ee00ad..52a989e 100644 --- a/scripts/run-parity-smoke.ps1 +++ b/scripts/run-parity-smoke.ps1 @@ -82,7 +82,8 @@ try { powershell -ExecutionPolicy Bypass -File .\scripts\capture-android-screenshot.ps1 ` -OutputPath (Join-Path $runRoot "android-periwinkle-$($case.id).png") ` -Width $case.width ` - -Height $case.height + -Height $case.height ` + -Orientation $case.orientation } } diff --git a/tools/parity/parity-manifest.json b/tools/parity/parity-manifest.json index d55f890..9c11743 100644 --- a/tools/parity/parity-manifest.json +++ b/tools/parity/parity-manifest.json @@ -5,18 +5,21 @@ "id": "phone", "width": 390, "height": 844, + "orientation": "portrait", "deviceScale": 1 }, { "id": "tablet", "width": 768, "height": 1024, + "orientation": "portrait", "deviceScale": 1 }, { "id": "desktop", "width": 1280, "height": 720, + "orientation": "landscape", "deviceScale": 1 } ],