Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/LetterboxControllerStrategy.kt +10 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.compatui.letterbox import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.MULTIPLE_SURFACES import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.SINGLE_SURFACE import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEvent import com.android.wm.shell.dagger.WMSingleton import javax.inject.Inject Loading @@ -36,7 +37,7 @@ class LetterboxControllerStrategy @Inject constructor( @Volatile private var currentMode: LetterboxMode = SINGLE_SURFACE fun configureLetterboxMode() { fun configureLetterboxMode(event: LetterboxLifecycleEvent) { // TODO(b/377875146): Define criteria for switching between [LetterboxMode]s. // At the moment, we use the presence of rounded corners to understand if to use a single // surface or multiple surfaces for the letterbox areas. This rule will change when Loading @@ -44,7 +45,10 @@ class LetterboxControllerStrategy @Inject constructor( // [MULTIPLE_SURFACES] option. // The chosen strategy will depend on performance considerations, // including surface memory usage and the impact of the rounded corners solution. currentMode = if (letterboxConfiguration.isLetterboxActivityCornersRounded()) { // In case of Bubble we always use a single surface as simple optimisation for no // transparent activities. currentMode = if (event.isBubble || letterboxConfiguration.isLetterboxActivityCornersRounded()) { SINGLE_SURFACE } else { MULTIPLE_SURFACES Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -40,8 +40,8 @@ class LetterboxLifecycleControllerImpl( with(letterboxController) { if (event.letterboxBounds != null) { // In this case the top Activity is letterboxed. letterboxModeStrategy.configureLetterboxMode() event.taskLeash?.let { taskLeash -> letterboxModeStrategy.configureLetterboxMode(event) createLetterboxSurface( key, startTransaction, Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ data class LetterboxLifecycleEvent( val letterboxBounds: Rect? = null, val containerToken: WindowContainerToken? = null, val taskLeash: SurfaceControl? = null, val isBubble: Boolean = false ) /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt +2 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ class TaskInfoLetterboxLifecycleEventFactory : LetterboxLifecycleEventFactory { taskBounds = taskBounds, letterboxBounds = letterboxBounds, containerToken = ti.token, taskLeash = change.leash taskLeash = change.leash, isBubble = ti.isAppBubble ) } return null Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/LetterboxControllerStrategyTest.kt +23 −4 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package com.android.wm.shell.compatui.letterbox import android.content.Context import android.graphics.Rect import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.MULTIPLE_SURFACES import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.SINGLE_SURFACE import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEvent import java.util.function.Consumer import kotlin.test.assertEquals import org.junit.Test Loading @@ -38,7 +40,7 @@ import org.junit.runner.RunWith class LetterboxControllerStrategyTest : ShellTestCase() { @Test fun `LetterboxMode is MULTIPLE_SURFACES with rounded corners`() { fun `LetterboxMode is SINGLE_SURFACE with rounded corners`() { runTestScenario { r -> r.configureRoundedCornerRadius(true) r.configureLetterboxMode() Loading @@ -46,6 +48,19 @@ class LetterboxControllerStrategyTest : ShellTestCase() { } } @Test fun `LetterboxMode is SINGLE_SURFACE with Bubble Events`() { runTestScenario { r -> r.configureRoundedCornerRadius(true) r.configureLetterboxMode( r.SIMPLE_TEST_EVENT.copy( isBubble = true ) ) r.checkLetterboxModeIsSingle() } } @Test fun `LetterboxMode is MULTIPLE_SURFACES with no rounded corners`() { runTestScenario { r -> Loading @@ -63,7 +78,7 @@ class LetterboxControllerStrategyTest : ShellTestCase() { consumer.accept(robot) } class LetterboxStrategyRobotTest(val ctx: Context) { class LetterboxStrategyRobotTest(ctx: Context) { companion object { @JvmStatic Loading @@ -72,6 +87,10 @@ class LetterboxControllerStrategyTest : ShellTestCase() { private val ROUNDED_CORNERS_FALSE = 0 } val SIMPLE_TEST_EVENT = LetterboxLifecycleEvent( taskBounds = Rect() ) private val letterboxConfiguration: LetterboxConfiguration private val letterboxStrategy: LetterboxControllerStrategy Loading @@ -86,8 +105,8 @@ class LetterboxControllerStrategyTest : ShellTestCase() { ) } fun configureLetterboxMode() { letterboxStrategy.configureLetterboxMode() fun configureLetterboxMode(event: LetterboxLifecycleEvent = SIMPLE_TEST_EVENT) { letterboxStrategy.configureLetterboxMode(event) } fun checkLetterboxModeIsSingle(expected: Boolean = true) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/LetterboxControllerStrategy.kt +10 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.compatui.letterbox import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.MULTIPLE_SURFACES import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.SINGLE_SURFACE import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEvent import com.android.wm.shell.dagger.WMSingleton import javax.inject.Inject Loading @@ -36,7 +37,7 @@ class LetterboxControllerStrategy @Inject constructor( @Volatile private var currentMode: LetterboxMode = SINGLE_SURFACE fun configureLetterboxMode() { fun configureLetterboxMode(event: LetterboxLifecycleEvent) { // TODO(b/377875146): Define criteria for switching between [LetterboxMode]s. // At the moment, we use the presence of rounded corners to understand if to use a single // surface or multiple surfaces for the letterbox areas. This rule will change when Loading @@ -44,7 +45,10 @@ class LetterboxControllerStrategy @Inject constructor( // [MULTIPLE_SURFACES] option. // The chosen strategy will depend on performance considerations, // including surface memory usage and the impact of the rounded corners solution. currentMode = if (letterboxConfiguration.isLetterboxActivityCornersRounded()) { // In case of Bubble we always use a single surface as simple optimisation for no // transparent activities. currentMode = if (event.isBubble || letterboxConfiguration.isLetterboxActivityCornersRounded()) { SINGLE_SURFACE } else { MULTIPLE_SURFACES Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -40,8 +40,8 @@ class LetterboxLifecycleControllerImpl( with(letterboxController) { if (event.letterboxBounds != null) { // In this case the top Activity is letterboxed. letterboxModeStrategy.configureLetterboxMode() event.taskLeash?.let { taskLeash -> letterboxModeStrategy.configureLetterboxMode(event) createLetterboxSurface( key, startTransaction, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ data class LetterboxLifecycleEvent( val letterboxBounds: Rect? = null, val containerToken: WindowContainerToken? = null, val taskLeash: SurfaceControl? = null, val isBubble: Boolean = false ) /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt +2 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ class TaskInfoLetterboxLifecycleEventFactory : LetterboxLifecycleEventFactory { taskBounds = taskBounds, letterboxBounds = letterboxBounds, containerToken = ti.token, taskLeash = change.leash taskLeash = change.leash, isBubble = ti.isAppBubble ) } return null Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/LetterboxControllerStrategyTest.kt +23 −4 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package com.android.wm.shell.compatui.letterbox import android.content.Context import android.graphics.Rect import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.MULTIPLE_SURFACES import com.android.wm.shell.compatui.letterbox.LetterboxControllerStrategy.LetterboxMode.SINGLE_SURFACE import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEvent import java.util.function.Consumer import kotlin.test.assertEquals import org.junit.Test Loading @@ -38,7 +40,7 @@ import org.junit.runner.RunWith class LetterboxControllerStrategyTest : ShellTestCase() { @Test fun `LetterboxMode is MULTIPLE_SURFACES with rounded corners`() { fun `LetterboxMode is SINGLE_SURFACE with rounded corners`() { runTestScenario { r -> r.configureRoundedCornerRadius(true) r.configureLetterboxMode() Loading @@ -46,6 +48,19 @@ class LetterboxControllerStrategyTest : ShellTestCase() { } } @Test fun `LetterboxMode is SINGLE_SURFACE with Bubble Events`() { runTestScenario { r -> r.configureRoundedCornerRadius(true) r.configureLetterboxMode( r.SIMPLE_TEST_EVENT.copy( isBubble = true ) ) r.checkLetterboxModeIsSingle() } } @Test fun `LetterboxMode is MULTIPLE_SURFACES with no rounded corners`() { runTestScenario { r -> Loading @@ -63,7 +78,7 @@ class LetterboxControllerStrategyTest : ShellTestCase() { consumer.accept(robot) } class LetterboxStrategyRobotTest(val ctx: Context) { class LetterboxStrategyRobotTest(ctx: Context) { companion object { @JvmStatic Loading @@ -72,6 +87,10 @@ class LetterboxControllerStrategyTest : ShellTestCase() { private val ROUNDED_CORNERS_FALSE = 0 } val SIMPLE_TEST_EVENT = LetterboxLifecycleEvent( taskBounds = Rect() ) private val letterboxConfiguration: LetterboxConfiguration private val letterboxStrategy: LetterboxControllerStrategy Loading @@ -86,8 +105,8 @@ class LetterboxControllerStrategyTest : ShellTestCase() { ) } fun configureLetterboxMode() { letterboxStrategy.configureLetterboxMode() fun configureLetterboxMode(event: LetterboxLifecycleEvent = SIMPLE_TEST_EVENT) { letterboxStrategy.configureLetterboxMode(event) } fun checkLetterboxModeIsSingle(expected: Boolean = true) { Loading