Reset activity's "return to home" flag on relaunch

When relaunching an activity re-evaluate the flag that determines
whether to return to the next activity on the stack or to the home
activity upon return.

Fixes bug 10545580.

Change-Id: I5868ce1b494afffcc5afc22abe3b65aa339827bb
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 250ab4a..3e0b5eb 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1426,8 +1426,7 @@
                             if ((launchFlags &
                                     (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME))
                                     == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) {
-                                // Caller wants to appear on home activity, so before starting
-                                // their own activity we will bring home to the front.
+                                // Caller wants to appear on home activity.
                                 r.mLaunchHomeTaskNext = true;
                             }
                             targetStack.moveTaskToFrontLocked(intentActivity.task, r, options);
@@ -1541,6 +1540,8 @@
                         // don't use that intent!)  And for paranoia, make
                         // sure we have correctly resumed the top activity.
                         if (doResume) {
+                            // Reset flag so it gets correctly reevaluated.
+                            intentActivity.mLaunchHomeTaskNext = false;
                             setLaunchHomeTaskNextFlag(sourceRecord, intentActivity, targetStack);
                             targetStack.resumeTopActivityLocked(null, options);
                         } else {