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

Commit ff2b2375 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "[PB] Skip predictive back if prevous activity has not created" into main

parents 2257abae 387b7e57
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -252,7 +252,8 @@ class BackNavigationController {
                // skip if one of participant activity is translucent
                // skip if one of participant activity is translucent
                backType = BackNavigationInfo.TYPE_CALLBACK;
                backType = BackNavigationInfo.TYPE_CALLBACK;
            } else if (prevActivities.size() > 0) {
            } else if (prevActivities.size() > 0) {
                if (!isOccluded || isAllActivitiesCanShowWhenLocked(prevActivities)) {
                if ((!isOccluded || isAllActivitiesCanShowWhenLocked(prevActivities))
                        && isAllActivitiesCreated(prevActivities)) {
                    // We have another Activity in the same currentTask to go to
                    // We have another Activity in the same currentTask to go to
                    final WindowContainer parent = currentActivity.getParent();
                    final WindowContainer parent = currentActivity.getParent();
                    final boolean canCustomize = parent != null
                    final boolean canCustomize = parent != null
@@ -549,6 +550,17 @@ class BackNavigationController {
        return !prevActivities.isEmpty();
        return !prevActivities.isEmpty();
    }
    }


    private static boolean isAllActivitiesCreated(
            @NonNull ArrayList<ActivityRecord> prevActivities) {
        for (int i = prevActivities.size() - 1; i >= 0; --i) {
            final ActivityRecord check = prevActivities.get(i);
            if (check.isState(ActivityRecord.State.INITIALIZING)) {
                return false;
            }
        }
        return !prevActivities.isEmpty();
    }

    boolean isMonitoringTransition() {
    boolean isMonitoringTransition() {
        return mAnimationHandler.mComposed || mNavigationMonitor.isMonitorForRemote();
        return mAnimationHandler.mComposed || mNavigationMonitor.isMonitorForRemote();
    }
    }
+3 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityRecord.State.STOPPED;


import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -245,6 +246,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        assertTrue("Animation scheduled", backNavigationInfo.isPrepareRemoteAnimation());
        assertTrue("Animation scheduled", backNavigationInfo.isPrepareRemoteAnimation());


        // reset drawing status
        // reset drawing status
        testCase.recordBack.setState(STOPPED, "stopped");
        backNavigationInfo.onBackNavigationFinished(false);
        backNavigationInfo.onBackNavigationFinished(false);
        mBackNavigationController.clearBackAnimations();
        mBackNavigationController.clearBackAnimations();
        makeWindowVisibleAndDrawn(testCase.recordFront.findMainWindow());
        makeWindowVisibleAndDrawn(testCase.recordFront.findMainWindow());
@@ -937,6 +939,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        testCase.recordFront = record2;
        testCase.recordFront = record2;
        testCase.windowBack = window1;
        testCase.windowBack = window1;
        testCase.windowFront = window2;
        testCase.windowFront = window2;
        record1.setState(STOPPED, "stopped");
        return testCase;
        return testCase;
    }
    }