Pause activities when leaving.

Missed a spot where an activity that is launching another was not
being paused. Fixes bug 8640130. At least in one case.

Release mWindowMap as soon as it is no longer needed.

Change-Id: Id2c63d3d715b98741e2ebe3c9985cb1e9ca5ffbc
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 3758bb1..675823a 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1302,7 +1302,12 @@
 
         // We need to start pausing the current activity so the top one
         // can be resumed...
-        if (mStackSupervisor.pauseBackStacks(userLeaving)) {
+        boolean pausing = mStackSupervisor.pauseBackStacks(userLeaving);
+        if (mResumedActivity != null) {
+            pausing = true;
+            startPausingLocked(userLeaving, false);
+        }
+        if (pausing) {
             if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: need to start pausing");
             // At this point we want to put the upcoming activity's process
             // at the top of the LRU list, since we know we will be needing it