Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImpl.kt +2 −2 Original line number Diff line number Diff line Loading @@ -48,12 +48,12 @@ class LetterboxLifecycleControllerImpl( if (event.letterboxBounds != null) { // In this case the top Activity is letterboxed. letterboxModeStrategy.configureLetterboxMode() event.letterboxActivityLeash?.let { leash -> event.leash?.let { leash -> createLetterboxSurface( key, startTransaction, leash, event.letterboxActivityToken event.containerToken ) } updateLetterboxSurfaceBounds( Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEvent.kt +12 −4 Original line number Diff line number Diff line Loading @@ -42,8 +42,8 @@ data class LetterboxLifecycleEvent( val displayId: Int = -1, val taskBounds: Rect, val letterboxBounds: Rect? = null, val letterboxActivityToken: WindowContainerToken? = null, val letterboxActivityLeash: SurfaceControl? = null, val containerToken: WindowContainerToken? = null, val leash: SurfaceControl? = null, ) /** Loading @@ -52,6 +52,14 @@ data class LetterboxLifecycleEvent( fun LetterboxLifecycleEvent.letterboxKey(): LetterboxKey = LetterboxKey(displayId = displayId, taskId = taskId) /** * Maps a [TransitionInfo.Change] mode in a [LetterboxLifecycleEventType]. */ fun Change.asLetterboxLifecycleEventType() = when { isClosingType(mode) -> CLOSE isOpeningType(mode) -> OPEN else -> NONE } /** * Creates a [LetterboxLifecycleEvent] from the information in a [Change]. Loading Loading @@ -81,7 +89,7 @@ fun Change.toLetterboxLifecycleEvent(): LetterboxLifecycleEvent { taskId = taskInfo?.taskId ?: -1, taskBounds = taskBounds, letterboxBounds = letterboxBounds, letterboxActivityToken = taskInfo?.token, letterboxActivityLeash = leash containerToken = taskInfo?.token, leash = leash ) } libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.compatui.letterbox.lifecycle import android.graphics.Rect import android.window.TransitionInfo.Change /** * [LetterboxLifecycleEventFactory] implementation which creates a [LetterboxLifecycleEvent] from * a [TransitionInfo.Change] using a [TaskInfo] when present. */ class TaskInfoLetterboxLifecycleEventFactory : LetterboxLifecycleEventFactory { override fun canHandle(change: Change): Boolean = change.taskInfo != null override fun createLifecycleEvent(change: Change): LetterboxLifecycleEvent? { change.taskInfo?.let { ti -> val taskBounds = Rect( change.endRelOffset.x, change.endRelOffset.y, change.endAbsBounds.width(), change.endAbsBounds.height() ) val isLetterboxed = ti.appCompatTaskInfo?.isTopActivityLetterboxed ?: false // Letterbox bounds are null when the activity is not letterboxed. val letterboxBounds = if (isLetterboxed) ti.appCompatTaskInfo?.topActivityLetterboxBounds else null return LetterboxLifecycleEvent( type = change.asLetterboxLifecycleEventType(), displayId = ti.displayId, taskId = ti.taskId, taskBounds = taskBounds, letterboxBounds = letterboxBounds, containerToken = ti.token, leash = change.leash ) } return null } } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImplTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -196,8 +196,8 @@ class LetterboxLifecycleControllerImplTest : ShellTestCase() { taskId = taskId, taskBounds = taskBounds, letterboxBounds = letterboxBounds, letterboxActivityToken = letterboxActivityToken, letterboxActivityLeash = letterboxActivityLeash containerToken = letterboxActivityToken, leash = letterboxActivityLeash ) fun configureIsRecentsTransitionRunning(running: Boolean) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEventTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -250,11 +250,11 @@ class LetterboxLifecycleEventTest : ShellTestCase() { } fun checkLetterboxActivityToken(expected: WindowContainerToken?) { assertEquals(expected, event?.letterboxActivityToken) assertEquals(expected, event?.containerToken) } fun checkLetterboxActivityLeash(expected: SurfaceControl?) { assertEquals(expected, event?.letterboxActivityLeash) assertEquals(expected, event?.leash) } fun checkLetterboxKey(expected: LetterboxKey) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImpl.kt +2 −2 Original line number Diff line number Diff line Loading @@ -48,12 +48,12 @@ class LetterboxLifecycleControllerImpl( if (event.letterboxBounds != null) { // In this case the top Activity is letterboxed. letterboxModeStrategy.configureLetterboxMode() event.letterboxActivityLeash?.let { leash -> event.leash?.let { leash -> createLetterboxSurface( key, startTransaction, leash, event.letterboxActivityToken event.containerToken ) } updateLetterboxSurfaceBounds( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEvent.kt +12 −4 Original line number Diff line number Diff line Loading @@ -42,8 +42,8 @@ data class LetterboxLifecycleEvent( val displayId: Int = -1, val taskBounds: Rect, val letterboxBounds: Rect? = null, val letterboxActivityToken: WindowContainerToken? = null, val letterboxActivityLeash: SurfaceControl? = null, val containerToken: WindowContainerToken? = null, val leash: SurfaceControl? = null, ) /** Loading @@ -52,6 +52,14 @@ data class LetterboxLifecycleEvent( fun LetterboxLifecycleEvent.letterboxKey(): LetterboxKey = LetterboxKey(displayId = displayId, taskId = taskId) /** * Maps a [TransitionInfo.Change] mode in a [LetterboxLifecycleEventType]. */ fun Change.asLetterboxLifecycleEventType() = when { isClosingType(mode) -> CLOSE isOpeningType(mode) -> OPEN else -> NONE } /** * Creates a [LetterboxLifecycleEvent] from the information in a [Change]. Loading Loading @@ -81,7 +89,7 @@ fun Change.toLetterboxLifecycleEvent(): LetterboxLifecycleEvent { taskId = taskInfo?.taskId ?: -1, taskBounds = taskBounds, letterboxBounds = letterboxBounds, letterboxActivityToken = taskInfo?.token, letterboxActivityLeash = leash containerToken = taskInfo?.token, leash = leash ) }
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.compatui.letterbox.lifecycle import android.graphics.Rect import android.window.TransitionInfo.Change /** * [LetterboxLifecycleEventFactory] implementation which creates a [LetterboxLifecycleEvent] from * a [TransitionInfo.Change] using a [TaskInfo] when present. */ class TaskInfoLetterboxLifecycleEventFactory : LetterboxLifecycleEventFactory { override fun canHandle(change: Change): Boolean = change.taskInfo != null override fun createLifecycleEvent(change: Change): LetterboxLifecycleEvent? { change.taskInfo?.let { ti -> val taskBounds = Rect( change.endRelOffset.x, change.endRelOffset.y, change.endAbsBounds.width(), change.endAbsBounds.height() ) val isLetterboxed = ti.appCompatTaskInfo?.isTopActivityLetterboxed ?: false // Letterbox bounds are null when the activity is not letterboxed. val letterboxBounds = if (isLetterboxed) ti.appCompatTaskInfo?.topActivityLetterboxBounds else null return LetterboxLifecycleEvent( type = change.asLetterboxLifecycleEventType(), displayId = ti.displayId, taskId = ti.taskId, taskBounds = taskBounds, letterboxBounds = letterboxBounds, containerToken = ti.token, leash = change.leash ) } return null } }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleControllerImplTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -196,8 +196,8 @@ class LetterboxLifecycleControllerImplTest : ShellTestCase() { taskId = taskId, taskBounds = taskBounds, letterboxBounds = letterboxBounds, letterboxActivityToken = letterboxActivityToken, letterboxActivityLeash = letterboxActivityLeash containerToken = letterboxActivityToken, leash = letterboxActivityLeash ) fun configureIsRecentsTransitionRunning(running: Boolean) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/LetterboxLifecycleEventTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -250,11 +250,11 @@ class LetterboxLifecycleEventTest : ShellTestCase() { } fun checkLetterboxActivityToken(expected: WindowContainerToken?) { assertEquals(expected, event?.letterboxActivityToken) assertEquals(expected, event?.containerToken) } fun checkLetterboxActivityLeash(expected: SurfaceControl?) { assertEquals(expected, event?.letterboxActivityLeash) assertEquals(expected, event?.leash) } fun checkLetterboxKey(expected: LetterboxKey) { Loading