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

Commit 387b7e57 authored by wilsonshih's avatar wilsonshih
Browse files

[PB] Skip predictive back if prevous activity has not created

The activities can remain in INITIALIZING state when launched with
startActivities, predictive back should not invoke to those activities
because there must have no snapshot, also make them visible will kick
lifecycle change.

Bug: 345951785
Flag: EXEMPT bugfix
Test: follow issue description
Change-Id: Ib5360c15fc68716236f3c62940971e965b46f21f
parent c92aa737
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;
    }
    }