Skip finishing activities while performing behind fullscreen check

Activities that behind a fullscreen finishing activity were
evaluated as invisible.

Bug: 144184591
Test: atest ActivityStackTests
Change-Id: Id09a30107d189acc986843ea8b3993a66c242a30
This commit is contained in:
Louis Chang
2020-02-21 12:14:32 +08:00
parent 7ed187c63e
commit 99d6f0e884
3 changed files with 33 additions and 6 deletions

View File

@@ -2085,7 +2085,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
/** Returns true if this activity is opaque and fills the entire space of this task. */
boolean occludesParent() {
return mOccludesParent;
return !finishing && mOccludesParent;
}
boolean setOccludesParent(boolean occludesParent) {

View File

@@ -2343,7 +2343,7 @@ class ActivityStack extends Task {
// Starting activity cannot be occluding activity, otherwise starting window could be
// remove immediately without transferring to starting activity.
final ActivityRecord occludingActivity = getActivity(
(ar) -> !ar.finishing && ar.occludesParent(), true, r);
(ar) -> ar.occludesParent(), true, r);
if (occludingActivity != null) {
// Here it is! Now, if this is not yet visible (occluded by another task) to the
// user, then just add it without starting; it will get started when the user
@@ -3069,9 +3069,8 @@ class ActivityStack extends Task {
}
// See if there is an occluding activity on-top of this one.
final ActivityRecord occludingActivity = getActivity((ar) ->
ar.occludesParent() && !ar.finishing,
r, false /*includeBoundary*/, true /*traverseTopToBottom*/);
final ActivityRecord occludingActivity = getActivity((ar) -> ar.occludesParent(), r,
false /*includeBoundary*/, true /*traverseTopToBottom*/);
if (occludingActivity != null) return false;
if (r.finishing) Slog.e(TAG, "willActivityBeVisible: Returning false,"

View File

@@ -27,6 +27,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECOND
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
@@ -56,7 +57,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import android.app.ActivityManager;
import android.app.IApplicationThread;
@@ -1156,6 +1156,34 @@ public class ActivityStackTests extends ActivityTestsBase {
assertThat(result).isEqualTo(taskTop);
}
@Test
public void testCheckBehindFullscreenActivity() {
final ActivityRecord bottomActivity =
new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
final ActivityRecord topActivity =
new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
doReturn(true).when(mStack).shouldBeVisible(any());
assertTrue(mStack.checkBehindFullscreenActivity(bottomActivity,
null /* handleBehindFullscreenActivity */));
assertFalse(mStack.checkBehindFullscreenActivity(topActivity,
null /* handleBehindFullscreenActivity */));
doReturn(false).when(topActivity).occludesParent();
assertFalse(mStack.checkBehindFullscreenActivity(bottomActivity,
null /* handleBehindFullscreenActivity */));
assertFalse(mStack.checkBehindFullscreenActivity(topActivity,
null /* handleBehindFullscreenActivity */));
final ActivityRecord finishingActivity =
new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
finishingActivity.finishing = true;
doCallRealMethod().when(finishingActivity).occludesParent();
assertFalse(mStack.checkBehindFullscreenActivity(bottomActivity,
null /* handleBehindFullscreenActivity */));
assertFalse(mStack.checkBehindFullscreenActivity(topActivity,
null /* handleBehindFullscreenActivity */));
}
@Test
public void testClearUnknownAppVisibilityBehindFullscreenActivity() {
final UnknownAppVisibilityController unknownAppVisibilityController =