Fix NPE going from PiP to Fullscreen.

Only happens when going to fullscreen when shell transitions are turned
on.

Bug: 271098548
Test: manual - make sure shell transitions are enabled, start a PiP, go
to the menu and select the fullscreen option --> app should go to
fullscreen and not just show a black screen.

Change-Id: I848b808182a0b0bae11401d74765cfd25e864d15
This commit is contained in:
Jacqueline Bronger
2023-02-07 09:55:26 +01:00
parent f928c832f3
commit d881a67969

View File

@@ -276,15 +276,14 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
Rect pipBounds) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: resizePipMenu: %s", TAG, pipBounds.toShortString());
if (pipBounds.isEmpty()) {
return;
}
if (!isMenuReadyToMove()) {
if (!isMenuAttached()) {
return;
}
final SurfaceControl frontSurface = getSurfaceControl(mPipMenuView);
final SurfaceControl backSurface = getSurfaceControl(mPipBackgroundView);
final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds);
@@ -321,7 +320,7 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
}
return;
}
if (!isMenuReadyToMove()) {
if (!isMenuAttached()) {
return;
}
@@ -344,12 +343,12 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
syncGroup.markSyncReady();
}
private boolean isMenuReadyToMove() {
private boolean isMenuAttached() {
final boolean ready = mPipMenuView != null && mPipMenuView.getViewRootImpl() != null
&& mPipBackgroundView != null && mPipBackgroundView.getViewRootImpl() != null;
if (!ready) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: Not going to move PiP, either menu or its parent is not created.", TAG);
"%s: the menu surfaces are not attached.", TAG);
}
return ready;
}
@@ -368,6 +367,9 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
@Override
public void updateMenuBounds(Rect pipBounds) {
if (!isMenuAttached()) {
return;
}
final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds);
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: updateMenuBounds: %s", TAG, menuBounds.toShortString());