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

Commit b2a6f7af authored by Chilun's avatar Chilun Committed by Tony Huang
Browse files

Clean up the legacy split screen (3/n)

Clean up legacy split screen related code from TaskFragment and
WindowState.

Bug: 199236198
Test: atest TaskFragmentTest
      atest WindowStateTests
      atest RootTaskTests
Change-Id: I8a6a294598af52c83164b7d396e776f07523a556
parent 943fe3d9
Loading
Loading
Loading
Loading
+0 −68
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
@@ -796,13 +794,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            return TASK_FRAGMENT_VISIBILITY_VISIBLE;
        }

        boolean gotRootSplitScreenFragment = false;
        boolean gotOpaqueSplitScreenPrimary = false;
        boolean gotOpaqueSplitScreenSecondary = false;
        boolean gotTranslucentFullscreen = false;
        boolean gotTranslucentAdjacent = false;
        boolean gotTranslucentSplitScreenPrimary = false;
        boolean gotTranslucentSplitScreenSecondary = false;
        boolean shouldBeVisible = true;

        // This TaskFragment is only considered visible if all its parent TaskFragments are
@@ -821,8 +814,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        }

        final List<TaskFragment> adjacentTaskFragments = new ArrayList<>();
        final int windowingMode = getWindowingMode();
        final boolean isAssistantType = isActivityTypeAssistant();
        for (int i = parent.getChildCount() - 1; i >= 0; --i) {
            final WindowContainer other = parent.getChildAt(i);
            if (other == null) continue;
@@ -870,37 +861,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                }
                // Multi-window TaskFragment that matches parent bounds would occlude other children
                return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
            } else if (otherWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                    && !gotOpaqueSplitScreenPrimary) {
                gotRootSplitScreenFragment = true;
                gotTranslucentSplitScreenPrimary = isTranslucent(other, starting);
                gotOpaqueSplitScreenPrimary = !gotTranslucentSplitScreenPrimary;
                if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                        && gotOpaqueSplitScreenPrimary) {
                    // Can't be visible behind another opaque TaskFragment in split-screen-primary.
                    return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
                }
            } else if (otherWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
                    && !gotOpaqueSplitScreenSecondary) {
                gotRootSplitScreenFragment = true;
                gotTranslucentSplitScreenSecondary = isTranslucent(other, starting);
                gotOpaqueSplitScreenSecondary = !gotTranslucentSplitScreenSecondary;
                if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
                        && gotOpaqueSplitScreenSecondary) {
                    // Can't be visible behind another opaque TaskFragment in split-screen-secondary
                    return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
                }
            }
            if (gotOpaqueSplitScreenPrimary && gotOpaqueSplitScreenSecondary) {
                // Can not be visible if we are in split-screen windowing mode and both halves of
                // the screen are opaque.
                return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
            }
            if (isAssistantType && gotRootSplitScreenFragment) {
                // Assistant TaskFragment can't be visible behind split-screen. In addition to
                // this not making sense, it also works around an issue here we boost the z-order
                // of the assistant window surfaces in window manager whenever it is visible.
                return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
            }

            final TaskFragment otherTaskFrag = other.asTaskFragment();
@@ -926,34 +886,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
        }

        // Handle cases when there can be a translucent split-screen TaskFragment on top.
        switch (windowingMode) {
            case WINDOWING_MODE_FULLSCREEN:
                if (gotTranslucentSplitScreenPrimary || gotTranslucentSplitScreenSecondary) {
                    // At least one of the split-screen TaskFragment that covers this one is
                    // translucent.
                    // When in split mode, home will be reparented to the secondary split while
                    // leaving TaskFragments not supporting split below. Due to
                    // TaskDisplayArea#assignRootTaskOrdering always adjusts home surface layer to
                    // the bottom, this makes sure TaskFragments not in split roots won't occlude
                    // home task unexpectedly.
                    return TASK_FRAGMENT_VISIBILITY_INVISIBLE;
                }
                break;
            case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY:
                if (gotTranslucentSplitScreenPrimary) {
                    // Covered by translucent primary split-screen on top.
                    return TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
                }
                break;
            case WINDOWING_MODE_SPLIT_SCREEN_SECONDARY:
                if (gotTranslucentSplitScreenSecondary) {
                    // Covered by translucent secondary split-screen on top.
                    return TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
                }
                break;
        }

        // Lastly - check if there is a translucent fullscreen TaskFragment on top.
        return gotTranslucentFullscreen
                ? TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT
+0 −11
Original line number Diff line number Diff line
@@ -2928,7 +2928,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        @Override
        public void binderDied() {
            try {
                boolean resetSplitScreenResizing = false;
                synchronized (mWmService.mGlobalLock) {
                    final WindowState win = mWmService
                            .windowForClientLocked(mSession, mClient, false);
@@ -2944,16 +2943,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                        WindowState.this.removeIfPossible();
                    }
                }
                if (resetSplitScreenResizing) {
                    try {
                        // Note: this calls into ActivityManager, so we must *not* hold the window
                        // manager lock while calling this.
                        mWmService.mActivityTaskManager.setSplitScreenResizing(false);
                    } catch (RemoteException e) {
                        // Local call, shouldn't return RemoteException.
                        throw e.rethrowAsRuntimeException();
                    }
                }
            } catch (IllegalArgumentException ex) {
                // This will happen if the window has already been removed.
            }
+2 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import android.platform.test.annotations.Presubmit;
import androidx.test.filters.SmallTest;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -529,6 +530,7 @@ public class RootTaskTests extends WindowTestsBase {

    // TODO(b/199236198): check this is unnecessary or need to migrate after remove legacy split.
    @Test
    @Ignore
    public void testShouldBeVisible_SplitScreen() {
        // task not supporting split should be fullscreen for this test.
        final Task notSupportingSplitTask = createTaskForShouldBeVisibleTest(