Merge "Invoke the occluding callback only if the activity is occluded" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
156bf9d3c2
@@ -382,6 +382,7 @@ class ActivityStack extends Task {
|
||||
return mBehindFullscreenActivity;
|
||||
}
|
||||
|
||||
/** Returns {@code true} to stop the outer loop and indicate the result is computed. */
|
||||
private boolean processActivity(ActivityRecord r, ActivityRecord topActivity) {
|
||||
if (mAboveTop) {
|
||||
if (r == topActivity) {
|
||||
@@ -397,7 +398,10 @@ class ActivityStack extends Task {
|
||||
}
|
||||
|
||||
if (mHandlingOccluded) {
|
||||
mHandleBehindFullscreenActivity.accept(r);
|
||||
// Iterating through all occluded activities.
|
||||
if (mBehindFullscreenActivity) {
|
||||
mHandleBehindFullscreenActivity.accept(r);
|
||||
}
|
||||
} else if (r == mToCheck) {
|
||||
return true;
|
||||
} else if (mBehindFullscreenActivity) {
|
||||
|
||||
@@ -76,6 +76,9 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Tests for the {@link ActivityStack} class.
|
||||
*
|
||||
@@ -1327,6 +1330,8 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
|
||||
@Test
|
||||
public void testCheckBehindFullscreenActivity() {
|
||||
final ArrayList<ActivityRecord> occludedActivities = new ArrayList<>();
|
||||
final Consumer<ActivityRecord> handleBehindFullscreenActivity = occludedActivities::add;
|
||||
final ActivityRecord bottomActivity =
|
||||
new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
|
||||
final ActivityRecord topActivity =
|
||||
@@ -1337,12 +1342,21 @@ public class ActivityStackTests extends ActivityTestsBase {
|
||||
assertFalse(mStack.checkBehindFullscreenActivity(topActivity,
|
||||
null /* handleBehindFullscreenActivity */));
|
||||
|
||||
// Top activity occludes bottom activity.
|
||||
mStack.checkBehindFullscreenActivity(null /* toCheck */, handleBehindFullscreenActivity);
|
||||
assertThat(occludedActivities).containsExactly(bottomActivity);
|
||||
|
||||
doReturn(false).when(topActivity).occludesParent();
|
||||
assertFalse(mStack.checkBehindFullscreenActivity(bottomActivity,
|
||||
null /* handleBehindFullscreenActivity */));
|
||||
assertFalse(mStack.checkBehindFullscreenActivity(topActivity,
|
||||
null /* handleBehindFullscreenActivity */));
|
||||
|
||||
occludedActivities.clear();
|
||||
// Top activity doesn't occlude parent, so the bottom activity is not occluded.
|
||||
mStack.checkBehindFullscreenActivity(null /* toCheck */, handleBehindFullscreenActivity);
|
||||
assertThat(occludedActivities).isEmpty();
|
||||
|
||||
final ActivityRecord finishingActivity =
|
||||
new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
|
||||
finishingActivity.finishing = true;
|
||||
|
||||
Reference in New Issue
Block a user