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

Commit 2c227e94 authored by wilsonshih's avatar wilsonshih Committed by Android Build Coastguard Worker
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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:387b7e5765bcac8c57c55353616409ec55859d6a)
Merged-In: Ib5360c15fc68716236f3c62940971e965b46f21f
Change-Id: Ib5360c15fc68716236f3c62940971e965b46f21f
parent 902f6c5b
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -252,7 +252,8 @@ class BackNavigationController {
                // skip if one of participant activity is translucent
                backType = BackNavigationInfo.TYPE_CALLBACK;
            } 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
                    final WindowContainer parent = currentActivity.getParent();
                    final boolean canCustomize = parent != null
@@ -549,6 +550,17 @@ class BackNavigationController {
        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() {
        return mAnimationHandler.mComposed || mNavigationMonitor.isMonitorForRemote();
    }
+3 −0
Original line number 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.spyOn;
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.assertWithMessage;
@@ -245,6 +246,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        assertTrue("Animation scheduled", backNavigationInfo.isPrepareRemoteAnimation());

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