DO NOT MERGE -- Fix finishing activity in non-focused stack

This CL explicitly checks if we're finishing activity in non-focused
stack as there are other cases except this one when we finish paused
activities in FINISH_AFTER_VISIBLE mode.

Bug: 29007436
Bug: 29458854
Change-Id: I67744d23cd72f2fe8861180008bfdd284a7b5e26
(cherry picked from commit 995fa2bd2d)
This commit is contained in:
Andrii Kulian
2016-07-29 12:55:41 -07:00
parent 128a4419e9
commit 772c598f66

View File

@@ -3542,19 +3542,22 @@ final class ActivityStack {
final ActivityState prevState = r.state;
if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to FINISHING: " + r);
r.state = ActivityState.FINISHING;
final boolean finishingActivityInNonFocusedStack
= r.task.stack != mStackSupervisor.getFocusedStack()
&& prevState == ActivityState.PAUSED && mode == FINISH_AFTER_VISIBLE;
if (mode == FINISH_IMMEDIATELY
|| (prevState == ActivityState.PAUSED
&& (mode == FINISH_AFTER_PAUSE || mode == FINISH_AFTER_VISIBLE
|| mStackId == PINNED_STACK_ID))
&& (mode == FINISH_AFTER_PAUSE || mStackId == PINNED_STACK_ID))
|| finishingActivityInNonFocusedStack
|| prevState == ActivityState.STOPPED
|| prevState == ActivityState.INITIALIZING) {
r.makeFinishingLocked();
boolean activityRemoved = destroyActivityLocked(r, true, "finish-imm");
if (prevState == ActivityState.PAUSED && mode == FINISH_AFTER_VISIBLE) {
// Finishing activity that was in paused state - this can happen if it was in
// not currently focused stack. Need to make something visible in its place.
if (finishingActivityInNonFocusedStack) {
// Finishing activity that was in paused state and it was in not currently focused
// stack, need to make something visible in its place.
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
}
if (activityRemoved) {