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

Commit 973f4bde authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Transfer launch cookie when finishing activity" into tm-dev am: c177d232

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17104885

Change-Id: I2bd3f676fc799202eb43b4421d62a684866586a1
parents 97f66a77 c177d232
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3643,6 +3643,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }
        finishing = true;

        // Transfer the launch cookie to the next running activity above this in the same task.
        if (mLaunchCookie != null && mState != RESUMED && task != null && !task.mInRemoveTask
                && !task.isClearingToReuseTask()) {
            final ActivityRecord nextCookieTarget = task.getActivity(
                    // Intend to only associate the same app by checking uid.
                    r -> r.mLaunchCookie == null && !r.finishing && r.isUid(getUid()),
                    this, false /* includeBoundary */, false /* traverseTopToBottom */);
            if (nextCookieTarget != null) {
                nextCookieTarget.mLaunchCookie = mLaunchCookie;
                mLaunchCookie = null;
            }
        }

        final TaskFragment taskFragment = getTaskFragment();
        if (taskFragment != null) {
            final Task task = taskFragment.getTask();
+13 −0
Original line number Diff line number Diff line
@@ -2217,6 +2217,19 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertTrue(activity.pictureInPictureArgs.isLaunchIntoPip());
    }

    @Test
    public void testTransferLaunchCookieWhenFinishing() {
        final ActivityRecord activity1 = createActivityWithTask();
        final Binder launchCookie = new Binder();
        activity1.mLaunchCookie = launchCookie;
        final ActivityRecord activity2 = createActivityRecord(activity1.getTask());
        activity1.setState(PAUSED, "test");
        activity1.makeFinishingLocked();

        assertEquals(launchCookie, activity2.mLaunchCookie);
        assertNull(activity1.mLaunchCookie);
    }

    private void verifyProcessInfoUpdate(ActivityRecord activity, State state,
            boolean shouldUpdate, boolean activityChange) {
        reset(activity.app);