From 40d73a799732110b75d33faa707412821c680b50 Mon Sep 17 00:00:00 2001 From: "yang.xa.liu" Date: Fri, 18 Dec 2015 16:40:31 +0800 Subject: [PATCH] Make sure NaturalSurfaceLayout is consistent with SurfaceControl SurfaceControl and NaturalSurfaceLayout will be created in screen-off mode. Screen-on animation also creates NaturalSurfaceLayout. And NaturalSurfaceLayout uses the reference of SurfaceControl. SurfaceControl points to NULL when screen-on process calls destory function, which will not be called in screen-off process. It makes NaturalSurfaceLayout's member points to the SurfaceControl with NULL. Crash occurs by accessing the destroyed SurfaceControl. This CL makes the creation of SurfaceControl and NaturalSurfaceLayout to one-to-one. Change-Id: Ic47ea73dea67d2aba4e3e0766d1353198d7dff1d --- .../com/android/server/display/ColorFade.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/display/ColorFade.java b/services/core/java/com/android/server/display/ColorFade.java index 835ba1734da32..a16fcd2fa112e 100644 --- a/services/core/java/com/android/server/display/ColorFade.java +++ b/services/core/java/com/android/server/display/ColorFade.java @@ -587,16 +587,16 @@ final class ColorFade { Slog.e(TAG, "Unable to create surface.", ex); return false; } + + mSurfaceControl.setLayerStack(mDisplayLayerStack); + mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight); + mSurface = new Surface(); + mSurface.copyFrom(mSurfaceControl); + + mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, + mDisplayId, mSurfaceControl); + mSurfaceLayout.onDisplayTransaction(); } - - mSurfaceControl.setLayerStack(mDisplayLayerStack); - mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight); - mSurface = new Surface(); - mSurface.copyFrom(mSurfaceControl); - - mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, - mDisplayId, mSurfaceControl); - mSurfaceLayout.onDisplayTransaction(); } finally { SurfaceControl.closeTransaction(); }