Compare tasks not activities.

In order to determine if the topmost activity needs to be moved out
of the way, compare its task to the task of the source activity
rather than compare the activities themeselves.

Fixes bug 10182783.

Change-Id: Idd4542d7ddce8b7586ee47f100366bc47e07d54f
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 467c0b3..dc2b0ae 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1418,7 +1418,8 @@
                             null : lastStack.topRunningNonDelayedActivityLocked(notTop);
                     if (curTop != null && curTop.task != intentActivity.task) {
                         r.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
-                        if (sourceRecord == null || sourceStack.topActivity() == sourceRecord) {
+                        if (sourceRecord == null || (sourceStack.topActivity() != null &&
+                                sourceStack.topActivity().task == sourceRecord.task)) {
                             // We really do want to push this one into the
                             // user's face, right now.
                             movedHome = true;