From fc0ebd7d379ff63c00ebf78ca252fab5070213da Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 30 Apr 2013 16:33:00 -0700 Subject: Really make Surface thread-safe. There were many places where the native object was being accessed improperly. Also some places where CloseGuard might not be acquired or released correctly or where the generation count might not be updated. Fixed them all. That said, Surface isn't intended to be used concurrently so please don't do it. This is only intended to make hard to find crashes less likely. Bug: 8328715 Change-Id: I981ef33425823e0fd7ad6b64443f2ec9b0c8335e --- core/java/android/view/SurfaceControl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core/java/android/view/SurfaceControl.java') diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index e869d09adaa7..6b530ef343a5 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -496,8 +496,14 @@ public class SurfaceControl { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } - int nativeSurface = surface != null ? surface.mNativeObject : 0; - nativeSetDisplaySurface(displayToken, nativeSurface); + + if (surface != null) { + synchronized (surface.mLock) { + nativeSetDisplaySurface(displayToken, surface.mNativeObject); + } + } else { + nativeSetDisplaySurface(displayToken, 0); + } } public static IBinder createDisplay(String name, boolean secure) { -- cgit v1.2.3