Clear reference to DreamActivity window.

This changelist clears the reference to the DreamActivity window once
the activity is cleared in DreamService. Holding onto the reference
will lead to a DreamActivity instance leak.

Test: verified leak no longer present through hprof
Bug: 221285764
Change-Id: I1494bcdeaa1b23c0006867ff8eb1806bd5206eba
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index db622d3..1fd75e6 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -1341,7 +1341,9 @@
                     public void onViewDetachedFromWindow(View v) {
                         if (mActivity == null || !mActivity.isChangingConfigurations()) {
                             // Only stop the dream if the view is not detached by relaunching
-                            // activity for configuration changes.
+                            // activity for configuration changes. It is important to also clear
+                            // the window reference in order to fully release the DreamActivity.
+                            mWindow = null;
                             mActivity = null;
                             finish();
                         }