Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactory.kt +4 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.window.TransitionInfo import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.shared.TransitionUtil.isClosingType import javax.inject.Inject /** Loading @@ -30,12 +31,13 @@ class SkipLetterboxLifecycleEventFactory @Inject constructor( private val desksOrganizer: DesksOrganizer ) : LetterboxLifecycleEventFactory { // A Desktop Windowing transition should be ignored because not related to Letterboxing. This // A root task desk transition should be ignored because it's not related to Letterboxing. This // prevents any operations on the Letterbox Surfaces (e.g. resize) which can cause unwanted // behaviour (e.g. Adding Letterbox Surfaces on the wrong Task surface). // TODO(b/421188466): Improve heuristics for Activities dealing with Camera. // We also ignore closing Changes. override fun canHandle(change: TransitionInfo.Change): Boolean = desksOrganizer.isDeskChange(change) isClosingType(change.mode) || desksOrganizer.isDeskChange(change) // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // it returns an empty LetterboxLifecycleEvent to basically ignore the Change. Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactoryTest.kt +29 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.testing.AndroidTestingRunner import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer Loading @@ -26,7 +28,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock /** Loading @@ -40,11 +41,31 @@ import org.mockito.kotlin.mock class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { @Test fun `Factory is active when Change is a DesksOrganizer change`() { fun `Factory is active when Change is a Closing one`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_CLOSE } validateCanHandle { canHandle -> assert(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) } } } } @Test fun `Factory is active when Change is not closing and a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { // Empty Change mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = true) validateCanHandle { canHandle -> Loading @@ -58,11 +79,14 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } @Test fun `Factory is skipped when Change is NOT a DesksOrganizer change`() { fun `Factory is skipped when Change is not closing one and is NOT a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { // Empty Change mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = false) validateCanHandle { canHandle -> Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/util/CommonInputBuilders.kt +4 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,11 @@ import android.content.ComponentName import android.graphics.Point import android.graphics.Rect import android.view.SurfaceControl import android.view.WindowManager.TRANSIT_NONE import android.window.ActivityTransitionInfo import android.window.AppCompatTransitionInfo import android.window.TransitionInfo.Change import android.window.TransitionInfo.TransitionMode import android.window.WindowContainerToken import org.mockito.kotlin.mock Loading Loading @@ -59,6 +61,7 @@ class ChangeTestInputBuilder : TestInputBuilder<Change> { private val inputParams = InputParams() var endAbsBounds: Rect? = null var endRelOffset: Point? = null @TransitionMode var mode: Int = TRANSIT_NONE data class InputParams( var token: WindowContainerToken = mock<WindowContainerToken>(), Loading Loading @@ -109,6 +112,7 @@ class ChangeTestInputBuilder : TestInputBuilder<Change> { inputParams.token, inputParams.leash ).apply { mode = this@ChangeTestInputBuilder.mode taskInfo = inputParams.taskInfo this@ChangeTestInputBuilder.endAbsBounds?.let { this@apply.endAbsBounds.set(endAbsBounds) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactory.kt +4 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.window.TransitionInfo import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.shared.TransitionUtil.isClosingType import javax.inject.Inject /** Loading @@ -30,12 +31,13 @@ class SkipLetterboxLifecycleEventFactory @Inject constructor( private val desksOrganizer: DesksOrganizer ) : LetterboxLifecycleEventFactory { // A Desktop Windowing transition should be ignored because not related to Letterboxing. This // A root task desk transition should be ignored because it's not related to Letterboxing. This // prevents any operations on the Letterbox Surfaces (e.g. resize) which can cause unwanted // behaviour (e.g. Adding Letterbox Surfaces on the wrong Task surface). // TODO(b/421188466): Improve heuristics for Activities dealing with Camera. // We also ignore closing Changes. override fun canHandle(change: TransitionInfo.Change): Boolean = desksOrganizer.isDeskChange(change) isClosingType(change.mode) || desksOrganizer.isDeskChange(change) // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // it returns an empty LetterboxLifecycleEvent to basically ignore the Change. Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactoryTest.kt +29 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.testing.AndroidTestingRunner import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer Loading @@ -26,7 +28,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock /** Loading @@ -40,11 +41,31 @@ import org.mockito.kotlin.mock class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { @Test fun `Factory is active when Change is a DesksOrganizer change`() { fun `Factory is active when Change is a Closing one`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_CLOSE } validateCanHandle { canHandle -> assert(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) } } } } @Test fun `Factory is active when Change is not closing and a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { // Empty Change mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = true) validateCanHandle { canHandle -> Loading @@ -58,11 +79,14 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } @Test fun `Factory is skipped when Change is NOT a DesksOrganizer change`() { fun `Factory is skipped when Change is not closing one and is NOT a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { // Empty Change mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = false) validateCanHandle { canHandle -> Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/util/CommonInputBuilders.kt +4 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,11 @@ import android.content.ComponentName import android.graphics.Point import android.graphics.Rect import android.view.SurfaceControl import android.view.WindowManager.TRANSIT_NONE import android.window.ActivityTransitionInfo import android.window.AppCompatTransitionInfo import android.window.TransitionInfo.Change import android.window.TransitionInfo.TransitionMode import android.window.WindowContainerToken import org.mockito.kotlin.mock Loading Loading @@ -59,6 +61,7 @@ class ChangeTestInputBuilder : TestInputBuilder<Change> { private val inputParams = InputParams() var endAbsBounds: Rect? = null var endRelOffset: Point? = null @TransitionMode var mode: Int = TRANSIT_NONE data class InputParams( var token: WindowContainerToken = mock<WindowContainerToken>(), Loading Loading @@ -109,6 +112,7 @@ class ChangeTestInputBuilder : TestInputBuilder<Change> { inputParams.token, inputParams.leash ).apply { mode = this@ChangeTestInputBuilder.mode taskInfo = inputParams.taskInfo this@ChangeTestInputBuilder.endAbsBounds?.let { this@apply.endAbsBounds.set(endAbsBounds) Loading