From 1a797c714b90c9c236c34f47d15d3b58a93ce87f Mon Sep 17 00:00:00 2001 From: Shen Lin Date: Wed, 9 Nov 2022 17:16:12 +0800 Subject: [PATCH] Fix potential crash when exit splash screen - Make sure mDecorView is attached before calling its WindowInsetsController. - Amend modifier declare sequence for a better code style. Bug: 258270145 Test: atest SplashscreenTests StartingSurfaceDrawerTests Change-Id: I4d3b184252ed9516827812adfa0c76e07a6527e7 --- .../wm/shell/startingsurface/StartingSurfaceDrawer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java index 54d62edf25701..978ad8ac10f2c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java @@ -429,7 +429,8 @@ public class StartingSurfaceDrawer { } @Override - public @Nullable SplashScreenView get() { + @Nullable + public SplashScreenView get() { synchronized (this) { while (!mIsViewSet) { try { @@ -690,7 +691,7 @@ public class StartingSurfaceDrawer { private final TaskSnapshotWindow mTaskSnapshotWindow; private SplashScreenView mContentView; private boolean mSetSplashScreen; - private @StartingWindowType int mSuggestType; + @StartingWindowType private int mSuggestType; private int mBGColor; private final long mCreateTime; private int mSystemBarAppearance; @@ -731,7 +732,7 @@ public class StartingSurfaceDrawer { // Reset the system bar color which set by splash screen, make it align to the app. private void clearSystemBarColor() { - if (mDecorView == null) { + if (mDecorView == null || !mDecorView.isAttachedToWindow()) { return; } if (mDecorView.getLayoutParams() instanceof WindowManager.LayoutParams) {