Update visibility of finishing activities

A visibility of a trampoline activity may not be updated when the
activity it launches becomes visible in some cases. This CL makes
sure that the visibility of a finishing activity is updated to
'false'.

In a normal flow when a trampoline activity launches the next one,
ActivityStack#resumeTopActivityInnerLocked() sets the visibility to
'false' when the next one is being resumed. However, if the
RootActivityContainer#ensureVisibilityAndConfig() is called before
that, it can update the visibility of the top activity without
updating the visibility of the trampoline (visibility updates were
skipped for finishing activities).

Bug: 139808754
Test: Unit tests for ActivityRecord and CTS lifecycle tests
Change-Id: Idc89743fb708487594e5b56f2e860e4ffc78fd14
This commit is contained in:
Andrii Kulian
2019-08-23 15:04:17 -07:00
parent c8aec6423d
commit 149d9ad3fe
2 changed files with 5 additions and 4 deletions

View File

@@ -2094,9 +2094,6 @@ class ActivityStack extends ConfigurationContainer {
final ArrayList<ActivityRecord> activities = task.mActivities;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = activities.get(activityNdx);
if (r.finishing) {
continue;
}
final boolean isTop = r == top;
if (aboveTop && !isTop) {
continue;
@@ -2112,6 +2109,9 @@ class ActivityStack extends ConfigurationContainer {
behindFullscreenActivity, r);
}
if (reallyVisible) {
if (r.finishing) {
continue;
}
if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Make visible? " + r
+ " finishing=" + r.finishing + " state=" + r.getState());
// First: if this is not the current activity being started, make

View File

@@ -30,6 +30,7 @@ import static android.view.WindowManager.TRANSIT_TASK_CLOSE;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.atLeast;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
@@ -866,7 +867,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
mActivity.setState(PAUSED, "test");
mActivity.finishIfPossible("test", false /* oomAdj */);
verify(mActivity).setVisibility(eq(false));
verify(mActivity, atLeast(1)).setVisibility(eq(false));
verify(mActivity.getDisplay().mDisplayContent)
.prepareAppTransition(eq(TRANSIT_TASK_CLOSE), eq(false) /* alwaysKeepCurrent */);
verify(mActivity.getDisplay().mDisplayContent).executeAppTransition();