Remove PendingActivityLaunches based on stack.

Was previously removing by trying to match activities, but the
activity being matched would not have been in the stack yet. Since
it doesn't get added to the stack when it goes into the list
of pending activities. By removing all pending activities associated
with the stack we clean up all such pending activities.

Fixes bug 16045752.

Change-Id: I6b5981ffcce674139837b06362e573299bbc9e52
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index cdccccc..91915c1 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1859,10 +1859,10 @@
         }
     }
 
-    void removePendingActivityLaunchesLocked(ActivityRecord r) {
+    void removePendingActivityLaunchesLocked(ActivityStack stack) {
         for (int palNdx = mPendingActivityLaunches.size() - 1; palNdx >= 0; --palNdx) {
             PendingActivityLaunch pal = mPendingActivityLaunches.get(palNdx);
-            if (pal.r == r) {
+            if (pal.stack == stack) {
                 mPendingActivityLaunches.remove(palNdx);
             }
         }
@@ -3099,6 +3099,7 @@
                 long origId = Binder.clearCallingIdentity();
                 try {
                     mStack.finishAllActivitiesLocked(false);
+                    removePendingActivityLaunchesLocked(mStack);
                 } finally {
                     Binder.restoreCallingIdentity(origId);
                 }