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

Commit 90e24dcf authored by Louis Chang's avatar Louis Chang
Browse files

Clean up redundant fields in TaskContainer

Also remove a TODO item in the test since the decor surface
can now be created/removed by non-system organizer.

Bug: 293654166
Test: wm presubmit
Change-Id: I5d0a4a316587c8a99f50a4a755010ce5ff8d63a0
parent 3559a202
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -855,7 +855,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        if (!parentInfo.isVisible()) {
            // Only making the TaskContainer invisible and drops the other info, and perform the
            // update when the next time the Task becomes visible.
            taskContainer.setIsVisible(false);
            if (taskContainer.isVisible()) {
                taskContainer.setInvisible();
            }
            return;
        }

@@ -3228,11 +3230,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            @NonNull WindowContainerTransaction wct, @NonNull TaskContainer taskContainer) {
        final DividerPresenter dividerPresenter = mDividerPresenters.get(taskContainer.getTaskId());
        final TaskFragmentParentInfo parentInfo = taskContainer.getTaskFragmentParentInfo();
        if (parentInfo != null) {
        dividerPresenter.updateDivider(
                wct, parentInfo, taskContainer.getTopNonFinishingSplitContainer());
    }
    }

    @Override
    public void onStartDragging(@NonNull Consumer<WindowContainerTransaction> action) {
+24 −35
Original line number Diff line number Diff line
@@ -78,16 +78,7 @@ class TaskContainer {
    private TaskFragmentContainer mAlwaysOnTopOverlayContainer;

    @NonNull
    private final Configuration mConfiguration;

    private int mDisplayId;

    private boolean mIsVisible;

    private boolean mHasDirectActivity;

    @Nullable
    private TaskFragmentParentInfo mTaskFragmentParentInfo;
    private TaskFragmentParentInfo mInfo;

    /**
     * TaskFragments that the organizer has requested to be closed. They should be removed when
@@ -131,12 +122,14 @@ class TaskContainer {
        mTaskId = taskId;
        final TaskProperties taskProperties = TaskProperties
                .getTaskPropertiesFromActivity(activityInTask);
        mConfiguration = taskProperties.getConfiguration();
        mDisplayId = taskProperties.getDisplayId();
        // Note that it is always called when there's a new Activity is started, which implies
        // the host task is visible and has an activity in the task.
        mIsVisible = true;
        mHasDirectActivity = true;
        mInfo = new TaskFragmentParentInfo(
                taskProperties.getConfiguration(),
                taskProperties.getDisplayId(),
                // Note that it is always called when there's a new Activity is started, which
                // implies the host task is visible and has an activity in the task.
                true /* visible */,
                true /* hasDirectActivity */,
                null /* decorSurface */);
    }

    int getTaskId() {
@@ -144,43 +137,39 @@ class TaskContainer {
    }

    int getDisplayId() {
        return mDisplayId;
        return mInfo.getDisplayId();
    }

    boolean isVisible() {
        return mIsVisible;
        return mInfo.isVisible();
    }

    void setIsVisible(boolean visible) {
        mIsVisible = visible;
    void setInvisible() {
        mInfo = new TaskFragmentParentInfo(mInfo.getConfiguration(), mInfo.getDisplayId(),
                false /* visible */, mInfo.hasDirectActivity(), mInfo.getDecorSurface());
    }

    boolean hasDirectActivity() {
        return mHasDirectActivity;
        return mInfo.hasDirectActivity();
    }

    @NonNull
    Rect getBounds() {
        return mConfiguration.windowConfiguration.getBounds();
        return mInfo.getConfiguration().windowConfiguration.getBounds();
    }

    @NonNull
    TaskProperties getTaskProperties() {
        return new TaskProperties(mDisplayId, mConfiguration);
        return new TaskProperties(mInfo.getDisplayId(), mInfo.getConfiguration());
    }

    void updateTaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
        // TODO(b/293654166): cache the TaskFragmentParentInfo and remove these fields.
        mConfiguration.setTo(info.getConfiguration());
        mDisplayId = info.getDisplayId();
        mIsVisible = info.isVisible();
        mHasDirectActivity = info.hasDirectActivity();
        mTaskFragmentParentInfo = info;
        mInfo = info;
    }

    @Nullable
    @NonNull
    TaskFragmentParentInfo getTaskFragmentParentInfo() {
        return mTaskFragmentParentInfo;
        return mInfo;
    }

    /**
@@ -196,8 +185,8 @@ class TaskContainer {

        // If the task properties equals regardless of starting position, don't
        // need to update the container.
        return mConfiguration.diffPublicOnly(configuration) != 0
                || mDisplayId != info.getDisplayId();
        return mInfo.getConfiguration().diffPublicOnly(configuration) != 0
                || mInfo.getDisplayId() != info.getDisplayId();
    }

    /**
@@ -224,7 +213,7 @@ class TaskContainer {
    }

    boolean isInPictureInPicture() {
        return isInPictureInPicture(mConfiguration);
        return isInPictureInPicture(mInfo.getConfiguration());
    }

    private static boolean isInPictureInPicture(@NonNull Configuration configuration) {
@@ -237,7 +226,7 @@ class TaskContainer {

    @WindowingMode
    private int getWindowingMode() {
        return mConfiguration.windowConfiguration.getWindowingMode();
        return mInfo.getConfiguration().windowConfiguration.getWindowingMode();
    }

    /** Whether there is any {@link TaskFragmentContainer} below this Task. */
+0 −7
Original line number Diff line number Diff line
@@ -1884,11 +1884,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
    public void testApplyTransaction_createTaskFragmentDecorSurface() {
        mSetFlagsRule.enableFlags(Flags.FLAG_TASK_FRAGMENT_SYSTEM_ORGANIZER_FLAG);

        // TODO(b/293654166) remove system organizer requirement once security review is cleared.
        mController.unregisterOrganizer(mIOrganizer);
        registerTaskFragmentOrganizer(mIOrganizer, true /* isSystemOrganizer */);
        final Task task = createTask(mDisplayContent);

        final TaskFragment tf = createTaskFragment(task);
        final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
                OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE).build();
@@ -1903,9 +1899,6 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
    public void testApplyTransaction_removeTaskFragmentDecorSurface() {
        mSetFlagsRule.enableFlags(Flags.FLAG_TASK_FRAGMENT_SYSTEM_ORGANIZER_FLAG);

        // TODO(b/293654166) remove system organizer requirement once security review is cleared.
        mController.unregisterOrganizer(mIOrganizer);
        registerTaskFragmentOrganizer(mIOrganizer, true /* isSystemOrganizer */);
        final Task task = createTask(mDisplayContent);
        final TaskFragment tf = createTaskFragment(task);