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

Commit 3cbf0726 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix lost intent extra when starting activity from recents"

parents 4353cd61 2f9acd22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1960,7 +1960,7 @@ public class TaskRecord extends ConfigurationContainer implements TaskWindowCont
        info.stackId = getStackId();
        info.taskId = taskId;
        info.isRunning = getTopActivity() != null;
        info.baseIntent = getBaseIntent();
        info.baseIntent = new Intent(getBaseIntent());
        info.baseActivity = reuseActivitiesReport.base != null
                ? reuseActivitiesReport.base.intent.getComponent()
                : null;
+15 −0
Original line number Diff line number Diff line
@@ -19,9 +19,12 @@ package com.android.server.wm;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;

import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import android.app.ActivityManager;
@@ -92,6 +95,18 @@ public class TaskRecordTests extends ActivityTestsBase {
        assertNotNull(TaskRecord.getTaskRecordFactory());
    }

    /** Ensure we have no chance to modify the original intent. */
    @Test
    public void testCopyBaseIntentForTaskInfo() {
        final TaskRecord task = createTaskRecord(1);
        task.lastTaskDescription = new ActivityManager.TaskDescription();
        final ActivityManager.RecentTaskInfo info = new ActivityManager.RecentTaskInfo();
        task.fillTaskInfo(info, new TaskRecord.TaskActivitiesReport());

        // The intent of info should be a copy so assert that they are different instances.
        assertThat(info.baseIntent, not(sameInstance(task.getBaseIntent())));
    }

    @Test
    public void testCreateTestRecordUsingCustomizedFactory() throws Exception {
        TestTaskRecordFactory factory = new TestTaskRecordFactory();