diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index 1202ddd4c45..8ace803e5db 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -1127,6 +1127,13 @@ public class FlutterActivity extends Activity return false; } + @Override + public void updateSystemUiOverlays() { + if (delegate != null) { + delegate.updateSystemUiOverlays(); + } + } + private boolean stillAttachedForEvent(String event) { if (delegate == null) { Log.w(TAG, "FlutterActivity " + hashCode() + " " + event + " called after release."); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index f7689f226be..e1a1e33a3dc 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -507,19 +507,25 @@ import java.util.Arrays; Log.v(TAG, "onPostResume()"); ensureAlive(); if (flutterEngine != null) { - if (platformPlugin != null) { - // TODO(mattcarroll): find a better way to handle the update of UI overlays than calling - // through - // to platformPlugin. We're implicitly entangling the Window, Activity, - // Fragment, - // and engine all with this one call. - platformPlugin.updateSystemUiOverlays(); - } + updateSystemUiOverlays(); } else { Log.w(TAG, "onPostResume() invoked before FlutterFragment was attached to an Activity."); } } + /** + * Refreshes Android's window system UI (AKA system chrome) to match Flutter's desired system + * chrome style. + */ + void updateSystemUiOverlays() { + if (platformPlugin != null) { + // TODO(mattcarroll): find a better way to handle the update of UI overlays than calling + // through to platformPlugin. We're implicitly entangling the Window, Activity, + // Fragment, and engine all with this one call. + platformPlugin.updateSystemUiOverlays(); + } + } + /** * Invoke this from {@code Activity#onPause()} or {@code Fragment#onPause()}. * @@ -1009,5 +1015,17 @@ import java.util.Arrays; *

This defaults to true, unless a cached engine is used. */ boolean shouldRestoreAndSaveState(); + + /** + * Refreshes Android's window system UI (AKA system chrome) to match Flutter's desired system + * chrome style. + * + *

This is useful when using the splash screen API available in Android 12. {@code + * SplashScreenView#remove} resets the system UI colors to the values set prior to the execution + * of the Dart entrypoint. As a result, the values set from Dart are reverted by this API. To + * workaround this issue, call this method after removing the splash screen with {@code + * SplashScreenView#remove}. + */ + void updateSystemUiOverlays(); } } diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java index b4bc5777fb5..f18ef836689 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java @@ -1275,6 +1275,13 @@ public class FlutterFragment extends Fragment return true; } + @Override + public void updateSystemUiOverlays() { + if (delegate != null) { + delegate.updateSystemUiOverlays(); + } + } + /** * {@inheritDoc} * diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterAndroidComponentTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterAndroidComponentTest.java index 1f5978d73eb..3f483bf6e95 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterAndroidComponentTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterAndroidComponentTest.java @@ -384,6 +384,9 @@ public class FlutterAndroidComponentTest { @Override public void detachFromFlutterEngine() {} + @Override + public void updateSystemUiOverlays() {} + @Override public boolean popSystemNavigator() { return false;