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

Commit 63114cf3 authored by Alex Chau's avatar Alex Chau
Browse files

Split screen via Task menu when grid_only_overview is enabled

- Also change to choose bottom right task for split when grid_only_overview is eanbled, as ordering of tasks changes with grid_only_overview

Fix: 309041108
Fix: 309044300
Test: com.android.wm.shell.flicker.service.splitscreen.platinum.EnterSplitScreenFromOverviewGesturalNavLandscape#enterSplitScreenFromOverview
Test: com.android.wm.shell.flicker.service.splitscreen.platinum.SwitchBetweenSplitPairsGesturalNavLandscape#switchBetweenSplitPairs
Change-Id: I6906ecb4851097aefc027d5fd689e8c2098404dc
parent 8036b830
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -135,20 +135,30 @@ object SplitScreenUtils {
            // second task to split.
            val home = tapl.workspace.switchToOverview()
            ChangeDisplayOrientationRule.setRotation(rotation)
            val isGridOnlyOverviewEnabled = tapl.isGridOnlyOverviewEnabled
            if (isGridOnlyOverviewEnabled) {
                home.currentTask.tapMenu().tapSplitMenuItem()
            } else {
                home.overviewActions.clickSplit()
            }
            val snapshots = device.wait(Until.findObjects(overviewSnapshotSelector), TIMEOUT_MS)
            if (snapshots == null || snapshots.size < 1) {
                error("Fail to find a overview snapshot to split.")
            }

            // Find the second task in the upper right corner in split select mode by sorting
            // 'left' in descending order and 'top' in ascending order.
            // Find the second task in the upper (or bottom for grid only Overview) right corner in
            // split select mode by sorting 'left' in descending order and 'top' in ascending (or
            // descending for grid only Overview) order.
            snapshots.sortWith { t1: UiObject2, t2: UiObject2 ->
                t2.getVisibleBounds().left - t1.getVisibleBounds().left
            }
            snapshots.sortWith { t1: UiObject2, t2: UiObject2 ->
                if (isGridOnlyOverviewEnabled) {
                    t2.getVisibleBounds().top - t1.getVisibleBounds().top
                } else {
                    t1.getVisibleBounds().top - t2.getVisibleBounds().top
                }
            }
            snapshots[0].click()
        } else {
            val rotationCheckEnabled = tapl.getExpectedRotationCheckEnabled()