Loading services/core/java/com/android/server/wm/TaskRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading
services/core/java/com/android/server/wm/TaskRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading