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

Commit 3579b63c authored by Jiaming Liu's avatar Jiaming Liu Committed by Android (Google) Code Review
Browse files

Merge "Fix placeholder launch with AvoidMoveToFront flag" into main

parents 4dc14489 45974dd3
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -2314,15 +2314,12 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
    @GuardedBy("mLock")
    @Nullable
    Bundle getPlaceholderOptions(@NonNull Activity primaryActivity, boolean isOnCreated) {
        // Setting avoid move to front will also skip the animation. We only want to do that when
        // the Task is currently in background.
        // Check if the primary is resumed or if this is called when the primary is onCreated
        // (not resumed yet).
        if (isOnCreated || primaryActivity.isResumed()) {
            // Only set trigger type if the launch happens in foreground.
            mTransactionManager.getCurrentTransactionRecord()
                    .setOriginType(TASK_FRAGMENT_TRANSIT_OPEN);
            return null;
        }
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setAvoidMoveToFront();
+24 −18
Original line number Diff line number Diff line
@@ -166,6 +166,8 @@ public class SplitControllerTest {
    private List<SplitInfo> mSplitInfos;
    private TransactionManager mTransactionManager;
    private ActivityThread mCurrentActivityThread;
    private final ArgumentCaptor<Bundle> mBundleArgumentCaptor =
            ArgumentCaptor.forClass(Bundle.class);

    @Before
    public void setUp() {
@@ -685,9 +687,13 @@ public class SplitControllerTest {
                false /* isOnReparent */);

        assertTrue(result);
        verify(mSplitPresenter).startActivityToSide(mTransaction, mActivity, PLACEHOLDER_INTENT,
                mSplitController.getPlaceholderOptions(mActivity, true /* isOnCreated */),
                placeholderRule, SPLIT_ATTRIBUTES, true /* isPlaceholder */);
        verify(mSplitPresenter).startActivityToSide(eq(mTransaction), eq(mActivity),
                eq(PLACEHOLDER_INTENT), mBundleArgumentCaptor.capture(),
                eq(placeholderRule), eq(SPLIT_ATTRIBUTES), eq(true) /* isPlaceholder */);

        final ActivityOptions activityOptions =
                new ActivityOptions(mBundleArgumentCaptor.getValue());
        assertTrue(activityOptions.getAvoidMoveToFront());
    }

    @Test
@@ -720,9 +726,13 @@ public class SplitControllerTest {
                false /* isOnReparent */);

        assertTrue(result);
        verify(mSplitPresenter).startActivityToSide(mTransaction, mActivity, PLACEHOLDER_INTENT,
                mSplitController.getPlaceholderOptions(mActivity, true /* isOnCreated */),
                placeholderRule, SPLIT_ATTRIBUTES, true /* isPlaceholder */);
        verify(mSplitPresenter).startActivityToSide(eq(mTransaction), eq(mActivity),
                eq(PLACEHOLDER_INTENT), mBundleArgumentCaptor.capture(),
                eq(placeholderRule), eq(SPLIT_ATTRIBUTES), eq(true) /* isPlaceholder */);

        final ActivityOptions activityOptions =
                new ActivityOptions(mBundleArgumentCaptor.getValue());
        assertTrue(activityOptions.getAvoidMoveToFront());
    }

    @Test
@@ -755,9 +765,13 @@ public class SplitControllerTest {
                false /* isOnReparent */);

        assertTrue(result);
        verify(mSplitPresenter).startActivityToSide(mTransaction, mActivity, PLACEHOLDER_INTENT,
                mSplitController.getPlaceholderOptions(mActivity, true /* isOnCreated */),
                placeholderRule, SPLIT_ATTRIBUTES, true /* isPlaceholder */);
        verify(mSplitPresenter).startActivityToSide(eq(mTransaction), eq(mActivity),
                eq(PLACEHOLDER_INTENT), mBundleArgumentCaptor.capture(),
                eq(placeholderRule), eq(SPLIT_ATTRIBUTES), eq(true) /* isPlaceholder */);

        final ActivityOptions activityOptions =
                new ActivityOptions(mBundleArgumentCaptor.getValue());
        assertTrue(activityOptions.getAvoidMoveToFront());
    }

    @Test
@@ -1065,16 +1079,8 @@ public class SplitControllerTest {
    public void testGetPlaceholderOptions() {
        // Setup to make sure a transaction record is started.
        mTransactionManager.startNewTransaction();
        doReturn(true).when(mActivity).isResumed();

        assertNull(mSplitController.getPlaceholderOptions(mActivity, false /* isOnCreated */));

        doReturn(false).when(mActivity).isResumed();

        assertNull(mSplitController.getPlaceholderOptions(mActivity, true /* isOnCreated */));

        // Launch placeholder without moving the Task to front if the Task is now in background (not
        // resumed or onCreated).
        // Launch placeholder without moving the Task to front
        final Bundle options = mSplitController.getPlaceholderOptions(mActivity,
                false /* isOnCreated */);