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

Commit 4ec08f85 authored by Winson Chung's avatar Winson Chung
Browse files

Skip evicting children in certain non-drop cases as well

- When splitting with an existing split pair task from an app icon
  menu we also need to avoid evicting the children to prevent the same
  race between start activity and eviction in ag/25565608

Fixes: 309905087
Test: Launch a split pair, Open a new fullscreen app, Use the taskbar
      to split with one of the previously paired tasks
Change-Id: I76808dfad48951d443593c6d3d284827ba7f2e00
parent 84427ae9
Loading
Loading
Loading
Loading
+25 −1
Original line number Original line Diff line number Diff line
@@ -223,6 +223,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    private boolean mExitSplitScreenOnHide;
    private boolean mExitSplitScreenOnHide;
    private boolean mIsDividerRemoteAnimating;
    private boolean mIsDividerRemoteAnimating;
    private boolean mIsDropEntering;
    private boolean mIsDropEntering;
    private boolean mSkipEvictingMainStageChildren;
    private boolean mIsExiting;
    private boolean mIsExiting;
    private boolean mIsRootTranslucent;
    private boolean mIsRootTranslucent;
    @VisibleForTesting
    @VisibleForTesting
@@ -468,6 +469,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        }
        }
        // Due to drag already pip task entering split by this method so need to reset flag here.
        // Due to drag already pip task entering split by this method so need to reset flag here.
        mIsDropEntering = false;
        mIsDropEntering = false;
        mSkipEvictingMainStageChildren = false;
        return true;
        return true;
    }
    }


@@ -572,6 +574,15 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            return;
            return;
        }
        }


        // Don't evict the main stage children as this can race and happen after the activity is
        // started into that stage
        if (!isSplitScreenVisible()) {
            mSkipEvictingMainStageChildren = true;
            // Starting the split task without evicting children will bring the single root task
            // container forward, so ensure that we hide the divider before we start animate it
            setDividerVisibility(false, null);
        }

        // If split screen is not activated, we're expecting to open a pair of apps to split.
        // If split screen is not activated, we're expecting to open a pair of apps to split.
        final int extraTransitType = mMainStage.isActive()
        final int extraTransitType = mMainStage.isActive()
                ? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
                ? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
@@ -600,6 +611,15 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            return;
            return;
        }
        }


        // Don't evict the main stage children as this can race and happen after the activity is
        // started into that stage
        if (!isSplitScreenVisible()) {
            mSkipEvictingMainStageChildren = true;
            // Starting the split task without evicting children will bring the single root task
            // container forward, so ensure that we hide the divider before we start animate it
            setDividerVisibility(false, null);
        }

        // If split screen is not activated, we're expecting to open a pair of apps to split.
        // If split screen is not activated, we're expecting to open a pair of apps to split.
        final int extraTransitType = mMainStage.isActive()
        final int extraTransitType = mMainStage.isActive()
                ? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
                ? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
@@ -1618,7 +1638,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            // Ensure to evict old splitting tasks because the new split pair might be composed by
            // Ensure to evict old splitting tasks because the new split pair might be composed by
            // one of the splitting tasks, evicting the task when finishing entering transition
            // one of the splitting tasks, evicting the task when finishing entering transition
            // won't guarantee to put the task to the indicated new position.
            // won't guarantee to put the task to the indicated new position.
            if (!mIsDropEntering) {
            if (!mSkipEvictingMainStageChildren) {
                mMainStage.evictAllChildren(wct);
                mMainStage.evictAllChildren(wct);
            }
            }
            mMainStage.reparentTopTask(wct);
            mMainStage.reparentTopTask(wct);
@@ -1680,6 +1700,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        finishT.show(mRootTaskLeash);
        finishT.show(mRootTaskLeash);
        setSplitsVisible(true);
        setSplitsVisible(true);
        mIsDropEntering = false;
        mIsDropEntering = false;
        mSkipEvictingMainStageChildren = false;
        mSplitRequest = null;
        mSplitRequest = null;
        updateRecentTasksSplitPair();
        updateRecentTasksSplitPair();
        if (!mLogger.hasStartedSession()) {
        if (!mLogger.hasStartedSession()) {
@@ -1929,6 +1950,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                if (mIsDropEntering) {
                if (mIsDropEntering) {
                    updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
                    updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
                    mIsDropEntering = false;
                    mIsDropEntering = false;
                    mSkipEvictingMainStageChildren = false;
                } else {
                } else {
                    mShowDecorImmediately = true;
                    mShowDecorImmediately = true;
                    mSplitLayout.flingDividerToCenter();
                    mSplitLayout.flingDividerToCenter();
@@ -2123,6 +2145,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                if (mIsDropEntering) {
                if (mIsDropEntering) {
                    updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
                    updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
                    mIsDropEntering = false;
                    mIsDropEntering = false;
                    mSkipEvictingMainStageChildren = false;
                } else {
                } else {
                    mShowDecorImmediately = true;
                    mShowDecorImmediately = true;
                    mSplitLayout.flingDividerToCenter();
                    mSplitLayout.flingDividerToCenter();
@@ -3245,6 +3268,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    public void onDroppedToSplit(@SplitPosition int position, InstanceId dragSessionId) {
    public void onDroppedToSplit(@SplitPosition int position, InstanceId dragSessionId) {
        if (!isSplitScreenVisible()) {
        if (!isSplitScreenVisible()) {
            mIsDropEntering = true;
            mIsDropEntering = true;
            mSkipEvictingMainStageChildren = true;
        }
        }
        if (!isSplitScreenVisible() && !ENABLE_SHELL_TRANSITIONS) {
        if (!isSplitScreenVisible() && !ENABLE_SHELL_TRANSITIONS) {
            // If split running background, exit split first.
            // If split running background, exit split first.