diff options
| author | Robert Carr <racarr@google.com> | 2020-02-27 13:25:17 -0800 |
|---|---|---|
| committer | Rob Carr <racarr@google.com> | 2020-02-28 21:30:33 +0000 |
| commit | 01b0dd5f1d606fb96a71cf373532c2b09ffb4217 (patch) | |
| tree | c693cbdc3dd6b117ba34dc063465c0008ba5e495 /core/java/android/view/SurfaceControl.java | |
| parent | abe3d7bde45371c10345b06c691ff1d163279b84 (diff) | |
SurfaceControl: Bind close-guard lifetime to native-object lifetime.
Currently there are two bugs in the close-guard behavior:
Bug 1:
a. Create surface control from parcel, close guard opens
b. Import new parcel, last object release close guard closed
c. Close guard not reopened, now we have a resource but no close guard
Bug 2:
a. Construct "new SurfaceControl()" but don't do anything with it
b. Now we have a close guard but no native resources
This CL ensures the state of the close guard matches the ownership of
native resources.
Bug: 150128124
Test: Existing tests pass
Change-Id: I0155854213ac64be3ac9a5d264815dbd43018fca
Diffstat (limited to 'core/java/android/view/SurfaceControl.java')
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 0816e8433e66..a492222690e4 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -420,6 +420,9 @@ public final class SurfaceControl implements Parcelable { if (mNativeObject != 0) { release(); } + if (nativeObject != 0) { + mCloseGuard.open("release"); + } mNativeObject = nativeObject; } @@ -867,14 +870,12 @@ public final class SurfaceControl implements Parcelable { private SurfaceControl(Parcel in) { readFromParcel(in); - mCloseGuard.open("release"); } /** * @hide */ public SurfaceControl() { - mCloseGuard.open("release"); } public void readFromParcel(Parcel in) { @@ -972,8 +973,8 @@ public final class SurfaceControl implements Parcelable { if (mNativeObject != 0) { nativeRelease(mNativeObject); mNativeObject = 0; + mCloseGuard.close(); } - mCloseGuard.close(); } /** |
