Skip to content

[Android] Reset system UI visibility flags when setting edge-to-edge mode#187207

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
camsim99:reset_flags_for_e2e
May 28, 2026
Merged

[Android] Reset system UI visibility flags when setting edge-to-edge mode#187207
auto-submit[bot] merged 5 commits into
flutter:masterfrom
camsim99:reset_flags_for_e2e

Conversation

@camsim99

@camsim99 camsim99 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Resets system UI visibility flags before setting edge-to-edge mode if requested.

System UI visibility flags will be set if the developer requests a non-edge-to-edge SystemUiMode, which can (and does in practice) conflict with laying out a window edge-to-edge. This is why the docs warn against setting system UI visibility flags altogether; see #133074 for details.

Fixes #186723.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@camsim99 camsim99 requested a review from a team as a code owner May 27, 2026 21:33
@camsim99 camsim99 requested review from mboetger and removed request for a team May 27, 2026 21:33
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the enableEdgeToEdge method in PlatformPlugin.java to clear previously applied system UI visibility flags before configuring the window. It also adds a corresponding unit test in PlatformPluginTest.java to verify this behavior. The review feedback suggests adding defensive null checks in enableEdgeToEdge to prevent potential NullPointerExceptions, and optimizing the new test by moving the MockedStatic block outside of the loop to improve performance.

@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels May 27, 2026
@camsim99 camsim99 added CICD Run CI/CD and removed CICD Run CI/CD labels May 27, 2026
@mboetger mboetger added CICD Run CI/CD and removed CICD Run CI/CD labels May 27, 2026
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label May 28, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 28, 2026
Merged via the queue into flutter:master with commit f84bd03 May 28, 2026
30 of 31 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 28, 2026
@dbebawy

dbebawy commented May 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for the quick turnaround, @camsim99 — and sorry the regression slipped through #183072.

For the record / future archaeology: the EDGE_TO_EDGE branch in setSystemChromeEnabledSystemUIMode returns before any flag application (PlatformPlugin.java#L380), and because the prior IMMERSIVE_STICKY call never set isEdgeToEdge=true, the disableEdgeToEdge() guard at the top is a no-op on that transition. Pre-#183072, the explicit setSystemUiVisibility(LAYOUT_*) assignment in the e2e branch was incidentally clearing FULLSCREEN/HIDE_NAVIGATION for us; #183072 removed that without the explicit clear, which is what broke the transition.

Filed #187265 to add integration coverage for the full SystemUiMode transition matrix — Mockito-based unit tests can't observe residual decorView state across mode switches, which is exactly the gap that let this ship.

@camsim99

Copy link
Copy Markdown
Contributor Author

@dbebawy Thank you for the clear explanation and for filing the issue for integration tests! Those would be a major value add.

@camsim99 camsim99 added cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch labels May 28, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 29, 2026
flutter/flutter@e70534d...b05a9d7

2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from 47155534833e to d9d6b440c4e7 (1 revision) (flutter/flutter#187301)
2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from f93ed13d77fb to 47155534833e (4 revisions) (flutter/flutter#187291)
2026-05-29 kevmoo@users.noreply.github.com [web_ui] Optimize skwasm text layout and path decoding to eliminate dynamic boxing churn under Wasm (flutter/flutter#186978)
2026-05-29 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from SBpmmPxqx3lAvGojE... to jMR_VXQi07kAk8vbR... (flutter/flutter#187279)
2026-05-29 burak.karahan@mail.ru Remove Material import from sliver tree rendering test (flutter/flutter#187000)
2026-05-29 bdero@google.com [Impeller] Remove the y_coord_scale Y-flip plumbing (flutter/flutter#187224)
2026-05-29 31859944+LongCatIsLooong@users.noreply.github.com Add/remove overlay child RenderObject from the tree in `attach`/`detach` (flutter/flutter#186564)
2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from fcfe5975c945 to f93ed13d77fb (4 revisions) (flutter/flutter#187273)
2026-05-28 evanwall@buffalo.edu Handle complex RSE rendering in the uber SDF pipeline (flutter/flutter#186434)
2026-05-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 082191101fcc to 683322426411 (2 revisions) (flutter/flutter#187270)
2026-05-28 mvincentong@gmail.com Clarify route transition animations (flutter/flutter#186552)
2026-05-28 116356835+AbdeMohlbi@users.noreply.github.com document that the default Key is null and explain proper usage in list diffing (flutter/flutter#185197)
2026-05-28 srawlins@google.com [flutter_tools] Use super parameters in missed spots (flutter/flutter#186197)
2026-05-28 mr_nadeem_iqbal@yahoo.com docs: Document MediaQueryData.alwaysUse24HourFormat on macOS, Windows, Linux, web (#160664) (flutter/flutter#186642)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from 5493e4c144cd to fcfe5975c945 (3 revisions) (flutter/flutter#187256)
2026-05-28 30870216+gaaclarke@users.noreply.github.com Shares opengles golden context (flutter/flutter#187243)
2026-05-28 jason-simmons@users.noreply.github.com Update the Curl CIPD package in .ci.yaml to version 8.20.0 (flutter/flutter#187133)
2026-05-28 737941+loic-sharma@users.noreply.github.com Improve SizedBox's docs (flutter/flutter#187208)
2026-05-28 bdero@google.com [Impeller] Support instanced rendering across all backends (flutter/flutter#186653)
2026-05-28 43054281+camsim99@users.noreply.github.com [Android] Reset system UI visibility flags when setting edge-to-edge mode (flutter/flutter#187207)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from a38708fb7926 to 5493e4c144cd (7 revisions) (flutter/flutter#187241)
2026-05-28 30870216+gaaclarke@users.noreply.github.com Turned on impeller by default on macos (flutter/flutter#186546)
2026-05-28 mvincentong@gmail.com Clarify lazy scroll extent docs (flutter/flutter#186864)
2026-05-28 mdebbar@google.com [web] Fix WebParagraph locales test (flutter/flutter#186813)
2026-05-28 engine-flutter-autoroll@skia.org Roll Packages from 4b424d7 to 10cbdc5 (3 revisions) (flutter/flutter#187238)
2026-05-28 engine-flutter-autoroll@skia.org Roll Dart SDK from f3db7b7d9801 to 082191101fcc (8 revisions) (flutter/flutter#187235)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from 32acea791248 to a38708fb7926 (1 revision) (flutter/flutter#187221)
2026-05-28 bdero@google.com [Flutter GPU] Add r32Float and remove Apple-only XR pixel formats (flutter/flutter#187069)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
dbebawy added a commit to dbebawy/flutter that referenced this pull request May 29, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
dbebawy added a commit to dbebawy/flutter that referenced this pull request May 30, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
dbebawy added a commit to dbebawy/flutter that referenced this pull request Jun 1, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
dbebawy added a commit to dbebawy/flutter that referenced this pull request Jun 1, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11803)

flutter/flutter@e70534d...b05a9d7

2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from 47155534833e to d9d6b440c4e7 (1 revision) (flutter/flutter#187301)
2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from f93ed13d77fb to 47155534833e (4 revisions) (flutter/flutter#187291)
2026-05-29 kevmoo@users.noreply.github.com [web_ui] Optimize skwasm text layout and path decoding to eliminate dynamic boxing churn under Wasm (flutter/flutter#186978)
2026-05-29 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from SBpmmPxqx3lAvGojE... to jMR_VXQi07kAk8vbR... (flutter/flutter#187279)
2026-05-29 burak.karahan@mail.ru Remove Material import from sliver tree rendering test (flutter/flutter#187000)
2026-05-29 bdero@google.com [Impeller] Remove the y_coord_scale Y-flip plumbing (flutter/flutter#187224)
2026-05-29 31859944+LongCatIsLooong@users.noreply.github.com Add/remove overlay child RenderObject from the tree in `attach`/`detach` (flutter/flutter#186564)
2026-05-29 engine-flutter-autoroll@skia.org Roll Skia from fcfe5975c945 to f93ed13d77fb (4 revisions) (flutter/flutter#187273)
2026-05-28 evanwall@buffalo.edu Handle complex RSE rendering in the uber SDF pipeline (flutter/flutter#186434)
2026-05-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 082191101fcc to 683322426411 (2 revisions) (flutter/flutter#187270)
2026-05-28 mvincentong@gmail.com Clarify route transition animations (flutter/flutter#186552)
2026-05-28 116356835+AbdeMohlbi@users.noreply.github.com document that the default Key is null and explain proper usage in list diffing (flutter/flutter#185197)
2026-05-28 srawlins@google.com [flutter_tools] Use super parameters in missed spots (flutter/flutter#186197)
2026-05-28 mr_nadeem_iqbal@yahoo.com docs: Document MediaQueryData.alwaysUse24HourFormat on macOS, Windows, Linux, web (#160664) (flutter/flutter#186642)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from 5493e4c144cd to fcfe5975c945 (3 revisions) (flutter/flutter#187256)
2026-05-28 30870216+gaaclarke@users.noreply.github.com Shares opengles golden context (flutter/flutter#187243)
2026-05-28 jason-simmons@users.noreply.github.com Update the Curl CIPD package in .ci.yaml to version 8.20.0 (flutter/flutter#187133)
2026-05-28 737941+loic-sharma@users.noreply.github.com Improve SizedBox's docs (flutter/flutter#187208)
2026-05-28 bdero@google.com [Impeller] Support instanced rendering across all backends (flutter/flutter#186653)
2026-05-28 43054281+camsim99@users.noreply.github.com [Android] Reset system UI visibility flags when setting edge-to-edge mode (flutter/flutter#187207)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from a38708fb7926 to 5493e4c144cd (7 revisions) (flutter/flutter#187241)
2026-05-28 30870216+gaaclarke@users.noreply.github.com Turned on impeller by default on macos (flutter/flutter#186546)
2026-05-28 mvincentong@gmail.com Clarify lazy scroll extent docs (flutter/flutter#186864)
2026-05-28 mdebbar@google.com [web] Fix WebParagraph locales test (flutter/flutter#186813)
2026-05-28 engine-flutter-autoroll@skia.org Roll Packages from 4b424d7 to 10cbdc5 (3 revisions) (flutter/flutter#187238)
2026-05-28 engine-flutter-autoroll@skia.org Roll Dart SDK from f3db7b7d9801 to 082191101fcc (8 revisions) (flutter/flutter#187235)
2026-05-28 engine-flutter-autoroll@skia.org Roll Skia from 32acea791248 to a38708fb7926 (1 revision) (flutter/flutter#187221)
2026-05-28 bdero@google.com [Flutter GPU] Add r32Float and remove Apple-only XR pixel formats (flutter/flutter#187069)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
dbebawy added a commit to dbebawy/flutter that referenced this pull request Jun 23, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
dbebawy added a commit to dbebawy/flutter that referenced this pull request Jun 24, 2026
Adds a Flutter Driver test under android_engine_test that drives
`SystemChrome.setEnabledSystemUIMode` through transition pairs and
asserts the resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on `native_driver`.

The regression-named test reproduces the
`immersiveSticky -> edgeToEdge` cell from flutter#186723 / fixed in flutter#187207:
without the fix, FLAG_FULLSCREEN and FLAG_HIDE_NAVIGATION from the
prior immersiveSticky call persist on the decor view, leaving the
system bars hidden under edgeToEdge.

Tests skip on API < 29 since edgeToEdge requires API 29+.

Closes flutter#187265
gmackall pushed a commit to gmackall/flutter that referenced this pull request Jun 24, 2026
…187269)

## Summary

Adds a Flutter Driver integration test under
`dev/integration_tests/android_engine_test/` covering `SystemUiMode`
transitions on Android. The test exposes a `requestData` handler that
applies modes via `SystemChrome.setEnabledSystemUIMode` and reads the
resulting decor-view `systemUiVisibility` flags via a new
`get_system_ui_visibility` method on the existing `native_driver` method
channel.

Closes flutter#187265.

## Why

flutter#186723 was a P1 regression introduced by flutter#183072 and fixed by flutter#187207.
The Mockito-based `PlatformPluginTest` unit tests verify which APIs are
called on a mocked `Window`/`View` but cannot observe residual
`decorView` state that bleeds across mode switches — which is the exact
bug class the regression was. A device-level integration test closes
that gap.

## What the tests cover

| Transition | Assertion |
|------------|-----------|
| `immersiveSticky → edgeToEdge` (regression case for flutter#186723) |
`FLAG_FULLSCREEN` and `FLAG_HIDE_NAVIGATION` are cleared |
| `immersive → edgeToEdge` | Same |
| `leanBack → edgeToEdge` | Same |
| `edgeToEdge → immersive` | `IMMERSIVE \| FULLSCREEN \|
HIDE_NAVIGATION` set |
| `edgeToEdge → immersiveSticky` | `IMMERSIVE_STICKY \| FULLSCREEN \|
HIDE_NAVIGATION` set |
| `edgeToEdge → leanBack` | `FULLSCREEN \| HIDE_NAVIGATION` set, no
immersive flags |

All tests skip on API < 29 since `edgeToEdge` requires Android 10+.

## Files

- New: `lib/system_ui_mode_transitions_main.dart` — Flutter Driver
entrypoint with mode-applying handler.
- New: `test_driver/system_ui_mode_transitions_main_test.dart` —
assertion suite.
- Modified: `NativeDriverSupportPlugin.kt` — adds
`get_system_ui_visibility` method that returns the decor view's
`systemUiVisibility` int. Reading the deprecated field is the most
direct signal of the regression class (flutter#186723 was specifically about
flag bleed-through on this field).
- Modified: `README.md` — adds the new entrypoint to the test list.

CI auto-discovery is via
`Glob('dev/integration_tests/android_engine_test/lib/**_main.dart')` in
`dev/bots/suite_runners/run_android_engine_tests.dart` — no separate
registration needed.

## Pre-launch Checklist

- [x] I read the [Contributor
Guide](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview).
- [x] I read the [Tree
Hygiene](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md)
wiki page.
- [x] I read and followed the [Flutter Style
Guide](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md).
- [x] I signed the [CLA](https://cla.developers.google.com/).
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making.
- [x] All existing and new tests are passing.

## Notes for reviewers

- Marked as draft because I do not have a local Android emulator set up
— `flutter analyze` is clean but I have not run the test end-to-end. CI
is the source of truth.
- The reason for reading the deprecated `systemUiVisibility` field on
the native side (rather than `WindowInsetsCompat.isVisible(...)`) is
that the regression was specifically about bit flags persisting on the
decor view; the deprecated read gives a deterministic,
version-independent signal. The production code still migrates to
non-deprecated APIs for *setting* state per flutter#183072.
- `SystemUiMode.manual` is out of scope here (different API surface —
takes a `List<SystemUiOverlay>`) and can follow up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression] [Android] Failed to swtich SystemUIMode from immersiveSticky to edgeToEdge in Flutter 3.44.0

3 participants