Skip to content

Commit ed93b0f

Browse files
authored
Do not update system UI overlays when the SDK version condition is not met (flutter#29643)
1 parent ce849c1 commit ed93b0f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ public void onSystemUiVisibilityChange(int visibility) {
238238
}
239239

240240
private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode systemUiMode) {
241-
int enabledOverlays =
242-
DEFAULT_SYSTEM_UI
243-
| View.SYSTEM_UI_FLAG_FULLSCREEN
244-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
245-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
241+
int enabledOverlays;
246242

247243
if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK
248244
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
@@ -301,6 +297,9 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys
301297
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
302298
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
303299
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
300+
} else {
301+
// When none of the conditions are matched, return without updating the system UI overlays.
302+
return;
304303
}
305304

306305
mEnabledOverlays = enabledOverlays;

shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,26 @@ public void setSystemUiMode() {
367367
}
368368
}
369369

370+
@Config(sdk = 28)
371+
@Test
372+
public void doNotEnableEdgeToEdgeOnOlderSdk() {
373+
View fakeDecorView = mock(View.class);
374+
Window fakeWindow = mock(Window.class);
375+
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
376+
Activity fakeActivity = mock(Activity.class);
377+
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
378+
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
379+
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
380+
381+
platformPlugin.mPlatformMessageHandler.showSystemUiMode(
382+
PlatformChannel.SystemUiMode.EDGE_TO_EDGE);
383+
verify(fakeDecorView, never())
384+
.setSystemUiVisibility(
385+
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
386+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
387+
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
388+
}
389+
370390
@Test
371391
public void popSystemNavigatorFlutterActivity() {
372392
Activity mockActivity = mock(Activity.class);

0 commit comments

Comments
 (0)