Android 8.1 is set to a white wallpaper and then restarts causing the status bar to be invisible

16054562:

Due to the needs of the recent project, the customer said that the default white wallpaper needs to be set for the system. After the setting is completed, it is found that after the first boot, why are the status bar and navigation bar gone? ? ?
It doesn't make sense! Then think about it, it should be that the wallpaper and title bar are all white and cannot be viewed. After careful observation, it is indeed the same as guessed.

Well, without further ado, go directly to the code
packages\apps\Launcher3\src\com\android\launcher3\Launcher.java

@@ -272,6 +273,7 @@ public class Launcher extends BaseActivity
 
     private boolean mPaused = true;
     private boolean mOnResumeNeedsLoad;
     //判断是否刚开机
+    private static boolean isFirstFlag = true;
 
     private final ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<>();
     private final ArrayList<Runnable> mOnResumeCallbacks = new ArrayList<>();
@@ -378,7 +380,16 @@ public class Launcher extends BaseActivity
 
         WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this);
         wallpaperColorInfo.setOnThemeChangeListener(this);
-        overrideTheme(wallpaperColorInfo.isDark(), wallpaperColorInfo.supportsDarkText());
+        if (isFirstFlag) {
    
    
+            if (wallpaperColorInfo.isDark()) {
    
    
+                overrideTheme(true, true);
+            } else {
    
    
+                overrideTheme(false, true);
+            }
+            isFirstFlag = false;
+        } else {
    
    
+            overrideTheme(wallpaperColorInfo.isDark(), wallpaperColorInfo.supportsDarkText());
+        }

After booting, if you reset the white or black wallpaper, Laucher will adapt itself according to the set wallpaper color, there will be a delay, but the first boot will not be adaptive.

I wrote this first, if there is something wrong, please correct me.

Guess you like

Origin blog.csdn.net/a307326984/article/details/132049929