diff options
| author | Mathias Agopian <mathias@google.com> | 2013-03-13 17:48:22 -0700 |
|---|---|---|
| committer | Mathias Agopian <mathias@google.com> | 2013-03-13 18:21:11 -0700 |
| commit | 86e1bc730570765355dc8789b5c6de6962a053cc (patch) | |
| tree | a6b5357746a565b6fd4853d9f46d75af422812d9 /core/java/android | |
| parent | c3b9cd635163ae48a9151fc6e1650388c5d716be (diff) | |
| download | frameworks_base-86e1bc730570765355dc8789b5c6de6962a053cc.zip frameworks_base-86e1bc730570765355dc8789b5c6de6962a053cc.tar.gz frameworks_base-86e1bc730570765355dc8789b5c6de6962a053cc.tar.bz2 | |
fix CloseGuard usage in Surface
Bug: 8375415
Change-Id: I03e9f318c2ad586f4bd93b280557ada66121d275
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/Surface.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 9955bc1..0492d29 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -39,7 +39,6 @@ public class Surface implements Parcelable { private native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas); private static native void nativeRelease(int nativeObject); - private static native void nativeDestroy(int nativeObject); private static native boolean nativeIsValid(int nativeObject); private static native boolean nativeIsConsumerRunningBehind(int nativeObject); private static native int nativeCopyFrom(int nativeObject, int surfaceControlNativeObject); @@ -106,7 +105,6 @@ public class Surface implements Parcelable { * @hide */ public Surface() { - mCloseGuard.open("release"); } /** @@ -135,6 +133,7 @@ public class Surface implements Parcelable { mCloseGuard.open("release"); } + /* called from android_view_Surface_createFromIGraphicBufferProducer() */ private Surface(int nativeObject) { mNativeObject = nativeObject; mCloseGuard.open("release"); @@ -146,9 +145,7 @@ public class Surface implements Parcelable { if (mCloseGuard != null) { mCloseGuard.warnIfOpen(); } - if (mNativeObject != 0) { - nativeRelease(mNativeObject); - } + release(); } finally { super.finalize(); } @@ -175,12 +172,7 @@ public class Surface implements Parcelable { * @hide */ public void destroy() { - if (mNativeObject != 0) { - nativeDestroy(mNativeObject); - mNativeObject = 0; - mGenerationId++; - } - mCloseGuard.close(); + release(); } /** @@ -287,6 +279,10 @@ public class Surface implements Parcelable { "SurfaceControl native object is null. Are you using a released SurfaceControl?"); } mNativeObject = nativeCopyFrom(mNativeObject, other.mNativeObject); + if (mNativeObject == 0) { + // nativeCopyFrom released our reference + mCloseGuard.close(); + } mGenerationId++; } @@ -308,11 +304,15 @@ public class Surface implements Parcelable { nativeRelease(mNativeObject); } // transfer the reference from other to us + if (other.mNativeObject != 0 && mNativeObject == 0) { + mCloseGuard.open("release"); + } mNativeObject = other.mNativeObject; mGenerationId++; other.mNativeObject = 0; other.mGenerationId++; + other.mCloseGuard.close(); } } @@ -326,7 +326,11 @@ public class Surface implements Parcelable { throw new IllegalArgumentException("source must not be null"); } mName = source.readString(); - mNativeObject = nativeReadFromParcel(mNativeObject, source); + int nativeObject = nativeReadFromParcel(mNativeObject, source); + if (nativeObject !=0 && mNativeObject == 0) { + mCloseGuard.open("release"); + } + mNativeObject = nativeObject; mGenerationId++; } |
