Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +17 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ import com.android.wm.shell.desktopmode.education.AppToWebEducationController; import com.android.wm.shell.desktopmode.education.AppToWebEducationFilter; import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository; import com.android.wm.shell.desktopmode.education.data.AppToWebEducationDatastoreRepository; import com.android.wm.shell.desktopmode.multidesks.DeskSwitchTransitionHandler; import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer; import com.android.wm.shell.desktopmode.multidesks.DesksTransitionObserver; import com.android.wm.shell.desktopmode.multidesks.RootTaskDesksOrganizer; Loading Loading @@ -950,6 +951,7 @@ public abstract class WMShellModule { UserProfileContexts userProfileContexts, DesktopModeCompatPolicy desktopModeCompatPolicy, WindowDragTransitionHandler windowDragTransitionHandler, DeskSwitchTransitionHandler deskSwitchTransitionHandler, DesktopModeMoveToDisplayTransitionHandler moveToDisplayTransitionHandler, HomeIntentProvider homeIntentProvider, DesktopState desktopState, Loading Loading @@ -998,6 +1000,7 @@ public abstract class WMShellModule { userProfileContexts, desktopModeCompatPolicy, windowDragTransitionHandler, deskSwitchTransitionHandler, moveToDisplayTransitionHandler, homeIntentProvider, desktopState, Loading Loading @@ -1167,6 +1170,20 @@ public abstract class WMShellModule { desktopState); } @WMSingleton @Provides static DeskSwitchTransitionHandler provideDeskSwitchTransitionHandler( Context context, @DynamicOverride DesktopUserRepositories desktopUserRepositories, DesktopState desktopState, Transitions transitions, DisplayController displayController ) { return new DeskSwitchTransitionHandler(context, desktopUserRepositories, desktopState, transitions, displayController); } @WMSingleton @Provides static Optional<DisplayDisconnectTransitionHandler> provideDisplayDisconnectTransitionHandler( Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTransitionTypes.kt +5 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ object DesktopModeTransitionTypes { /** Transition type to animate the minimization triggered when reaching the task limit. */ const val TRANSIT_DESKTOP_MODE_TASK_LIMIT_MINIMIZE = TRANSIT_DESKTOP_MODE_TYPES + 13 /** Transition type to animate desk switches within the same display. */ const val TRANSIT_DESKTOP_MODE_DESK_TO_DESK_SWITCH = TRANSIT_DESKTOP_MODE_TYPES + 14 /** Return whether the [TransitionType] corresponds to a transition to enter desktop mode. */ @JvmStatic fun @receiver:TransitionType Int.isEnterDesktopModeTransition(): Boolean { Loading Loading @@ -113,13 +116,14 @@ object DesktopModeTransitionTypes { * string. */ @JvmStatic fun transitTypeToString(transitType: Int): String = fun transitTypeToString(transitType: Int?): String = when (transitType) { TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP -> "DESKTOP_MODE_START_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_END_DRAG_TO_DESKTOP -> "DESKTOP_MODE_END_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP -> "DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE -> "DESKTOP_MODE_TOGGLE_RESIZE" TRANSIT_DESKTOP_MODE_TASK_LIMIT_MINIMIZE -> "DESKTOP_MODE_TASK_LIMIT_MINIMIZE" TRANSIT_DESKTOP_MODE_DESK_TO_DESK_SWITCH -> "DESKTOP_MODE_DESK_TO_DESK_SWITCH" else -> "" } } libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +44 −6 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ import com.android.wm.shell.desktopmode.desktopfirst.DesktopFirstListenerManager import com.android.wm.shell.desktopmode.desktopfirst.isDisplayDesktopFirst import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.desktopmode.multidesks.DeskSwitchTransitionHandler import com.android.wm.shell.desktopmode.multidesks.DeskTransition import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.desktopmode.multidesks.DesksTransitionObserver Loading Loading @@ -247,6 +248,7 @@ class DesktopTasksController( private val userProfileContexts: UserProfileContexts, private val desktopModeCompatPolicy: DesktopModeCompatPolicy, private val windowDragTransitionHandler: WindowDragTransitionHandler, private val deskSwitchTransitionHandler: DeskSwitchTransitionHandler, private val moveToDisplayTransitionHandler: DesktopModeMoveToDisplayTransitionHandler, private val homeIntentProvider: HomeIntentProvider, private val desktopState: DesktopState, Loading Loading @@ -1144,12 +1146,13 @@ class DesktopTasksController( // Deactivate desks of old user. rootTaskDisplayAreaOrganizer.displayIds .toList() .mapNotNull { displayId -> previousRepo.getActiveDeskId(displayId) } .mapNotNull { deskId -> .mapNotNull { displayId -> val deskId = previousRepo.getActiveDeskId(displayId) ?: return@mapNotNull null addDeskDeactivationChanges( wct = wct, deskId = deskId, userId = userChange.previousUserId, displayId = displayId, switchingUser = true, exitReason = ExitReason.UNKNOWN_EXIT, ) Loading Loading @@ -1207,6 +1210,7 @@ class DesktopTasksController( wct = wct, deskId = disconnectedDisplayActiveDesk, userId = userId, displayId = destinationDisplayId, exitReason = ExitReason.DISPLAY_DISCONNECTED, ) } Loading Loading @@ -3287,6 +3291,7 @@ class DesktopTasksController( wct = wct, deskId = deskId, userId = userId, displayId = displayId, exitReason = exitReason, ) } Loading Loading @@ -4911,6 +4916,7 @@ class DesktopTasksController( wct = wct, deskId = deactivatingDesk, userId = userId, displayId = displayId, switchingUser = switchingUser, ExitReason.RETURN_HOME_OR_OVERVIEW, ) Loading Loading @@ -4990,11 +4996,26 @@ class DesktopTasksController( activeDeskId, validDisplay, ) // TODO: b/389957556 - add animation. return } val wct = WindowContainerTransaction() val runOnTransitStart = addDeskActivationChanges( deskId = destinationDeskId, wct = wct, userId = userId, enterReason = enterReason, ) logV("activatePreviousDesk from deskId=%d to deskId=%d", activeDeskId, destinationDeskId) activateDesk(deskId = destinationDeskId, userId = userId, enterReason = enterReason) val transition = deskSwitchTransitionHandler.startTransition( wct = wct, userId = userId, displayId = displayId, fromDeskId = activeDeskId, toDeskId = destinationDeskId, ) runOnTransitStart(transition) } /** Activates the desk at the given index if it exists. */ Loading Loading @@ -5028,11 +5049,26 @@ class DesktopTasksController( activeDeskId, validDisplay, ) // TODO: b/389957556 - add animation. return } val wct = WindowContainerTransaction() val runOnTransitStart = addDeskActivationChanges( deskId = destinationDeskId, wct = wct, userId = userId, enterReason = enterReason, ) logV("activateNextDesk from deskId=%d to deskId=%d", activeDeskId, destinationDeskId) activateDesk(deskId = destinationDeskId, userId = userId, enterReason = enterReason) val transition = deskSwitchTransitionHandler.startTransition( wct = wct, userId = userId, displayId = displayId, fromDeskId = activeDeskId, toDeskId = destinationDeskId, ) runOnTransitStart(transition) } /** Loading Loading @@ -5187,6 +5223,7 @@ class DesktopTasksController( wct: WindowContainerTransaction, deskId: Int?, userId: Int, displayId: Int, switchingUser: Boolean = false, exitReason: ExitReason, ): RunOnTransitStart? { Loading @@ -5199,6 +5236,7 @@ class DesktopTasksController( token = transition, userId = userId, deskId = deskId, displayId = displayId, switchingUser = switchingUser, exitReason = exitReason, runOnTransitEnd = { snapEventHandler.onDeskDeactivated(deskId) }, Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopWallpaperActivity.kt +108 −0 Original line number Diff line number Diff line Loading @@ -20,7 +20,11 @@ import android.app.ActivityManager.getCurrentUser import android.app.TaskInfo import android.app.WallpaperColors import android.app.WallpaperManager import android.content.BroadcastReceiver import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.IntentFilter import android.content.res.Configuration import android.hardware.display.DisplayManager import android.os.Bundle Loading @@ -31,6 +35,9 @@ import androidx.activity.addCallback import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.fragment.app.FragmentActivity import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator.Companion.JUMP_CUT_ANIMATION import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator.Companion.SLIDE_ANIMATION /** * A transparent activity used in the desktop mode to show the wallpaper under the freeform windows. Loading Loading @@ -81,6 +88,14 @@ class DesktopWallpaperActivity : FragmentActivity() { } } private val wallpaperAnimationReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { intent ?: return handleStartWallpaperAnimationRequest(intent) } } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Log.d(TAG, "onCreate") Loading Loading @@ -116,6 +131,20 @@ class DesktopWallpaperActivity : FragmentActivity() { initialDisplayId = displayId } override fun onResume() { super.onResume() registerReceiver( wallpaperAnimationReceiver, IntentFilter(START_WALLPAPER_ANIMATION_ACTION), RECEIVER_EXPORTED, ) } override fun onPause() { unregisterReceiver(wallpaperAnimationReceiver) super.onPause() } override fun onDestroy() { super.onDestroy() wallpaperManager?.removeOnColorsChangedListener(wallpaperColorsListener) Loading Loading @@ -153,10 +182,61 @@ class DesktopWallpaperActivity : FragmentActivity() { private fun getWindowInsetsController(): WindowInsetsControllerCompat = WindowCompat.getInsetsController(window, window.decorView) private fun handleStartWallpaperAnimationRequest(intent: Intent) { Log.d(TAG, "handleStartWallpaperAnimationRequest") if (intent.action != START_WALLPAPER_ANIMATION_ACTION) return val animType = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, JUMP_CUT_ANIMATION) val displayId = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, -1) if (displayId == -1 || displayId != initialDisplayId) return val token = window?.decorView?.rootView?.windowToken ?: return val wm = wallpaperManager ?: return when (animType) { JUMP_CUT_ANIMATION -> { val numberOfDesks = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, -1) val toDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, -1) if (numberOfDesks == -1 || toDeskIndex == -1) { return } DeskWallpaperAnimator.jumpCutAnimator( wallpaperManager = wm, windowToken = token, numberOfDesks = numberOfDesks, toDeskIndex = toDeskIndex, ) .start() } SLIDE_ANIMATION -> { val numberOfDesks = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, -1) val fromDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, -1) val toDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, -1) if (numberOfDesks == -1 || fromDeskIndex == -1 || toDeskIndex == -1) { return } DeskWallpaperAnimator.slideAnimator( wallpaperManager = wm, windowToken = token, numberOfDesks = numberOfDesks, fromDeskIndex = fromDeskIndex, toDeskIndex = toDeskIndex, ) .start() } } } companion object { private const val TAG = "DesktopWallpaperActivity" private const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui" private const val START_WALLPAPER_ANIMATION_ACTION = "com.android.wm.shell.desktop.action.ANIMATE_WALLPAPER" private const val WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE = "animation_type" private const val WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID = "display_id" private const val WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS = "num_of_desks" private const val WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX = "from_desk_index" private const val WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX = "to_desk_index" @JvmStatic val wallpaperActivityComponent = ComponentName(SYSTEM_UI_PACKAGE_NAME, DesktopWallpaperActivity::class.java.name) Loading @@ -167,5 +247,33 @@ class DesktopWallpaperActivity : FragmentActivity() { @JvmStatic fun isWallpaperComponent(component: ComponentName) = component == wallpaperActivityComponent /** An intent to use in a broadcast to trigger the slide wallpaper animation. */ fun createWallpaperSlideAnimationIntent( displayId: Int, numberOfDesks: Int, fromDeskIndex: Int, toDeskIndex: Int, ): Intent = Intent(START_WALLPAPER_ANIMATION_ACTION).apply { putExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, SLIDE_ANIMATION) putExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, displayId) putExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, numberOfDesks) putExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, fromDeskIndex) putExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, toDeskIndex) } /** An intent to use in a broadcast to trigger the no-animation wallpaper animation. */ fun createWallpaperNoAnimationIntent( displayId: Int, numberOfDesks: Int, deskIndex: Int, ): Intent = Intent(START_WALLPAPER_ANIMATION_ACTION).apply { putExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, JUMP_CUT_ANIMATION) putExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, displayId) putExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, numberOfDesks) putExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, deskIndex) } } } libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/data/DesktopRepository.kt +8 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,14 @@ class DesktopRepository( /** Returns the default desk in the given display. */ private fun getDefaultDesk(displayId: Int): Desk? = desktopData.getDefaultDesk(displayId) /** Returns the index of the given desk in the ordered list of desks. */ fun getDeskPosition(deskId: Int): Int? { val desks = desktopData.getOrderedDesks(getDisplayForDesk(deskId)) val index = desks.indexOfFirst { it.deskId == deskId } if (index < 0) return null return index } /** Returns the id of the desk ordered previous to the given one, or null if there isn't one. */ fun getPreviousDeskId(deskId: Int): Int? { val desks = desktopData.getOrderedDesks(getDisplayForDesk(deskId)) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +17 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ import com.android.wm.shell.desktopmode.education.AppToWebEducationController; import com.android.wm.shell.desktopmode.education.AppToWebEducationFilter; import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository; import com.android.wm.shell.desktopmode.education.data.AppToWebEducationDatastoreRepository; import com.android.wm.shell.desktopmode.multidesks.DeskSwitchTransitionHandler; import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer; import com.android.wm.shell.desktopmode.multidesks.DesksTransitionObserver; import com.android.wm.shell.desktopmode.multidesks.RootTaskDesksOrganizer; Loading Loading @@ -950,6 +951,7 @@ public abstract class WMShellModule { UserProfileContexts userProfileContexts, DesktopModeCompatPolicy desktopModeCompatPolicy, WindowDragTransitionHandler windowDragTransitionHandler, DeskSwitchTransitionHandler deskSwitchTransitionHandler, DesktopModeMoveToDisplayTransitionHandler moveToDisplayTransitionHandler, HomeIntentProvider homeIntentProvider, DesktopState desktopState, Loading Loading @@ -998,6 +1000,7 @@ public abstract class WMShellModule { userProfileContexts, desktopModeCompatPolicy, windowDragTransitionHandler, deskSwitchTransitionHandler, moveToDisplayTransitionHandler, homeIntentProvider, desktopState, Loading Loading @@ -1167,6 +1170,20 @@ public abstract class WMShellModule { desktopState); } @WMSingleton @Provides static DeskSwitchTransitionHandler provideDeskSwitchTransitionHandler( Context context, @DynamicOverride DesktopUserRepositories desktopUserRepositories, DesktopState desktopState, Transitions transitions, DisplayController displayController ) { return new DeskSwitchTransitionHandler(context, desktopUserRepositories, desktopState, transitions, displayController); } @WMSingleton @Provides static Optional<DisplayDisconnectTransitionHandler> provideDisplayDisconnectTransitionHandler( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTransitionTypes.kt +5 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ object DesktopModeTransitionTypes { /** Transition type to animate the minimization triggered when reaching the task limit. */ const val TRANSIT_DESKTOP_MODE_TASK_LIMIT_MINIMIZE = TRANSIT_DESKTOP_MODE_TYPES + 13 /** Transition type to animate desk switches within the same display. */ const val TRANSIT_DESKTOP_MODE_DESK_TO_DESK_SWITCH = TRANSIT_DESKTOP_MODE_TYPES + 14 /** Return whether the [TransitionType] corresponds to a transition to enter desktop mode. */ @JvmStatic fun @receiver:TransitionType Int.isEnterDesktopModeTransition(): Boolean { Loading Loading @@ -113,13 +116,14 @@ object DesktopModeTransitionTypes { * string. */ @JvmStatic fun transitTypeToString(transitType: Int): String = fun transitTypeToString(transitType: Int?): String = when (transitType) { TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP -> "DESKTOP_MODE_START_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_END_DRAG_TO_DESKTOP -> "DESKTOP_MODE_END_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP -> "DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP" TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE -> "DESKTOP_MODE_TOGGLE_RESIZE" TRANSIT_DESKTOP_MODE_TASK_LIMIT_MINIMIZE -> "DESKTOP_MODE_TASK_LIMIT_MINIMIZE" TRANSIT_DESKTOP_MODE_DESK_TO_DESK_SWITCH -> "DESKTOP_MODE_DESK_TO_DESK_SWITCH" else -> "" } }
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +44 −6 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ import com.android.wm.shell.desktopmode.desktopfirst.DesktopFirstListenerManager import com.android.wm.shell.desktopmode.desktopfirst.isDisplayDesktopFirst import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.desktopmode.multidesks.DeskSwitchTransitionHandler import com.android.wm.shell.desktopmode.multidesks.DeskTransition import com.android.wm.shell.desktopmode.multidesks.DesksOrganizer import com.android.wm.shell.desktopmode.multidesks.DesksTransitionObserver Loading Loading @@ -247,6 +248,7 @@ class DesktopTasksController( private val userProfileContexts: UserProfileContexts, private val desktopModeCompatPolicy: DesktopModeCompatPolicy, private val windowDragTransitionHandler: WindowDragTransitionHandler, private val deskSwitchTransitionHandler: DeskSwitchTransitionHandler, private val moveToDisplayTransitionHandler: DesktopModeMoveToDisplayTransitionHandler, private val homeIntentProvider: HomeIntentProvider, private val desktopState: DesktopState, Loading Loading @@ -1144,12 +1146,13 @@ class DesktopTasksController( // Deactivate desks of old user. rootTaskDisplayAreaOrganizer.displayIds .toList() .mapNotNull { displayId -> previousRepo.getActiveDeskId(displayId) } .mapNotNull { deskId -> .mapNotNull { displayId -> val deskId = previousRepo.getActiveDeskId(displayId) ?: return@mapNotNull null addDeskDeactivationChanges( wct = wct, deskId = deskId, userId = userChange.previousUserId, displayId = displayId, switchingUser = true, exitReason = ExitReason.UNKNOWN_EXIT, ) Loading Loading @@ -1207,6 +1210,7 @@ class DesktopTasksController( wct = wct, deskId = disconnectedDisplayActiveDesk, userId = userId, displayId = destinationDisplayId, exitReason = ExitReason.DISPLAY_DISCONNECTED, ) } Loading Loading @@ -3287,6 +3291,7 @@ class DesktopTasksController( wct = wct, deskId = deskId, userId = userId, displayId = displayId, exitReason = exitReason, ) } Loading Loading @@ -4911,6 +4916,7 @@ class DesktopTasksController( wct = wct, deskId = deactivatingDesk, userId = userId, displayId = displayId, switchingUser = switchingUser, ExitReason.RETURN_HOME_OR_OVERVIEW, ) Loading Loading @@ -4990,11 +4996,26 @@ class DesktopTasksController( activeDeskId, validDisplay, ) // TODO: b/389957556 - add animation. return } val wct = WindowContainerTransaction() val runOnTransitStart = addDeskActivationChanges( deskId = destinationDeskId, wct = wct, userId = userId, enterReason = enterReason, ) logV("activatePreviousDesk from deskId=%d to deskId=%d", activeDeskId, destinationDeskId) activateDesk(deskId = destinationDeskId, userId = userId, enterReason = enterReason) val transition = deskSwitchTransitionHandler.startTransition( wct = wct, userId = userId, displayId = displayId, fromDeskId = activeDeskId, toDeskId = destinationDeskId, ) runOnTransitStart(transition) } /** Activates the desk at the given index if it exists. */ Loading Loading @@ -5028,11 +5049,26 @@ class DesktopTasksController( activeDeskId, validDisplay, ) // TODO: b/389957556 - add animation. return } val wct = WindowContainerTransaction() val runOnTransitStart = addDeskActivationChanges( deskId = destinationDeskId, wct = wct, userId = userId, enterReason = enterReason, ) logV("activateNextDesk from deskId=%d to deskId=%d", activeDeskId, destinationDeskId) activateDesk(deskId = destinationDeskId, userId = userId, enterReason = enterReason) val transition = deskSwitchTransitionHandler.startTransition( wct = wct, userId = userId, displayId = displayId, fromDeskId = activeDeskId, toDeskId = destinationDeskId, ) runOnTransitStart(transition) } /** Loading Loading @@ -5187,6 +5223,7 @@ class DesktopTasksController( wct: WindowContainerTransaction, deskId: Int?, userId: Int, displayId: Int, switchingUser: Boolean = false, exitReason: ExitReason, ): RunOnTransitStart? { Loading @@ -5199,6 +5236,7 @@ class DesktopTasksController( token = transition, userId = userId, deskId = deskId, displayId = displayId, switchingUser = switchingUser, exitReason = exitReason, runOnTransitEnd = { snapEventHandler.onDeskDeactivated(deskId) }, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopWallpaperActivity.kt +108 −0 Original line number Diff line number Diff line Loading @@ -20,7 +20,11 @@ import android.app.ActivityManager.getCurrentUser import android.app.TaskInfo import android.app.WallpaperColors import android.app.WallpaperManager import android.content.BroadcastReceiver import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.IntentFilter import android.content.res.Configuration import android.hardware.display.DisplayManager import android.os.Bundle Loading @@ -31,6 +35,9 @@ import androidx.activity.addCallback import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.fragment.app.FragmentActivity import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator.Companion.JUMP_CUT_ANIMATION import com.android.wm.shell.desktopmode.multidesks.animation.DeskWallpaperAnimator.Companion.SLIDE_ANIMATION /** * A transparent activity used in the desktop mode to show the wallpaper under the freeform windows. Loading Loading @@ -81,6 +88,14 @@ class DesktopWallpaperActivity : FragmentActivity() { } } private val wallpaperAnimationReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { intent ?: return handleStartWallpaperAnimationRequest(intent) } } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Log.d(TAG, "onCreate") Loading Loading @@ -116,6 +131,20 @@ class DesktopWallpaperActivity : FragmentActivity() { initialDisplayId = displayId } override fun onResume() { super.onResume() registerReceiver( wallpaperAnimationReceiver, IntentFilter(START_WALLPAPER_ANIMATION_ACTION), RECEIVER_EXPORTED, ) } override fun onPause() { unregisterReceiver(wallpaperAnimationReceiver) super.onPause() } override fun onDestroy() { super.onDestroy() wallpaperManager?.removeOnColorsChangedListener(wallpaperColorsListener) Loading Loading @@ -153,10 +182,61 @@ class DesktopWallpaperActivity : FragmentActivity() { private fun getWindowInsetsController(): WindowInsetsControllerCompat = WindowCompat.getInsetsController(window, window.decorView) private fun handleStartWallpaperAnimationRequest(intent: Intent) { Log.d(TAG, "handleStartWallpaperAnimationRequest") if (intent.action != START_WALLPAPER_ANIMATION_ACTION) return val animType = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, JUMP_CUT_ANIMATION) val displayId = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, -1) if (displayId == -1 || displayId != initialDisplayId) return val token = window?.decorView?.rootView?.windowToken ?: return val wm = wallpaperManager ?: return when (animType) { JUMP_CUT_ANIMATION -> { val numberOfDesks = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, -1) val toDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, -1) if (numberOfDesks == -1 || toDeskIndex == -1) { return } DeskWallpaperAnimator.jumpCutAnimator( wallpaperManager = wm, windowToken = token, numberOfDesks = numberOfDesks, toDeskIndex = toDeskIndex, ) .start() } SLIDE_ANIMATION -> { val numberOfDesks = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, -1) val fromDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, -1) val toDeskIndex = intent.getIntExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, -1) if (numberOfDesks == -1 || fromDeskIndex == -1 || toDeskIndex == -1) { return } DeskWallpaperAnimator.slideAnimator( wallpaperManager = wm, windowToken = token, numberOfDesks = numberOfDesks, fromDeskIndex = fromDeskIndex, toDeskIndex = toDeskIndex, ) .start() } } } companion object { private const val TAG = "DesktopWallpaperActivity" private const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui" private const val START_WALLPAPER_ANIMATION_ACTION = "com.android.wm.shell.desktop.action.ANIMATE_WALLPAPER" private const val WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE = "animation_type" private const val WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID = "display_id" private const val WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS = "num_of_desks" private const val WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX = "from_desk_index" private const val WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX = "to_desk_index" @JvmStatic val wallpaperActivityComponent = ComponentName(SYSTEM_UI_PACKAGE_NAME, DesktopWallpaperActivity::class.java.name) Loading @@ -167,5 +247,33 @@ class DesktopWallpaperActivity : FragmentActivity() { @JvmStatic fun isWallpaperComponent(component: ComponentName) = component == wallpaperActivityComponent /** An intent to use in a broadcast to trigger the slide wallpaper animation. */ fun createWallpaperSlideAnimationIntent( displayId: Int, numberOfDesks: Int, fromDeskIndex: Int, toDeskIndex: Int, ): Intent = Intent(START_WALLPAPER_ANIMATION_ACTION).apply { putExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, SLIDE_ANIMATION) putExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, displayId) putExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, numberOfDesks) putExtra(WALLPAPER_ANIMATION_EXTRA_FROM_DESK_INDEX, fromDeskIndex) putExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, toDeskIndex) } /** An intent to use in a broadcast to trigger the no-animation wallpaper animation. */ fun createWallpaperNoAnimationIntent( displayId: Int, numberOfDesks: Int, deskIndex: Int, ): Intent = Intent(START_WALLPAPER_ANIMATION_ACTION).apply { putExtra(WALLPAPER_ANIMATION_EXTRA_ANIM_TYPE, JUMP_CUT_ANIMATION) putExtra(WALLPAPER_ANIMATION_EXTRA_DISPLAY_ID, displayId) putExtra(WALLPAPER_ANIMATION_EXTRA_NUM_OF_DESKS, numberOfDesks) putExtra(WALLPAPER_ANIMATION_EXTRA_TO_DESK_INDEX, deskIndex) } } }
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/data/DesktopRepository.kt +8 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,14 @@ class DesktopRepository( /** Returns the default desk in the given display. */ private fun getDefaultDesk(displayId: Int): Desk? = desktopData.getDefaultDesk(displayId) /** Returns the index of the given desk in the ordered list of desks. */ fun getDeskPosition(deskId: Int): Int? { val desks = desktopData.getOrderedDesks(getDisplayForDesk(deskId)) val index = desks.indexOfFirst { it.deskId == deskId } if (index < 0) return null return index } /** Returns the id of the desk ordered previous to the given one, or null if there isn't one. */ fun getPreviousDeskId(deskId: Int): Int? { val desks = desktopData.getOrderedDesks(getDisplayForDesk(deskId)) Loading