Skip to content

[net11] Re-apply the SystemUI emulation overlay when the status bar is shorter than the display cutout - #40765

Merged
kubaflo merged 1 commit into
net11from
kubaflo-net11-android-statusbar-cutout
Nov 28, 2026
Merged

kubaflo merged 1 commit into
net11from
kubaflo-net11-android-statusbar-cutout

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

UI-test infrastructure fix (eng/devices/android.cake). No product, test, baseline or tolerance changes.

Symptom. Android Material3 (API 36, pixel_3_xl) fails almost every screenshot test intermittently by boot. Build 1703317 (sr3) had 413 failures and 17 passes, and build 1701569 (sr4) failed the same way. Every failure is Unable to extract difference percentage from size differs (baseline 1440x2737, actual 1440x2824).

Cause.

  • Since [Testing] Fix Android screenshot cropping using the reported status bar and navigation bar heights #40603, screenshots are cropped by the status bar height Appium reports (getSystemBars, read from the StatusBar window frame in dumpsys window).
  • In the failing boots that frame is 84px for the whole run, while the display cutout is 171px. The baselines assume 171.
  • The emulator re-applies its resource overlays when the user unlocks, a few seconds after sys.boot_completed. SystemUI sometimes recomputes its status bar height from the framework overlay before its own emulation overlay is re-applied, and keeps the stale 84px.

Fix. Before each UI test attempt (EnsureDeviceForUITestAttempt, which runs after APK install and the test build):

  1. If a com.android.systemui.emulation.* overlay is enabled, compare the StatusBar window height with the dumpsys display cutout top.
  2. If the status bar is shorter, disable and re-enable that overlay. SystemUI then recomputes the height.
  3. Poll for up to 30 s and log the result.

Devices without an emulation overlay, or without a top cutout, are untouched.

Local validation (pixel_3_xl AVD, API 36, shell uid 2000):

  • Reproduction. cmd overlay disable + enable com.android.internal.emulation.pixel_3_xl deterministically leaves the CI state: StatusBar [0,0][1440,84] with DisplayCutout{insets=Rect(0, 171 - 0, 0)}. This held 9/9 across google_apis userdebug and google_apis_playstore user images, and the stale state persisted for over 30 s.
  • The exact new functions, run through dotnet cake with the same Cake.Android.Adb 3.2.0 addin on the CI-equivalent google_apis_playstore user image:
    • Healthy device: logs 171px / 171px and does nothing.
    • Stale device, 3/3: logs 84px / 171px, re-applies com.android.systemui.emulation.pixel_3_xl, and reports Status bar height is 171px after 1 seconds.
  • dotnet cake eng/devices/android.cake compiles.

Per repository policy, there are no tests for pipeline/device scripts. CI on this PR and the next Material3 runs are the end-to-end validation.

Issues Fixed

Fixes the Material3 Android screenshot-size failures seen after #40603 (builds 1703317 and 1701569).

…s shorter than the display cutout

On pixel_3_xl emulators (Material3, SafeAreaEdges), SystemUI sometimes keeps
the status bar height it computed before its emulation overlay was re-applied
at user unlock: the StatusBar window stays 84px while the display cutout is
171px for the whole run. Since #40603, Android screenshots are cropped by the
reported status bar height, so every Material3 screenshot comes out
1440x2824 instead of the 1440x2737 baselines (413 failures in builds 1703317
and 1701569).

Before each UI test attempt, compare the StatusBar window height to the
display cutout top and, if shorter, disable and enable the enabled SystemUI
emulation overlay, which makes SystemUI recompute the height.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

kubaflo commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 28, 2026 16:51 — with GitHub Actions Inactive
@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamping as requested by @kubaflo; no code review performed.

@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo merged commit 7b88bf7 into net11 Nov 28, 2026
45 of 52 checks passed
@kubaflo
kubaflo deleted the kubaflo-net11-android-statusbar-cutout branch November 28, 2026 20:33

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — e178441d Deployed Nov 28, 2026 by kubaflo via conclusion #3442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants