diff options
author | Daniel Sandler <dsandler@android.com> | 2012-10-09 17:44:45 -0700 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-10-10 11:34:44 -0700 |
commit | c13107046acfcda7e3402a56a617818b7e77e1b8 (patch) | |
tree | cce826e1a572f5166bbf6b2c0b3cdbdbc4612ace | |
parent | 434f8172332f0abf02499f33846c6042ed628b0c (diff) | |
download | frameworks_base-c13107046acfcda7e3402a56a617818b7e77e1b8.zip frameworks_base-c13107046acfcda7e3402a56a617818b7e77e1b8.tar.gz frameworks_base-c13107046acfcda7e3402a56a617818b7e77e1b8.tar.bz2 |
Remove Dream windows immediately.
Ensures that onDetachedFromWindow happens before onDestroy.
Bug: 7295929
Change-Id: Ic4ac2552bfce75a5dc43dc840e6ef0182369e24b
-rw-r--r-- | core/java/android/service/dreams/DreamService.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index cb78763..bdb86d9 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -37,6 +37,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.view.WindowManagerGlobal; import android.view.WindowManager.LayoutParams; import android.view.accessibility.AccessibilityEvent; @@ -510,8 +511,12 @@ public class DreamService extends Service implements Window.Callback { @Override public void onDestroy() { if (mDebug) Slog.v(TAG, "onDestroy()"); - super.onDestroy(); // hook for subclasses + + // Just in case destroy came in before detach, let's take care of that now + detach(); + + super.onDestroy(); } // end public api @@ -521,13 +526,13 @@ public class DreamService extends Service implements Window.Callback { } /** - * Called when the Dream is about to be unbound and destroyed. + * Called by DreamController.stopDream() when the Dream is about to be unbound and destroyed. * * Must run on mHandler. */ private final void detach() { if (mWindow == null) { - Slog.e(TAG, "detach() called when not attached"); + // already detached! return; } @@ -540,7 +545,11 @@ public class DreamService extends Service implements Window.Callback { if (mDebug) Slog.v(TAG, "detach(): Removing window from window manager"); try { - mWindowManager.removeView(mWindow.getDecorView()); + // force our window to be removed synchronously + mWindowManager.removeViewImmediate(mWindow.getDecorView()); + // the following will print a log message if it finds any other leaked windows + WindowManagerGlobal.getInstance().closeAll(mWindowToken, + this.getClass().getName(), "Dream"); } catch (Throwable t) { Slog.w(TAG, "Crashed removing window view", t); } |