SurfaceView: Update transform hint only if the view is visible
Transform hint should only be updated when creating the
surface or the view is visible. If the view is not visible, BBQ
will be null. This fixes a NPE in SurfaceView.
Test: go/wm-smoke
Fixes: 193618182
Change-Id: I98a463ae23a93d89ac803e2c2d80ecfd56ca97d2
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 4f2cf6d..f21d855dd 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -1081,7 +1081,8 @@
|| mWindowSpaceTop != mLocation[1];
final boolean layoutSizeChanged = getWidth() != mScreenRect.width()
|| getHeight() != mScreenRect.height();
- final boolean hintChanged = viewRoot.getSurfaceTransformHint() != mTransformHint;
+ final boolean hintChanged = (viewRoot.getSurfaceTransformHint() != mTransformHint)
+ && mRequestedVisible;
if (creating || formatChanged || sizeChanged || visibleChanged ||
(mUseAlpha && alphaChanged) || windowVisibleChanged ||
@@ -1227,7 +1228,9 @@
// Therefore, we must explicitly recreate the {@link Surface} in these
// cases.
if (mUseBlastAdapter) {
- mSurface.transferFrom(mBlastBufferQueue.createSurfaceWithHandle());
+ if (mBlastBufferQueue != null) {
+ mSurface.transferFrom(mBlastBufferQueue.createSurfaceWithHandle());
+ }
} else {
mSurface.createFrom(mSurfaceControl);
}
@@ -1237,7 +1240,10 @@
private void setBufferSize(Transaction transaction) {
if (mUseBlastAdapter) {
mBlastSurfaceControl.setTransformHint(mTransformHint);
- mBlastBufferQueue.update(mBlastSurfaceControl, mSurfaceWidth, mSurfaceHeight, mFormat);
+ if (mBlastBufferQueue != null) {
+ mBlastBufferQueue.update(mBlastSurfaceControl, mSurfaceWidth, mSurfaceHeight,
+ mFormat);
+ }
} else {
transaction.setBufferSize(mSurfaceControl, mSurfaceWidth, mSurfaceHeight);
}