diff options
| author | 2020-03-17 11:31:55 -0700 | |
|---|---|---|
| committer | 2020-03-17 14:12:53 -0700 | |
| commit | d9c9c0cc75cbb71492af72a80772de9b900d628a (patch) | |
| tree | b20d9f349fc7404966f9c855382ffb14cbbc6935 | |
| parent | 59624b219f1961114526b91ae253966f26b10d89 (diff) | |
SurfacePackage: Add release method
Oversight, the SurfacePackage holds a reference to the SurfaceControl
which is protected by a close-guard. We need a way to close it
explicitly. Going to follow up with a patch to have SurfaceView
manage the lifetime when the SurfacePackage is consumed, but want
to make sure this explicit release gets in ASAP.
Bug: 149591513
Test: Existing tests pass
Change-Id: I7276a2440c38cc6d859b79b4c3ee57bc122ce2a6
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/view/SurfaceControlViewHost.java | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index da9fd09cf152..007e67d67872 100644 --- a/api/current.txt +++ b/api/current.txt @@ -53616,6 +53616,7 @@ package android.view { public static final class SurfaceControlViewHost.SurfacePackage implements android.os.Parcelable { method public int describeContents(); + method public void release(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.SurfaceControlViewHost.SurfacePackage> CREATOR; } diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java index 41a384797521..b587fbe24767 100644 --- a/core/java/android/view/SurfaceControlViewHost.java +++ b/core/java/android/view/SurfaceControlViewHost.java @@ -52,7 +52,7 @@ public class SurfaceControlViewHost { * a SurfaceView by calling {@link SurfaceView#setChildSurfacePackage}. */ public static final class SurfacePackage implements Parcelable { - private final SurfaceControl mSurfaceControl; + private SurfaceControl mSurfaceControl; private final IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection; SurfacePackage(SurfaceControl sc, IAccessibilityEmbeddedConnection connection) { @@ -97,6 +97,16 @@ public class SurfaceControlViewHost { out.writeStrongBinder(mAccessibilityEmbeddedConnection.asBinder()); } + /** + * Release the SurfaceControl associated with the SurfacePackage. + */ + public void release() { + if (mSurfaceControl != null) { + mSurfaceControl.release(); + } + mSurfaceControl = null; + } + public static final @NonNull Creator<SurfacePackage> CREATOR = new Creator<SurfacePackage>() { public SurfacePackage createFromParcel(Parcel in) { |