From 4ff7da964737331b65419f6f91cad7693f3265fc Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Mon, 17 Jul 2017 10:39:24 -0700 Subject: [PATCH] Ensure home activity always is on home stack. It is possible to start a home activity on a non-home stack. For example, an activity that handles the home intent may be started with via a different intent, landing it on the fullscreen stack. This becomes problematic later on due to our assumptions about the home stack state and handling of tasks within it. To ensure proper behavior, this changelist moves the activity handling the home intent to the home stack if it is not already present there. Fixes: 36606833 Test: Move home activity to fullscreen stack, launch another activity, press home button. Test: go/wm-smoke Change-Id: If88550a24dca3eabc0c60940937e6a1e6f133cae --- services/core/java/com/android/server/am/ActivityStarter.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index a31c33e4ab91..4f04066c6076 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -1640,6 +1640,16 @@ class ActivityStarter { REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME, "reparentToDisplay"); mMovedToFront = true; + } else if (launchStack.getStackId() == StackId.HOME_STACK_ID + && mTargetStack.getStackId() != StackId.HOME_STACK_ID) { + // It is possible for the home activity to be in another stack initially. + // For example, the activity may have been initially started with an intent + // which placed it in the fullscreen stack. To ensure the proper handling of + // the activity based on home stack assumptions, we must move it over. + intentActivity.getTask().reparent(launchStack.mStackId, ON_TOP, + REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME, + "reparentingHome"); + mMovedToFront = true; } mOptions = null; -- 2.11.0