Repository: flutter
Issue: Flutter overrides Android statusbar icon brightness on startup
Labels: platform-android,engine,a: fidelity,a: quality,customer: crowd,a: layout,has reproducible steps,P2,found in release: 3.7,found in release: 3.10,team-android,triaged-android

Android supports light/dark brightness for statusbar icons. On startup, the FlutterActivity always sets the status bar icons to light.

When trying to create an app with dark status bar icons, this causes a flicker between brightness on startup.

![flutter_light_status_bar](https://user-images.githubusercontent.com/848767/90449938-927a5700-e13c-11ea-9cd7-5faa925c2f58.gif)


## Steps to Reproduce


**To reproduce, configure the Android theme to have a light status bar (dark icons):**

```xml
<style name="LaunchTheme" parent="@style/Theme.AppCompat.Light">
        
        <!--  The statusbar color is overridden to match the statusbar color set in Flutter -->
        <item name="android:statusBarColor">#42000000</item> 
        <!--  Request the statusbar has dark icons -->
        <item name="android:windowLightStatusBar">true</item>
        
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
         This Theme is only used starting with V2 of Flutter's Android embedding. -->
    <style name="NormalTheme" parent="@style/Theme.AppCompat.Light">
        
        <!--  The statusbar color is overridden to match the statusbar color set in Flutter -->
        <item name="android:statusBarColor">#42000000</item>
        <!--  Request the statusbar has dark icons -->
        <item name="android:windowLightStatusBar">true</item>
        
        <item name="android:windowBackground">@android:color/white</item>
    </style>
```

**In Flutter, also set the status bar icons to dark:**

```dart
 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    statusBarIconBrightness: Brightness.dark,
    statusBarColor: Colors.black26, //this color matches what we have set in the Android theme
  ));
```

**Expected result:** On startup, the statusbar color and icon color should be consistent across the native startup sequence and as the Flutter engine/app starts.

**Actual result:** The app starts with the correct status bar/icon colors, then flickers to light status bar icons during startup, and once the Flutter app is running flicks back to dark statusbar icons. 

A sample project can be found [here.](https://github.com/josh-burton/flutter-android-light-statusbar)


The cause of the issue seems to be this method in **io.flutter.embedding.android.FlutterActivity**:

```java
  private void configureStatusBarForFullscreenFlutterExperience() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(0x40000000);
      window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
    }
  }
```

Either Flutter should set the status bar color/brightness to the existing Android theme settings, or provide a way to override these values in the theme or manifest metadata.


<details>
  <summary>Logs</summary>
```
➜ flutter doctor -v
[✓] Flutter (Channel beta, 1.20.0, on Mac OS X 10.15.5 19F101, locale en-AU)
    • Flutter version 1.20.0 at /Users/athor/dev/flutter
    • Framework revision 916c3ac648 (2 weeks ago), 2020-08-01 09:01:12 -0700
    • Engine revision d6ee1499c2
    • Dart version 2.9.0 (build 2.9.0-21.10.beta)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/athor/dev/android-sdk
    • Platform android-30, build-tools 30.0.1
    • ANDROID_HOME = /Users/athor/dev/android-sdk
    • Java binary at: /Users/athor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/201.6719854/Android Studio 4.1 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/athor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-2/193.6626763/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[!] Android Studio (version 4.1)
    • Android Studio at /Users/athor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/201.6719854/Android Studio 4.1 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[!] Android Studio
    • Android Studio at /Users/athor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6720134/Android Studio 4.2 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.2)
    • IntelliJ at /Users/athor/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 48.0.4-dev.4
    • Dart plugin version 202.6397.47

[✓] VS Code (version 1.47.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (3 available)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64    • Android 10 (API 29) (emulator)
    • Web Server (web)                      • web-server    • web-javascript • Flutter Tools
    • Chrome (web)                          • chrome        • web-javascript • Google Chrome 84.0.4147.125

! Doctor found issues in 2 categories.

```

</details>