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

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

Merge "[1/n] Implement alternative translucent heuristic" into main

parents 70195714 09180bd8
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import android.app.TaskInfo
import android.graphics.Rect
import android.graphics.Rect
import android.view.SurfaceControl
import android.view.SurfaceControl
import android.window.TransitionInfo.Change
import android.window.TransitionInfo.Change
import android.window.TransitionInfo.FLAG_TRANSLUCENT
import android.window.WindowContainerToken
import android.window.WindowContainerToken
import com.android.wm.shell.compatui.letterbox.LetterboxKey
import com.android.wm.shell.compatui.letterbox.LetterboxKey
import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.CLOSE
import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.CLOSE
@@ -73,7 +72,7 @@ fun Change.shouldSkipForLetterbox(): Boolean = isClosingType(mode)
fun Change.isActivityChange(): Boolean = activityTransitionInfo != null
fun Change.isActivityChange(): Boolean = activityTransitionInfo != null


/** Returns [true] if the [Change] is related to a translucent container. */
/** Returns [true] if the [Change] is related to a translucent container. */
fun Change.isTranslucent() = hasFlags(FLAG_TRANSLUCENT)
fun Change.isTranslucent() = taskInfo?.isTopActivityTransparent ?: false


/** Returns [true] if the related [Task] is a leaf task. */
/** Returns [true] if the related [Task] is a leaf task. */
val TaskInfo.isALeafTask: Boolean
val TaskInfo.isALeafTask: Boolean
+11 −6
Original line number Original line Diff line number Diff line
@@ -18,17 +18,16 @@ package com.android.wm.shell.compatui.letterbox.lifecycle


import android.testing.AndroidTestingRunner
import android.testing.AndroidTestingRunner
import android.view.WindowManager
import android.view.WindowManager
import android.window.TransitionInfo.FLAG_TRANSLUCENT
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.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.CLOSE
import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.CLOSE
import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.OPEN
import com.android.wm.shell.compatui.letterbox.lifecycle.LetterboxLifecycleEventType.OPEN
import com.android.wm.shell.util.testLetterboxLifecycleEvent
import com.android.wm.shell.util.testLetterboxLifecycleEvent
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertEquals
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.test.assertTrue
import org.junit.Test
import org.junit.runner.RunWith


/**
/**
 * Tests for [LetterboxLifecycleEvent].
 * Tests for [LetterboxLifecycleEvent].
@@ -156,15 +155,21 @@ class LetterboxLifecycleEventTest : ShellTestCase() {
    }
    }


    @Test
    @Test
    fun `isTranslucent returns true if the FLAG_TRANSLUCENT flag is present in Change`() {
    fun `isTranslucent returns the value from TaskInfo `() {
        testLetterboxLifecycleEvent {
        testLetterboxLifecycleEvent {
            inputChange { }
            inputChange {
                runningTaskInfo { ti ->
                    ti.isTopActivityTransparent = false
                }
            }
            useChange { change ->
            useChange { change ->
                assertFalse(change.isTranslucent())
                assertFalse(change.isTranslucent())
            }
            }


            inputChange {
            inputChange {
                flags = FLAG_TRANSLUCENT
                runningTaskInfo { ti ->
                    ti.isTopActivityTransparent = true
                }
            }
            }
            useChange { change ->
            useChange { change ->
                assertTrue(change.isTranslucent())
                assertTrue(change.isTranslucent())