Merge "Fix NPE going from PiP to Fullscreen." into udc-dev

This commit is contained in:
Galia Peycheva
2023-04-04 09:07:11 +00:00
committed by Android (Google) Code Review

View File

@@ -276,15 +276,14 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
Rect pipBounds) { Rect pipBounds) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: resizePipMenu: %s", TAG, pipBounds.toShortString()); "%s: resizePipMenu: %s", TAG, pipBounds.toShortString());
if (pipBounds.isEmpty()) { if (pipBounds.isEmpty()) {
return; return;
} }
if (!isMenuAttached()) {
if (!isMenuReadyToMove()) {
return; return;
} }
final SurfaceControl frontSurface = getSurfaceControl(mPipMenuView); final SurfaceControl frontSurface = getSurfaceControl(mPipMenuView);
final SurfaceControl backSurface = getSurfaceControl(mPipBackgroundView); final SurfaceControl backSurface = getSurfaceControl(mPipBackgroundView);
final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds); final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds);
@@ -321,7 +320,7 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
} }
return; return;
} }
if (!isMenuReadyToMove()) { if (!isMenuAttached()) {
return; return;
} }
@@ -344,12 +343,12 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
syncGroup.markSyncReady(); syncGroup.markSyncReady();
} }
private boolean isMenuReadyToMove() { private boolean isMenuAttached() {
final boolean ready = mPipMenuView != null && mPipMenuView.getViewRootImpl() != null final boolean ready = mPipMenuView != null && mPipMenuView.getViewRootImpl() != null
&& mPipBackgroundView != null && mPipBackgroundView.getViewRootImpl() != null; && mPipBackgroundView != null && mPipBackgroundView.getViewRootImpl() != null;
if (!ready) { if (!ready) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, 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; return ready;
} }
@@ -368,6 +367,9 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
@Override @Override
public void updateMenuBounds(Rect pipBounds) { public void updateMenuBounds(Rect pipBounds) {
if (!isMenuAttached()) {
return;
}
final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds); final Rect menuBounds = calculateMenuSurfaceBounds(pipBounds);
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: updateMenuBounds: %s", TAG, menuBounds.toShortString()); "%s: updateMenuBounds: %s", TAG, menuBounds.toShortString());