Force Android landscape parity captures
This commit is contained in:
parent
e61c2a58a7
commit
987e90cd90
3 changed files with 26 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue