Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b47cd2e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Invoke the occluding callback only if the activity is occluded" into...

Merge "Invoke the occluding callback only if the activity is occluded" into rvc-dev am: 156bf9d3 am: 321f0605 am: 8866529e

Change-Id: I75ca3b16732b4a90285d1035f3adb6ca61cb9786
parents e1e0732e 8866529e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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) {
                // Iterating through all occluded activities.
                if (mBehindFullscreenActivity) {
                    mHandleBehindFullscreenActivity.accept(r);
                }
            } else if (r == mToCheck) {
                return true;
            } else if (mBehindFullscreenActivity) {
+14 −0
Original line number Diff line number Diff line
@@ -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;