Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt +9 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.window.TransitionInfo.Change import com.android.window.flags.Flags import com.android.wm.shell.compatui.letterbox.config.LetterboxDependenciesHelper import com.android.wm.shell.compatui.letterbox.state.LetterboxTaskInfoRepository import com.android.wm.shell.compatui.letterbox.state.updateConfiguration import com.android.wm.shell.compatui.letterbox.state.updateTaskLeafState /** Loading Loading @@ -49,6 +50,14 @@ class TaskInfoLetterboxLifecycleEventFactory( Rect(absBounds).apply { offset(-taskBoundsAbs.left, -taskBoundsAbs.top) } } val shouldSupportInput = letterboxDependenciesHelper.shouldSupportInputSurface(change) if (Flags.appCompatRefactoringRoundedCorners()) { // Sometimes the [TransitionObserver] is notified before than the // [TaskAppearedListener] and the related information (e.g. [Configuration]) // are required soon. This is the case, for instance, of rounded corners // implementation which require the [Configuration] when the related surfaces // are created. letterboxTaskInfoRepository.updateConfiguration(ti, change.leash) } if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { // Because the [TransitionObserver] is invoked before the [OnTaskAppearedListener]s // it's important to store the information about the Task to be reused below for the Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskInfoRepository.kt +16 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.compatui.letterbox.state import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityTaskManager import android.content.res.Configuration import android.view.SurfaceControl import android.window.WindowContainerToken import com.android.internal.protolog.ProtoLog Loading @@ -30,10 +31,11 @@ import javax.inject.Inject /** Encapsulate the [TaskInfo] information useful for letterboxing in shell. */ data class LetterboxTaskInfoState( val containerToken: WindowContainerToken, val containerToken: WindowContainerToken? = null, val containerLeash: SurfaceControl, val taskId: Int = ActivityTaskManager.INVALID_TASK_ID, val parentTaskId: Int = ActivityTaskManager.INVALID_TASK_ID, val configuration: Configuration, ) /** Loading Loading @@ -65,6 +67,7 @@ fun LetterboxTaskInfoRepository.updateTaskLeafState( containerLeash = leash, parentTaskId = taskInfo.parentTaskId, taskId = taskInfo.taskId, configuration = taskInfo.configuration, ), overrideIfPresent = true, ) Loading @@ -72,3 +75,15 @@ fun LetterboxTaskInfoRepository.updateTaskLeafState( delete(taskInfo.taskId) } } /** Updates the configuration given the [TaskInfo] and the leash. */ fun LetterboxTaskInfoRepository.updateConfiguration( taskInfo: RunningTaskInfo, leash: SurfaceControl, ) { insert( taskInfo.taskId, LetterboxTaskInfoState(taskInfo.token, leash, configuration = taskInfo.configuration), overrideIfPresent = true, ) } libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskListenerAdapter.kt +16 −6 Original line number Diff line number Diff line Loading @@ -47,9 +47,7 @@ constructor( { shellTaskOrganizer.addTaskAppearedListener(this) shellTaskOrganizer.addTaskVanishedListener(this) if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { shellTaskOrganizer.addTaskInfoChangedListener(this) } }, this, ) Loading @@ -63,17 +61,29 @@ constructor( letterboxTaskInfoRepository.insert( key = taskInfo.taskId, item = LetterboxTaskInfoState(containerToken = taskInfo.token, containerLeash = leash), LetterboxTaskInfoState( containerToken = taskInfo.token, containerLeash = leash, configuration = taskInfo.configuration, ), overrideIfPresent = true, ) } } override fun onTaskInfoChanged(taskInfo: RunningTaskInfo) { if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { if (!taskInfo.isALeafTask) { letterboxTaskInfoRepository.delete(taskInfo.taskId) } } if (Flags.appCompatRefactoringRoundedCorners()) { letterboxTaskInfoRepository.update( key = taskInfo.taskId, updateItem = { item -> item.copy(configuration = taskInfo.configuration) }, ) } } override fun onTaskVanished(taskInfo: RunningTaskInfo) { letterboxTaskInfoRepository.delete(taskInfo.taskId) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/ActivityLetterboxLifecycleEventFactoryTest.kt +17 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.content.res.Configuration import android.graphics.Rect import android.testing.AndroidTestingRunner import android.view.SurfaceControl Loading Loading @@ -74,7 +75,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } endAbsBounds = Rect(100, 50, 2000, 1500) } r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) validateCanHandle { canHandle -> assertTrue(canHandle) } Loading @@ -100,7 +104,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } } r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) validateCanHandle { canHandle -> assertTrue(canHandle) } Loading @@ -118,7 +125,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { val testLeash = mock<SurfaceControl>() val testToken = mock<WindowContainerToken>() r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) inputChange { activityTransitionInfo { taskId = 10 Loading Loading @@ -146,7 +156,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } val testLeash = mock<SurfaceControl>() val testToken = mock<WindowContainerToken>() r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) r.shouldSupportInputSurface(shouldSupportInputSurface = true) validateCreateLifecycleEvent { event -> assertNotNull(event) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskIdResolverTest.kt +6 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW import android.content.res.Configuration import android.testing.AndroidTestingRunner import android.view.SurfaceControl import android.window.WindowContainerToken Loading Loading @@ -126,6 +127,9 @@ class TaskIdResolverTest : ShellTestCase() { @JvmStatic val TEST_LEASH = mock<SurfaceControl>() @JvmStatic val TEST_CONFIGURATION = Configuration() } private val letterboxTaskInfoRepository: LetterboxTaskInfoRepository = Loading @@ -145,7 +149,8 @@ class TaskIdResolverTest : ShellTestCase() { containerToken = TEST_TOKEN, containerLeash = TEST_LEASH, taskId = taskId, parentTaskId = parentTaskId parentTaskId = parentTaskId, configuration = TEST_CONFIGURATION ) } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskInfoLetterboxLifecycleEventFactory.kt +9 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.window.TransitionInfo.Change import com.android.window.flags.Flags import com.android.wm.shell.compatui.letterbox.config.LetterboxDependenciesHelper import com.android.wm.shell.compatui.letterbox.state.LetterboxTaskInfoRepository import com.android.wm.shell.compatui.letterbox.state.updateConfiguration import com.android.wm.shell.compatui.letterbox.state.updateTaskLeafState /** Loading Loading @@ -49,6 +50,14 @@ class TaskInfoLetterboxLifecycleEventFactory( Rect(absBounds).apply { offset(-taskBoundsAbs.left, -taskBoundsAbs.top) } } val shouldSupportInput = letterboxDependenciesHelper.shouldSupportInputSurface(change) if (Flags.appCompatRefactoringRoundedCorners()) { // Sometimes the [TransitionObserver] is notified before than the // [TaskAppearedListener] and the related information (e.g. [Configuration]) // are required soon. This is the case, for instance, of rounded corners // implementation which require the [Configuration] when the related surfaces // are created. letterboxTaskInfoRepository.updateConfiguration(ti, change.leash) } if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { // Because the [TransitionObserver] is invoked before the [OnTaskAppearedListener]s // it's important to store the information about the Task to be reused below for the Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskInfoRepository.kt +16 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.compatui.letterbox.state import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityTaskManager import android.content.res.Configuration import android.view.SurfaceControl import android.window.WindowContainerToken import com.android.internal.protolog.ProtoLog Loading @@ -30,10 +31,11 @@ import javax.inject.Inject /** Encapsulate the [TaskInfo] information useful for letterboxing in shell. */ data class LetterboxTaskInfoState( val containerToken: WindowContainerToken, val containerToken: WindowContainerToken? = null, val containerLeash: SurfaceControl, val taskId: Int = ActivityTaskManager.INVALID_TASK_ID, val parentTaskId: Int = ActivityTaskManager.INVALID_TASK_ID, val configuration: Configuration, ) /** Loading Loading @@ -65,6 +67,7 @@ fun LetterboxTaskInfoRepository.updateTaskLeafState( containerLeash = leash, parentTaskId = taskInfo.parentTaskId, taskId = taskInfo.taskId, configuration = taskInfo.configuration, ), overrideIfPresent = true, ) Loading @@ -72,3 +75,15 @@ fun LetterboxTaskInfoRepository.updateTaskLeafState( delete(taskInfo.taskId) } } /** Updates the configuration given the [TaskInfo] and the leash. */ fun LetterboxTaskInfoRepository.updateConfiguration( taskInfo: RunningTaskInfo, leash: SurfaceControl, ) { insert( taskInfo.taskId, LetterboxTaskInfoState(taskInfo.token, leash, configuration = taskInfo.configuration), overrideIfPresent = true, ) }
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskListenerAdapter.kt +16 −6 Original line number Diff line number Diff line Loading @@ -47,9 +47,7 @@ constructor( { shellTaskOrganizer.addTaskAppearedListener(this) shellTaskOrganizer.addTaskVanishedListener(this) if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { shellTaskOrganizer.addTaskInfoChangedListener(this) } }, this, ) Loading @@ -63,17 +61,29 @@ constructor( letterboxTaskInfoRepository.insert( key = taskInfo.taskId, item = LetterboxTaskInfoState(containerToken = taskInfo.token, containerLeash = leash), LetterboxTaskInfoState( containerToken = taskInfo.token, containerLeash = leash, configuration = taskInfo.configuration, ), overrideIfPresent = true, ) } } override fun onTaskInfoChanged(taskInfo: RunningTaskInfo) { if (Flags.appCompatRefactoringFixMultiwindowTaskHierarchy()) { if (!taskInfo.isALeafTask) { letterboxTaskInfoRepository.delete(taskInfo.taskId) } } if (Flags.appCompatRefactoringRoundedCorners()) { letterboxTaskInfoRepository.update( key = taskInfo.taskId, updateItem = { item -> item.copy(configuration = taskInfo.configuration) }, ) } } override fun onTaskVanished(taskInfo: RunningTaskInfo) { letterboxTaskInfoRepository.delete(taskInfo.taskId) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/ActivityLetterboxLifecycleEventFactoryTest.kt +17 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.content.res.Configuration import android.graphics.Rect import android.testing.AndroidTestingRunner import android.view.SurfaceControl Loading Loading @@ -74,7 +75,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } endAbsBounds = Rect(100, 50, 2000, 1500) } r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) validateCanHandle { canHandle -> assertTrue(canHandle) } Loading @@ -100,7 +104,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } } r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) validateCanHandle { canHandle -> assertTrue(canHandle) } Loading @@ -118,7 +125,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { val testLeash = mock<SurfaceControl>() val testToken = mock<WindowContainerToken>() r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) inputChange { activityTransitionInfo { taskId = 10 Loading Loading @@ -146,7 +156,10 @@ class ActivityLetterboxLifecycleEventFactoryTest : ShellTestCase() { } val testLeash = mock<SurfaceControl>() val testToken = mock<WindowContainerToken>() r.addToTaskRepository(10, LetterboxTaskInfoState(testToken, testLeash)) r.addToTaskRepository( 10, LetterboxTaskInfoState(testToken, testLeash, configuration = Configuration()) ) r.shouldSupportInputSurface(shouldSupportInputSurface = true) validateCreateLifecycleEvent { event -> assertNotNull(event) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/TaskIdResolverTest.kt +6 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.wm.shell.compatui.letterbox.lifecycle import android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW import android.content.res.Configuration import android.testing.AndroidTestingRunner import android.view.SurfaceControl import android.window.WindowContainerToken Loading Loading @@ -126,6 +127,9 @@ class TaskIdResolverTest : ShellTestCase() { @JvmStatic val TEST_LEASH = mock<SurfaceControl>() @JvmStatic val TEST_CONFIGURATION = Configuration() } private val letterboxTaskInfoRepository: LetterboxTaskInfoRepository = Loading @@ -145,7 +149,8 @@ class TaskIdResolverTest : ShellTestCase() { containerToken = TEST_TOKEN, containerLeash = TEST_LEASH, taskId = taskId, parentTaskId = parentTaskId parentTaskId = parentTaskId, configuration = TEST_CONFIGURATION ) } }