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

Commit 050c87ee authored by Massimo Carli's avatar Massimo Carli Committed by Android (Google) Code Review
Browse files

Merge "[61/n] Always use Single Letterbox Surface for Bubble" into main

parents 176292a1 e107e1a9
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -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

@@ -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
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ data class LetterboxLifecycleEvent(
    val letterboxBounds: Rect? = null,
    val containerToken: WindowContainerToken? = null,
    val taskLeash: SurfaceControl? = null,
    val isBubble: Boolean = false
)

/**
+2 −1
Original line number Diff line number Diff line
@@ -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
+23 −4
Original line number Diff line number Diff line
@@ -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
@@ -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()
@@ -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 ->
@@ -63,7 +78,7 @@ class LetterboxControllerStrategyTest : ShellTestCase() {
        consumer.accept(robot)
    }

    class LetterboxStrategyRobotTest(val ctx: Context) {
    class LetterboxStrategyRobotTest(ctx: Context) {

        companion object {
            @JvmStatic
@@ -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

@@ -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