Do not update system UI overlays when the SDK version condition is not met (flutter/engine#29643)

This commit is contained in:
Wyte Krongapiradee
2021-11-12 04:29:31 +08:00
committed by GitHub
parent e79b6bb25d
commit 0a5dbbe522
2 changed files with 24 additions and 5 deletions

View File

@@ -238,11 +238,7 @@ public class PlatformPlugin {
}
private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode systemUiMode) {
int enabledOverlays =
DEFAULT_SYSTEM_UI
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
int enabledOverlays;
if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
@@ -301,6 +297,9 @@ public class PlatformPlugin {
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
} else {
// When none of the conditions are matched, return without updating the system UI overlays.
return;
}
mEnabledOverlays = enabledOverlays;

View File

@@ -367,6 +367,26 @@ public class PlatformPluginTest {
}
}
@Config(sdk = 28)
@Test
public void doNotEnableEdgeToEdgeOnOlderSdk() {
View fakeDecorView = mock(View.class);
Window fakeWindow = mock(Window.class);
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
Activity fakeActivity = mock(Activity.class);
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
platformPlugin.mPlatformMessageHandler.showSystemUiMode(
PlatformChannel.SystemUiMode.EDGE_TO_EDGE);
verify(fakeDecorView, never())
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
@Test
public void popSystemNavigatorFlutterActivity() {
Activity mockActivity = mock(Activity.class);