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

This commit is contained in:
Riddle Hsu
2022-03-08 05:39:24 +00:00
committed by Android (Google) Code Review
2 changed files with 27 additions and 0 deletions

View File

@@ -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();

View File

@@ -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);