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

Commit 9867b517 authored by Garfield Tan's avatar Garfield Tan
Browse files

Use TaskFactory to create ActivityStack.

ActivityStack now can be used as a Task by itself, so we need to make
sure they are of right type.

Also changed the signature of that constructor to make it more natural.

Bug: 150409355
Test: WM smoke tests & TH.
Test: atest TaskRecordTests
Change-Id: Ia6aa8decd0af79e58344442e93bd15ca0e373fc9
parent 755ce9ed
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -556,9 +556,9 @@ class ActivityStack extends Task {
        }
    }

    ActivityStack(DisplayContent display, int id, ActivityStackSupervisor supervisor,
            int activityType, ActivityInfo info, Intent intent) {
        this(supervisor.mService, id, info, intent, null /*voiceSession*/, null /*voiceInteractor*/,
    ActivityStack(ActivityTaskManagerService atmService, int id, int activityType,
            ActivityInfo info, Intent intent) {
        this(atmService, id, info, intent, null /*voiceSession*/, null /*voiceInteractor*/,
                null /*taskDescription*/, null /*stack*/);

        setActivityType(activityType);
+2 −2
Original line number Diff line number Diff line
@@ -5874,8 +5874,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            // Since this stack will be put into a tile, its windowingMode will be inherited.
            windowingMode = WINDOWING_MODE_UNDEFINED;
        }
        final ActivityStack stack = new ActivityStack(this, stackId,
                mRootWindowContainer.mStackSupervisor, activityType, info, intent);
        final ActivityStack stack = (ActivityStack) Task.create(mAtmService, stackId, activityType,
                info, intent);
        addStack(stack, onTop ? POSITION_TOP : POSITION_BOTTOM);
        stack.setWindowingMode(windowingMode, false /* animate */, false /* showRecents */,
                false /* enteringSplitScreenMode */, false /* deferEnsuringVisibility */,
+9 −11
Original line number Diff line number Diff line
@@ -3636,6 +3636,11 @@ class Task extends WindowContainer<WindowContainer> {
        sTaskFactory = factory;
    }

    static Task create(ActivityTaskManagerService service, int taskId, int activityType,
            ActivityInfo info, Intent intent) {
        return getTaskFactory().create(service, taskId, activityType, info, intent);
    }

    static Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
            Intent intent, IVoiceInteractionSession voiceSession,
            IVoiceInteractor voiceInteractor, ActivityStack stack) {
@@ -3643,11 +3648,6 @@ class Task extends WindowContainer<WindowContainer> {
                service, taskId, info, intent, voiceSession, voiceInteractor, stack);
    }

    static Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
            Intent intent, TaskDescription taskDescription, ActivityStack stack) {
        return getTaskFactory().create(service, taskId, info, intent, taskDescription, stack);
    }

    static Task restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor)
            throws IOException, XmlPullParserException {
        return getTaskFactory().restoreFromXml(in, stackSupervisor);
@@ -3659,6 +3659,10 @@ class Task extends WindowContainer<WindowContainer> {
     * {@link #setTaskFactory(TaskFactory)}.
     */
    static class TaskFactory {
        Task create(ActivityTaskManagerService service, int taskId, int activityType,
                ActivityInfo info, Intent intent) {
            return new ActivityStack(service, taskId, activityType, info, intent);
        }

        Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
                Intent intent, IVoiceInteractionSession voiceSession,
@@ -3667,12 +3671,6 @@ class Task extends WindowContainer<WindowContainer> {
                    null /*taskDescription*/, stack);
        }

        Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
                Intent intent, TaskDescription taskDescription, ActivityStack stack) {
            return new ActivityStack(service, taskId, info, intent, null /*voiceSession*/,
                    null /*voiceInteractor*/, taskDescription, stack);
        }

        /**
         * Should only be used when we're restoring {@link Task} from storage.
         */
+13 −10
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ public class TaskRecordTests extends ActivityTestsBase {

    @Before
    public void setUp() throws Exception {
        Task.setTaskFactory(null);
        mParentBounds = new Rect(10 /*left*/, 30 /*top*/, 80 /*right*/, 60 /*bottom*/);
        removeGlobalMinSizeRestriction();
    }
@@ -148,11 +147,16 @@ public class TaskRecordTests extends ActivityTestsBase {
        TestTaskFactory factory = new TestTaskFactory();
        Task.setTaskFactory(factory);

        try {
            assertFalse(factory.mCreated);

        Task.create(null, 0, null, null, null, null);
            Task.create(mService, 0 /*taskId*/, 0 /*activityType*/,
                    new ActivityInfo(), new Intent());

            assertTrue(factory.mCreated);
        } finally {
            Task.setTaskFactory(null);
        }
    }

    @Test
@@ -509,7 +513,7 @@ public class TaskRecordTests extends ActivityTestsBase {
        info.targetActivity = targetClassName;

        final Task task = Task.create(mService, 1 /* taskId */, info, intent,
                null /* taskDescription */, null /*stack*/);
                null /* voiceSession */, null /* voiceInteractor */, null /*stack*/);
        assertEquals("The alias activity component should be saved in task intent.", aliasClassName,
                task.intent.getComponent().getClassName());

@@ -997,17 +1001,16 @@ public class TaskRecordTests extends ActivityTestsBase {
        private boolean mCreated = false;

        @Override
        Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
                Intent intent, IVoiceInteractionSession voiceSession,
                IVoiceInteractor voiceInteractor, ActivityStack stack) {
        Task create(ActivityTaskManagerService service, int taskId, int activityType,
                ActivityInfo info, Intent intent) {
            mCreated = true;
            return null;
        }

        @Override
        Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info,
                Intent intent, ActivityManager.TaskDescription taskDescription,
                ActivityStack stack) {
                Intent intent, IVoiceInteractionSession voiceSession,
                IVoiceInteractor voiceInteractor, ActivityStack stack) {
            mCreated = true;
            return null;
        }