Fix NPE when adding window with policy to hide

WindowState will be created with token. But it may not add
to the token immediately. So at that path it should use
getDisplayContent() that use token to get display.

Such as addWindow -> initAppOpsState -> setAppOpVisibilityLw
-> hide -> startAnimation.

"win.mToken.addWindow(win)" executes after that.

Bug: 226259929
Test: switch user
Change-Id: Ieba9df3bca87d10cd031d25e0b7f1e9a0c311dee
This commit is contained in:
Riddle Hsu
2022-03-24 14:49:20 +08:00
parent 3cb4ef6df5
commit 28dc4cbba4

View File

@@ -5288,7 +5288,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
if (mControllableInsetProvider != null) {
return;
}
if (mDisplayContent.inTransition()) {
if (getDisplayContent().inTransition()) {
// Skip because the animation is usually unnoticeable (e.g. covered by rotation
// animation) and the animation bounds could be inconsistent, such as depending
// on when the window applies its draw transaction with new rotation.