Fix NPE for checking immersive confirmation window root feature

This may happen when the immersive mode change is triggered from
the window removal. In this case, it will not be attached to a root.

Bug: 186072738
Test: manual
Change-Id: I546f9f651e3f6a26f506ed7269683b9bffa32926
This commit is contained in:
Chris Li
2021-04-27 11:03:10 -07:00
parent 81e85863e5
commit e870d13d34

View File

@@ -92,6 +92,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_RIGHT;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_TIMEOUT;
@@ -2667,7 +2668,8 @@ public class DisplayPolicy {
if (oldImmersiveMode != newImmersiveMode) {
mLastImmersiveMode = newImmersiveMode;
// The immersive confirmation window should be attached to the immersive window root.
final int rootDisplayAreaId = win.getRootDisplayArea().mFeatureId;
final RootDisplayArea root = win.getRootDisplayArea();
final int rootDisplayAreaId = root == null ? FEATURE_UNDEFINED : root.mFeatureId;
mImmersiveModeConfirmation.immersiveModeChangedLw(rootDisplayAreaId, newImmersiveMode,
mService.mPolicy.isUserSetupComplete(),
isNavBarEmpty(disableFlags));