From f9b5a13cd1f79ffca2965e153862fb77b8821a9b Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 7 Feb 2022 16:06:29 -0800 Subject: [PATCH] SurfaceControlViewHost: Clone control for SurfacePackage Otherwise the results can be quite confusing, each time we call getSurfacePackage it returns a new SurfacePackage but after releasing the first one all the others become invalid. This normally isn't noticed as SurfaceControlViewHost is frequently used only in cross process scenarios so the additional step of parcelling can prevent this issue from occuring. Bug: 196926363 Test: SurfaceViewSurfacePackageValidatorTest#testSurfacePackageNoFlicker Change-Id: Id77f6daab4bb80d4d23d40d24d74b39bd694f350 --- core/java/android/view/SurfaceControlViewHost.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java index 2edfda5d065c3..a13579d0acad1 100644 --- a/core/java/android/view/SurfaceControlViewHost.java +++ b/core/java/android/view/SurfaceControlViewHost.java @@ -328,7 +328,8 @@ public class SurfaceControlViewHost { */ public @Nullable SurfacePackage getSurfacePackage() { if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) { - return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection, + return new SurfacePackage(new SurfaceControl(mSurfaceControl, "getSurfacePackage"), + mAccessibilityEmbeddedConnection, mWm.getFocusGrantToken(), mRemoteInterface); } else { return null;