• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.wm.shell.desktopmode.multidesks
17 
18 import android.app.ActivityManager
19 import android.window.TransitionInfo
20 import android.window.WindowContainerTransaction
21 
22 /** An organizer of desk containers in which to host child desktop windows. */
23 interface DesksOrganizer {
24     /** Creates a new desk container to use in the given display for the given user. */
createDesknull25     fun createDesk(displayId: Int, userId: Int, callback: OnCreateCallback)
26 
27     /** Activates the given desk, making it visible in its display. */
28     fun activateDesk(wct: WindowContainerTransaction, deskId: Int)
29 
30     /** Deactivates the given desk, removing it as the default launch container for new tasks. */
31     fun deactivateDesk(wct: WindowContainerTransaction, deskId: Int)
32 
33     /** Removes the given desk of the given user. */
34     fun removeDesk(wct: WindowContainerTransaction, deskId: Int, userId: Int)
35 
36     /** Moves the given task to the given desk. */
37     fun moveTaskToDesk(
38         wct: WindowContainerTransaction,
39         deskId: Int,
40         task: ActivityManager.RunningTaskInfo,
41     )
42 
43     /** Reorders a desk's task to the front. */
44     fun reorderTaskToFront(
45         wct: WindowContainerTransaction,
46         deskId: Int,
47         task: ActivityManager.RunningTaskInfo,
48     )
49 
50     /** Minimizes the given task of the given deskId. */
51     fun minimizeTask(
52         wct: WindowContainerTransaction,
53         deskId: Int,
54         task: ActivityManager.RunningTaskInfo,
55     )
56 
57     /** Unminimize the given task of the given desk. */
58     fun unminimizeTask(
59         wct: WindowContainerTransaction,
60         deskId: Int,
61         task: ActivityManager.RunningTaskInfo,
62     )
63 
64     /** Whether the change is for the given desk id. */
65     fun isDeskChange(change: TransitionInfo.Change, deskId: Int): Boolean
66 
67     /** Whether the change is for a known desk. */
68     fun isDeskChange(change: TransitionInfo.Change): Boolean
69 
70     /**
71      * Returns the desk id in which the task in the given change is located at the end of a
72      * transition, if any.
73      */
74     fun getDeskAtEnd(change: TransitionInfo.Change): Int?
75 
76     /** Whether the desk is activate according to the given change at the end of a transition. */
77     fun isDeskActiveAtEnd(change: TransitionInfo.Change, deskId: Int): Boolean
78 
79     /** Allows for other classes to respond to task changes this organizer receives. */
80     fun setOnDesktopTaskInfoChangedListener(listener: (ActivityManager.RunningTaskInfo) -> Unit)
81 
82     /** A callback that is invoked when the desk container is created. */
83     fun interface OnCreateCallback {
84         /** Calls back when the [deskId] has been created. */
85         fun onCreated(deskId: Int)
86     }
87 }
88