Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactory.kt +2 −10 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.window.TransitionInfo import android.window.TransitionInfo import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.shared.TransitionUtil.isClosingType import com.android.wm.shell.shared.TransitionUtil.isClosingType import javax.inject.Inject import javax.inject.Inject Loading @@ -27,17 +26,10 @@ import javax.inject.Inject * if not related to Letterboxing. * if not related to Letterboxing. */ */ @WMSingleton @WMSingleton class SkipLetterboxLifecycleEventFactory @Inject constructor( class SkipLetterboxLifecycleEventFactory @Inject constructor() : LetterboxLifecycleEventFactory { private val desksOrganizer: DesksOrganizer ) : LetterboxLifecycleEventFactory { // 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. // We also ignore closing Changes. override fun canHandle(change: TransitionInfo.Change): Boolean = override fun canHandle(change: TransitionInfo.Change): Boolean = isClosingType(change.mode) isClosingType(change.mode) || desksOrganizer.isDeskChange(change) // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // it returns an empty LetterboxLifecycleEvent to basically ignore the 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 +2 −34 Original line number Original line Diff line number Diff line Loading @@ -21,14 +21,10 @@ import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_OPEN import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import java.util.function.Consumer import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock /** /** * Tests for [SkipLetterboxLifecycleEventFactory]. * Tests for [SkipLetterboxLifecycleEventFactory]. Loading Loading @@ -58,7 +54,7 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } @Test @Test fun `Factory is active when Change is not closing and a DesksOrganizer change`() { fun `Factory is skipped when Change is not closing one`() { runTestScenario { r -> runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { inputChange { Loading @@ -67,28 +63,6 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { taskId = 10 taskId = 10 } } } } r.configureDesksOrganizer(isDeskChange = true) validateCanHandle { canHandle -> assert(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) } } } } @Test fun `Factory is skipped when Change is not closing one and is NOT a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = false) validateCanHandle { canHandle -> validateCanHandle { canHandle -> assert(!canHandle) assert(!canHandle) } } Loading @@ -113,14 +87,8 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { */ */ class DisableLetterboxLifecycleEventFactoryRobotTest { class DisableLetterboxLifecycleEventFactoryRobotTest { private val desksOrganizer: DesksOrganizer = mock<DesksOrganizer>() fun configureDesksOrganizer(isDeskChange: Boolean) { doReturn(isDeskChange).`when`(desksOrganizer).isDeskChange(any()) } fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { SkipLetterboxLifecycleEventFactory(desksOrganizer) SkipLetterboxLifecycleEventFactory() } } } } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactory.kt +2 −10 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.window.TransitionInfo import android.window.TransitionInfo import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.dagger.WMSingleton import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.shared.TransitionUtil.isClosingType import com.android.wm.shell.shared.TransitionUtil.isClosingType import javax.inject.Inject import javax.inject.Inject Loading @@ -27,17 +26,10 @@ import javax.inject.Inject * if not related to Letterboxing. * if not related to Letterboxing. */ */ @WMSingleton @WMSingleton class SkipLetterboxLifecycleEventFactory @Inject constructor( class SkipLetterboxLifecycleEventFactory @Inject constructor() : LetterboxLifecycleEventFactory { private val desksOrganizer: DesksOrganizer ) : LetterboxLifecycleEventFactory { // 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. // We also ignore closing Changes. override fun canHandle(change: TransitionInfo.Change): Boolean = override fun canHandle(change: TransitionInfo.Change): Boolean = isClosingType(change.mode) isClosingType(change.mode) || desksOrganizer.isDeskChange(change) // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // Although this LetterboxLifecycleEventFactory is able to handle the specific Change // it returns an empty LetterboxLifecycleEvent to basically ignore the 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 +2 −34 Original line number Original line Diff line number Diff line Loading @@ -21,14 +21,10 @@ import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_OPEN import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import java.util.function.Consumer import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock /** /** * Tests for [SkipLetterboxLifecycleEventFactory]. * Tests for [SkipLetterboxLifecycleEventFactory]. Loading Loading @@ -58,7 +54,7 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } @Test @Test fun `Factory is active when Change is not closing and a DesksOrganizer change`() { fun `Factory is skipped when Change is not closing one`() { runTestScenario { r -> runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { inputChange { Loading @@ -67,28 +63,6 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { taskId = 10 taskId = 10 } } } } r.configureDesksOrganizer(isDeskChange = true) validateCanHandle { canHandle -> assert(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) } } } } @Test fun `Factory is skipped when Change is not closing one and is NOT a DesksOrganizer change`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_OPEN activityTransitionInfo { taskId = 10 } } r.configureDesksOrganizer(isDeskChange = false) validateCanHandle { canHandle -> validateCanHandle { canHandle -> assert(!canHandle) assert(!canHandle) } } Loading @@ -113,14 +87,8 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { */ */ class DisableLetterboxLifecycleEventFactoryRobotTest { class DisableLetterboxLifecycleEventFactoryRobotTest { private val desksOrganizer: DesksOrganizer = mock<DesksOrganizer>() fun configureDesksOrganizer(isDeskChange: Boolean) { doReturn(isDeskChange).`when`(desksOrganizer).isDeskChange(any()) } fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { SkipLetterboxLifecycleEventFactory(desksOrganizer) SkipLetterboxLifecycleEventFactory() } } } } } }