From 7581cddf2515e9ec7c834549118b8db27e3a494f Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Mon, 22 Aug 2016 09:35:39 -0700 Subject: [PATCH] Make sure surface control is really valid before giving it to client Checking mSurfaceControl!=null is not enough to ensure the surface is valid. tryStartExitingAnimation() could destroy/save the surface before app is stopped, if it decided the surface is no longer needed. Use WSA.hasSurface() to check if the surface control is really valid. bug: 30766796 Change-Id: I7724f1929d4ebc3f9a7a3b19eec638d7a7d7b910 --- .../java/com/android/server/wm/WindowManagerService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index f2f85bf184cf9..1f82f0cda9f6b 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2908,12 +2908,11 @@ public class WindowManagerService extends IWindowManager.Stub } result |= RELAYOUT_RES_SURFACE_CHANGED; } - final WindowSurfaceController surfaceController = winAnimator.mSurfaceController; - if (viewVisibility == View.VISIBLE && surfaceController != null) { + if (viewVisibility == View.VISIBLE && winAnimator.hasSurface()) { // We already told the client to go invisible, but the message may not be // handled yet, or it might want to draw a last frame. If we already have a // surface, let the client use that, but don't create new surface at this point. - surfaceController.getSurface(outSurface); + winAnimator.mSurfaceController.getSurface(outSurface); } else { if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Releasing surface in: " + win);