Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +37 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.PointF import android.graphics.Rect import android.graphics.Region import android.os.Binder import android.os.Bundle import android.os.Handler import android.os.IBinder import android.os.SystemProperties Loading Loading @@ -883,6 +884,36 @@ class DesktopTasksController( moveToDisplay(task, newDisplayId) } /** * Start an intent through a launch transition for starting tasks whose transition does not get * handled by [handleRequest] */ fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) { val wct = WindowContainerTransaction() val displayLayout = displayController.getDisplayLayout(displayId) ?: return val bounds = calculateDefaultDesktopTaskBounds(displayLayout) if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) { cascadeWindow(bounds, displayLayout, displayId) } val pendingIntent = PendingIntent.getActivity( context, /* requestCode= */ 0, intent, PendingIntent.FLAG_IMMUTABLE, ) val ops = ActivityOptions.fromBundle(options).apply { launchWindowingMode = WINDOWING_MODE_FREEFORM pendingIntentBackgroundActivityStartMode = ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS launchBounds = bounds } wct.sendPendingIntent(pendingIntent, intent, ops.toBundle()) startLaunchTransition(TRANSIT_OPEN, wct, launchingTaskId = null) } /** * Move [task] to display with [displayId]. * Loading Loading @@ -2904,6 +2935,12 @@ class DesktopTasksController( c.moveToNextDisplay(taskId) } } override fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) { executeRemoteCallWithTaskPermission(controller, "startLaunchIntentTransition") { c -> c.startLaunchIntentTransition(intent, options, displayId) } } } private fun logV(msg: String, vararg arguments: Any?) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/IDesktopMode.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.wm.shell.desktopmode; import android.app.ActivityManager.RunningTaskInfo; import android.content.Intent; import android.os.Bundle; import android.window.RemoteTransition; import com.android.wm.shell.desktopmode.IDesktopTaskListener; import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource; Loading Loading @@ -61,4 +63,7 @@ interface IDesktopMode { /** Move a task with given `taskId` to external display */ void moveToExternalDisplay(int taskId); /** Start a transition when launching an intent in desktop mode */ void startLaunchIntentTransition(in Intent intent, in Bundle options, in int displayId); } No newline at end of file libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +16 −1 Original line number Diff line number Diff line Loading @@ -1145,6 +1145,21 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test fun launchIntent_taskInDesktopMode_transitionStarted() { setUpLandscapeDisplay() val freeformTask = setUpFreeformTask() controller.startLaunchIntentTransition( freeformTask.baseIntent, Bundle.EMPTY, DEFAULT_DISPLAY, ) val wct = getLatestDesktopMixedTaskWct(type = TRANSIT_OPEN) assertThat(wct.hierarchyOps).hasSize(1) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() { Loading Loading @@ -5204,7 +5219,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val arg: ArgumentCaptor<WindowContainerTransaction> = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(desktopMixedTransitionHandler) .startLaunchTransition(eq(type), capture(arg), anyInt(), anyOrNull(), anyOrNull()) .startLaunchTransition(eq(type), capture(arg), anyOrNull(), anyOrNull(), anyOrNull()) return arg.value } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +37 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.PointF import android.graphics.Rect import android.graphics.Region import android.os.Binder import android.os.Bundle import android.os.Handler import android.os.IBinder import android.os.SystemProperties Loading Loading @@ -883,6 +884,36 @@ class DesktopTasksController( moveToDisplay(task, newDisplayId) } /** * Start an intent through a launch transition for starting tasks whose transition does not get * handled by [handleRequest] */ fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) { val wct = WindowContainerTransaction() val displayLayout = displayController.getDisplayLayout(displayId) ?: return val bounds = calculateDefaultDesktopTaskBounds(displayLayout) if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) { cascadeWindow(bounds, displayLayout, displayId) } val pendingIntent = PendingIntent.getActivity( context, /* requestCode= */ 0, intent, PendingIntent.FLAG_IMMUTABLE, ) val ops = ActivityOptions.fromBundle(options).apply { launchWindowingMode = WINDOWING_MODE_FREEFORM pendingIntentBackgroundActivityStartMode = ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS launchBounds = bounds } wct.sendPendingIntent(pendingIntent, intent, ops.toBundle()) startLaunchTransition(TRANSIT_OPEN, wct, launchingTaskId = null) } /** * Move [task] to display with [displayId]. * Loading Loading @@ -2904,6 +2935,12 @@ class DesktopTasksController( c.moveToNextDisplay(taskId) } } override fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) { executeRemoteCallWithTaskPermission(controller, "startLaunchIntentTransition") { c -> c.startLaunchIntentTransition(intent, options, displayId) } } } private fun logV(msg: String, vararg arguments: Any?) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/IDesktopMode.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.wm.shell.desktopmode; import android.app.ActivityManager.RunningTaskInfo; import android.content.Intent; import android.os.Bundle; import android.window.RemoteTransition; import com.android.wm.shell.desktopmode.IDesktopTaskListener; import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource; Loading Loading @@ -61,4 +63,7 @@ interface IDesktopMode { /** Move a task with given `taskId` to external display */ void moveToExternalDisplay(int taskId); /** Start a transition when launching an intent in desktop mode */ void startLaunchIntentTransition(in Intent intent, in Bundle options, in int displayId); } No newline at end of file
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +16 −1 Original line number Diff line number Diff line Loading @@ -1145,6 +1145,21 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test fun launchIntent_taskInDesktopMode_transitionStarted() { setUpLandscapeDisplay() val freeformTask = setUpFreeformTask() controller.startLaunchIntentTransition( freeformTask.baseIntent, Bundle.EMPTY, DEFAULT_DISPLAY, ) val wct = getLatestDesktopMixedTaskWct(type = TRANSIT_OPEN) assertThat(wct.hierarchyOps).hasSize(1) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() { Loading Loading @@ -5204,7 +5219,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val arg: ArgumentCaptor<WindowContainerTransaction> = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(desktopMixedTransitionHandler) .startLaunchTransition(eq(type), capture(arg), anyInt(), anyOrNull(), anyOrNull()) .startLaunchTransition(eq(type), capture(arg), anyOrNull(), anyOrNull(), anyOrNull()) return arg.value } Loading