From d7f7deb2862fcfe830df15b6dc1be041f2741d3d Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 25 Sep 2009 17:35:10 -0700 Subject: [PATCH] Fix potential race when removing keyguard view. Change-Id: Ia636bc8a73d18b8ebe2dca2b29bb74793a3f0396 --- .../internal/policy/impl/KeyguardViewManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/policy/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/com/android/internal/policy/impl/KeyguardViewManager.java index a1d3576c81335..0facbf6cbbd2e 100644 --- a/policy/com/android/internal/policy/impl/KeyguardViewManager.java +++ b/policy/com/android/internal/policy/impl/KeyguardViewManager.java @@ -214,11 +214,16 @@ public class KeyguardViewManager implements KeyguardWindowController { // Don't do this right away, so we can let the view continue to animate // as it goes away. if (mKeyguardView != null) { + final View lastView = mKeyguardView; mKeyguardHost.postDelayed(new Runnable() { public void run() { - mKeyguardHost.removeView(mKeyguardView); - mKeyguardView.cleanUp(); - mKeyguardView = null; + synchronized (KeyguardViewManager.this) { + if (mKeyguardView == lastView) { + mKeyguardHost.removeView(mKeyguardView); + mKeyguardView.cleanUp(); + mKeyguardView = null; + } + } } }, 500); }