Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +13 −2 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import com.android.wm.shell.desktopmode.SpringDragToDesktopTransitionHandler; import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler; import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository; import com.android.wm.shell.desktopmode.compatui.SystemModalsTransitionHandler; import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider; import com.android.wm.shell.desktopmode.education.AppHandleEducationController; import com.android.wm.shell.desktopmode.education.AppHandleEducationFilter; import com.android.wm.shell.desktopmode.education.AppToWebEducationController; Loading Loading @@ -733,7 +734,8 @@ public abstract class WMShellModule { FocusTransitionObserver focusTransitionObserver, DesktopModeEventLogger desktopModeEventLogger, DesktopModeUiEventLogger desktopModeUiEventLogger, DesktopTilingDecorViewModel desktopTilingDecorViewModel) { DesktopTilingDecorViewModel desktopTilingDecorViewModel, DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider) { return new DesktopTasksController( context, shellInit, Loading Loading @@ -764,7 +766,8 @@ public abstract class WMShellModule { mainHandler, desktopModeEventLogger, desktopModeUiEventLogger, desktopTilingDecorViewModel); desktopTilingDecorViewModel, desktopWallpaperActivityTokenProvider); } @WMSingleton Loading Loading @@ -1092,6 +1095,7 @@ public abstract class WMShellModule { ShellTaskOrganizer shellTaskOrganizer, Optional<DesktopMixedTransitionHandler> desktopMixedTransitionHandler, Optional<BackAnimationController> backAnimationController, DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider, ShellInit shellInit) { return desktopUserRepositories.flatMap( repository -> Loading @@ -1103,6 +1107,7 @@ public abstract class WMShellModule { shellTaskOrganizer, desktopMixedTransitionHandler.get(), backAnimationController.get(), desktopWallpaperActivityTokenProvider, shellInit))); } Loading Loading @@ -1306,6 +1311,12 @@ public abstract class WMShellModule { return new DesktopModeUiEventLogger(uiEventLogger, packageManager); } @WMSingleton @Provides static DesktopWallpaperActivityTokenProvider provideDesktopWallpaperActivityTokenProvider() { return new DesktopWallpaperActivityTokenProvider(); } // // Drag and drop // Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +0 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.util.ArraySet import android.util.SparseArray import android.view.Display.INVALID_DISPLAY import android.window.DesktopModeFlags import android.window.WindowContainerToken import androidx.core.util.forEach import androidx.core.util.keyIterator import androidx.core.util.valueIterator Loading Loading @@ -90,9 +89,6 @@ class DesktopRepository( } } /* Current wallpaper activity token to remove wallpaper activity when last task is removed. */ var wallpaperActivityToken: WindowContainerToken? = null private val activeTasksListeners = ArraySet<ActiveTasksListener>() private val visibleTasksListeners = ArrayMap<VisibleTasksListener, Executor>() Loading Loading @@ -549,7 +545,6 @@ class DesktopRepository( "${innerPrefix}topTransparentFullscreenTaskId=" + "${data.topTransparentFullscreenTaskId}" ) pw.println("${innerPrefix}wallpaperActivityToken=$wallpaperActivityToken") } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +4 −4 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.DragToDes import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FREEFORM_ANIMATION_DURATION import com.android.wm.shell.desktopmode.ExitDesktopTaskTransitionHandler.FULLSCREEN_ANIMATION_DURATION import com.android.wm.shell.desktopmode.common.ToggleTaskSizeInteraction import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.draganddrop.DragAndDropController import com.android.wm.shell.freeform.FreeformTaskTransitionStarter Loading Loading @@ -170,6 +171,7 @@ class DesktopTasksController( private val desktopModeEventLogger: DesktopModeEventLogger, private val desktopModeUiEventLogger: DesktopModeUiEventLogger, private val desktopTilingDecorViewModel: DesktopTilingDecorViewModel, private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, ) : RemoteCallable<DesktopTasksController>, Transitions.TransitionHandler, Loading Loading @@ -1366,7 +1368,7 @@ class DesktopTasksController( } private fun removeWallpaperActivity(wct: WindowContainerTransaction) { taskRepository.wallpaperActivityToken?.let { token -> desktopWallpaperActivityTokenProvider.getToken()?.let { token -> logV("removeWallpaperActivity") wct.removeTask(token) } Loading Loading @@ -1396,10 +1398,8 @@ class DesktopTasksController( desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION ) if (taskRepository.wallpaperActivityToken != null) { removeWallpaperActivity(wct) } } fun releaseVisualIndicator() { val t = SurfaceControl.Transaction() Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +10 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.internal.protolog.ProtoLog import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.isExitDesktopModeTransition import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.shared.TransitionUtil import com.android.wm.shell.shared.desktopmode.DesktopModeStatus Loading @@ -50,6 +51,7 @@ class DesktopTasksTransitionObserver( private val shellTaskOrganizer: ShellTaskOrganizer, private val desktopMixedTransitionHandler: DesktopMixedTransitionHandler, private val backAnimationController: BackAnimationController, private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, shellInit: ShellInit, ) : Transitions.TransitionObserver { Loading Loading @@ -212,7 +214,7 @@ class DesktopTasksTransitionObserver( desktopRepository.getVisibleTaskCount(taskInfo.displayId) == 0 && change.mode == TRANSIT_CLOSE && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM && desktopRepository.wallpaperActivityToken != null desktopWallpaperActivityTokenProvider.getToken() != null ) { transitionToCloseWallpaper = transition currentProfileId = taskInfo.userId Loading @@ -232,8 +234,7 @@ class DesktopTasksTransitionObserver( // TODO: b/332682201 Update repository state if (transitionToCloseWallpaper == transition) { // TODO: b/362469671 - Handle merging the animation when desktop is also closing. val desktopRepository = desktopUserRepositories.getProfile(currentProfileId) desktopRepository.wallpaperActivityToken?.let { wallpaperActivityToken -> desktopWallpaperActivityTokenProvider.getToken()?.let { wallpaperActivityToken -> transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(wallpaperActivityToken), Loading @@ -251,10 +252,12 @@ class DesktopTasksTransitionObserver( info.changes.forEach { change -> change.taskInfo?.let { taskInfo -> if (DesktopWallpaperActivity.isWallpaperTask(taskInfo)) { val desktopRepository = desktopUserRepositories.getProfile(taskInfo.userId) when (change.mode) { WindowManager.TRANSIT_OPEN -> { desktopRepository.wallpaperActivityToken = taskInfo.token desktopWallpaperActivityTokenProvider.setToken( taskInfo.token, taskInfo.displayId, ) // After the task for the wallpaper is created, set it non-trimmable. // This is important to prevent recents from trimming and removing the // task. Loading @@ -263,7 +266,8 @@ class DesktopTasksTransitionObserver( .setTaskTrimmableFromRecents(taskInfo.token, false) ) } TRANSIT_CLOSE -> desktopRepository.wallpaperActivityToken = null TRANSIT_CLOSE -> desktopWallpaperActivityTokenProvider.removeToken(taskInfo.displayId) else -> {} } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/desktopwallpaperactivity/DesktopWallpaperActivityTokenProvider.kt 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.desktopmode.desktopwallpaperactivity import android.util.SparseArray import android.view.Display.DEFAULT_DISPLAY import android.window.WindowContainerToken /** Provides per display window container tokens for [DesktopWallpaperActivity]. */ class DesktopWallpaperActivityTokenProvider { private val wallpaperActivityTokenByDisplayId = SparseArray<WindowContainerToken>() fun setToken(token: WindowContainerToken, displayId: Int = DEFAULT_DISPLAY) { wallpaperActivityTokenByDisplayId[displayId] = token } fun getToken(displayId: Int = DEFAULT_DISPLAY): WindowContainerToken? { return wallpaperActivityTokenByDisplayId[displayId] } fun removeToken(displayId: Int = DEFAULT_DISPLAY) { wallpaperActivityTokenByDisplayId.delete(displayId) } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +13 −2 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import com.android.wm.shell.desktopmode.SpringDragToDesktopTransitionHandler; import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler; import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository; import com.android.wm.shell.desktopmode.compatui.SystemModalsTransitionHandler; import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider; import com.android.wm.shell.desktopmode.education.AppHandleEducationController; import com.android.wm.shell.desktopmode.education.AppHandleEducationFilter; import com.android.wm.shell.desktopmode.education.AppToWebEducationController; Loading Loading @@ -733,7 +734,8 @@ public abstract class WMShellModule { FocusTransitionObserver focusTransitionObserver, DesktopModeEventLogger desktopModeEventLogger, DesktopModeUiEventLogger desktopModeUiEventLogger, DesktopTilingDecorViewModel desktopTilingDecorViewModel) { DesktopTilingDecorViewModel desktopTilingDecorViewModel, DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider) { return new DesktopTasksController( context, shellInit, Loading Loading @@ -764,7 +766,8 @@ public abstract class WMShellModule { mainHandler, desktopModeEventLogger, desktopModeUiEventLogger, desktopTilingDecorViewModel); desktopTilingDecorViewModel, desktopWallpaperActivityTokenProvider); } @WMSingleton Loading Loading @@ -1092,6 +1095,7 @@ public abstract class WMShellModule { ShellTaskOrganizer shellTaskOrganizer, Optional<DesktopMixedTransitionHandler> desktopMixedTransitionHandler, Optional<BackAnimationController> backAnimationController, DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider, ShellInit shellInit) { return desktopUserRepositories.flatMap( repository -> Loading @@ -1103,6 +1107,7 @@ public abstract class WMShellModule { shellTaskOrganizer, desktopMixedTransitionHandler.get(), backAnimationController.get(), desktopWallpaperActivityTokenProvider, shellInit))); } Loading Loading @@ -1306,6 +1311,12 @@ public abstract class WMShellModule { return new DesktopModeUiEventLogger(uiEventLogger, packageManager); } @WMSingleton @Provides static DesktopWallpaperActivityTokenProvider provideDesktopWallpaperActivityTokenProvider() { return new DesktopWallpaperActivityTokenProvider(); } // // Drag and drop // Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +0 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.util.ArraySet import android.util.SparseArray import android.view.Display.INVALID_DISPLAY import android.window.DesktopModeFlags import android.window.WindowContainerToken import androidx.core.util.forEach import androidx.core.util.keyIterator import androidx.core.util.valueIterator Loading Loading @@ -90,9 +89,6 @@ class DesktopRepository( } } /* Current wallpaper activity token to remove wallpaper activity when last task is removed. */ var wallpaperActivityToken: WindowContainerToken? = null private val activeTasksListeners = ArraySet<ActiveTasksListener>() private val visibleTasksListeners = ArrayMap<VisibleTasksListener, Executor>() Loading Loading @@ -549,7 +545,6 @@ class DesktopRepository( "${innerPrefix}topTransparentFullscreenTaskId=" + "${data.topTransparentFullscreenTaskId}" ) pw.println("${innerPrefix}wallpaperActivityToken=$wallpaperActivityToken") } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +4 −4 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.DragToDes import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FREEFORM_ANIMATION_DURATION import com.android.wm.shell.desktopmode.ExitDesktopTaskTransitionHandler.FULLSCREEN_ANIMATION_DURATION import com.android.wm.shell.desktopmode.common.ToggleTaskSizeInteraction import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.draganddrop.DragAndDropController import com.android.wm.shell.freeform.FreeformTaskTransitionStarter Loading Loading @@ -170,6 +171,7 @@ class DesktopTasksController( private val desktopModeEventLogger: DesktopModeEventLogger, private val desktopModeUiEventLogger: DesktopModeUiEventLogger, private val desktopTilingDecorViewModel: DesktopTilingDecorViewModel, private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, ) : RemoteCallable<DesktopTasksController>, Transitions.TransitionHandler, Loading Loading @@ -1366,7 +1368,7 @@ class DesktopTasksController( } private fun removeWallpaperActivity(wct: WindowContainerTransaction) { taskRepository.wallpaperActivityToken?.let { token -> desktopWallpaperActivityTokenProvider.getToken()?.let { token -> logV("removeWallpaperActivity") wct.removeTask(token) } Loading Loading @@ -1396,10 +1398,8 @@ class DesktopTasksController( desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION ) if (taskRepository.wallpaperActivityToken != null) { removeWallpaperActivity(wct) } } fun releaseVisualIndicator() { val t = SurfaceControl.Transaction() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +10 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.internal.protolog.ProtoLog import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.isExitDesktopModeTransition import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.shared.TransitionUtil import com.android.wm.shell.shared.desktopmode.DesktopModeStatus Loading @@ -50,6 +51,7 @@ class DesktopTasksTransitionObserver( private val shellTaskOrganizer: ShellTaskOrganizer, private val desktopMixedTransitionHandler: DesktopMixedTransitionHandler, private val backAnimationController: BackAnimationController, private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, shellInit: ShellInit, ) : Transitions.TransitionObserver { Loading Loading @@ -212,7 +214,7 @@ class DesktopTasksTransitionObserver( desktopRepository.getVisibleTaskCount(taskInfo.displayId) == 0 && change.mode == TRANSIT_CLOSE && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM && desktopRepository.wallpaperActivityToken != null desktopWallpaperActivityTokenProvider.getToken() != null ) { transitionToCloseWallpaper = transition currentProfileId = taskInfo.userId Loading @@ -232,8 +234,7 @@ class DesktopTasksTransitionObserver( // TODO: b/332682201 Update repository state if (transitionToCloseWallpaper == transition) { // TODO: b/362469671 - Handle merging the animation when desktop is also closing. val desktopRepository = desktopUserRepositories.getProfile(currentProfileId) desktopRepository.wallpaperActivityToken?.let { wallpaperActivityToken -> desktopWallpaperActivityTokenProvider.getToken()?.let { wallpaperActivityToken -> transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(wallpaperActivityToken), Loading @@ -251,10 +252,12 @@ class DesktopTasksTransitionObserver( info.changes.forEach { change -> change.taskInfo?.let { taskInfo -> if (DesktopWallpaperActivity.isWallpaperTask(taskInfo)) { val desktopRepository = desktopUserRepositories.getProfile(taskInfo.userId) when (change.mode) { WindowManager.TRANSIT_OPEN -> { desktopRepository.wallpaperActivityToken = taskInfo.token desktopWallpaperActivityTokenProvider.setToken( taskInfo.token, taskInfo.displayId, ) // After the task for the wallpaper is created, set it non-trimmable. // This is important to prevent recents from trimming and removing the // task. Loading @@ -263,7 +266,8 @@ class DesktopTasksTransitionObserver( .setTaskTrimmableFromRecents(taskInfo.token, false) ) } TRANSIT_CLOSE -> desktopRepository.wallpaperActivityToken = null TRANSIT_CLOSE -> desktopWallpaperActivityTokenProvider.removeToken(taskInfo.displayId) else -> {} } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/desktopwallpaperactivity/DesktopWallpaperActivityTokenProvider.kt 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.desktopmode.desktopwallpaperactivity import android.util.SparseArray import android.view.Display.DEFAULT_DISPLAY import android.window.WindowContainerToken /** Provides per display window container tokens for [DesktopWallpaperActivity]. */ class DesktopWallpaperActivityTokenProvider { private val wallpaperActivityTokenByDisplayId = SparseArray<WindowContainerToken>() fun setToken(token: WindowContainerToken, displayId: Int = DEFAULT_DISPLAY) { wallpaperActivityTokenByDisplayId[displayId] = token } fun getToken(displayId: Int = DEFAULT_DISPLAY): WindowContainerToken? { return wallpaperActivityTokenByDisplayId[displayId] } fun removeToken(displayId: Int = DEFAULT_DISPLAY) { wallpaperActivityTokenByDisplayId.delete(displayId) } }