1 /**
2  * Copyright (c) 2014, 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 
17 package android.app;
18 
19 import android.app.ActivityManager;
20 import android.content.ComponentName;
21 
22 /** @hide */
23 oneway interface ITaskStackListener {
24     /** Activity was resized to be displayed in split-screen. */
25     const int FORCED_RESIZEABLE_REASON_SPLIT_SCREEN = 1;
26     /** Activity was resized to be displayed on a secondary display. */
27     const int FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY = 2;
28 
29     /** Called whenever there are changes to the state of tasks in a stack. */
onTaskStackChanged()30     void onTaskStackChanged();
31 
32     /** Called whenever an Activity is moved to the pinned stack from another stack. */
onActivityPinned(String packageName, int userId, int taskId, int stackId)33     void onActivityPinned(String packageName, int userId, int taskId, int stackId);
34 
35     /** Called whenever an Activity is moved from the pinned stack to another stack. */
onActivityUnpinned()36     void onActivityUnpinned();
37 
38     /**
39      * Called whenever IActivityManager.startActivity is called on an activity that is already
40      * running in the pinned stack and the activity is not actually started, but the task is either
41      * brought to the front or a new Intent is delivered to it.
42      *
43      * @param clearedTask whether or not the launch activity also cleared the task as a part of
44      * starting
45      */
onPinnedActivityRestartAttempt(boolean clearedTask)46     void onPinnedActivityRestartAttempt(boolean clearedTask);
47 
48     /**
49      * Called whenever the pinned stack is starting animating a resize.
50      */
onPinnedStackAnimationStarted()51     void onPinnedStackAnimationStarted();
52 
53     /**
54      * Called whenever the pinned stack is done animating a resize.
55      */
onPinnedStackAnimationEnded()56     void onPinnedStackAnimationEnded();
57 
58     /**
59      * Called when we launched an activity that we forced to be resizable.
60      *
61      * @param packageName Package name of the top activity in the task.
62      * @param taskId Id of the task.
63      * @param reason {@link #FORCED_RESIZEABLE_REASON_SPLIT_SCREEN} or
64       *              {@link #FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY}.
65      */
onActivityForcedResizable(String packageName, int taskId, int reason)66     void onActivityForcedResizable(String packageName, int taskId, int reason);
67 
68     /**
69      * Called when we launched an activity that dismissed the docked stack.
70      */
onActivityDismissingDockedStack()71     void onActivityDismissingDockedStack();
72 
73     /**
74      * Called when an activity was requested to be launched on a secondary display but was not
75      * allowed there.
76      *
77      * @param taskInfo info about the Activity's task
78      * @param requestedDisplayId the id of the requested launch display
79      */
onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo, int requestedDisplayId)80     void onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo,
81             int requestedDisplayId);
82 
83     /**
84      * Called when an activity was requested to be launched on a secondary display but was rerouted
85      * to default display.
86      *
87      * @param taskInfo info about the Activity's task
88      * @param requestedDisplayId the id of the requested launch display
89      */
onActivityLaunchOnSecondaryDisplayRerouted(in ActivityManager.RunningTaskInfo taskInfo, int requestedDisplayId)90     void onActivityLaunchOnSecondaryDisplayRerouted(in ActivityManager.RunningTaskInfo taskInfo,
91                 int requestedDisplayId);
92 
93     /**
94      * Called when a task is added.
95      *
96      * @param taskId id of the task.
97      * @param componentName of the activity that the task is being started with.
98     */
onTaskCreated(int taskId, in ComponentName componentName)99     void onTaskCreated(int taskId, in ComponentName componentName);
100 
101     /**
102      * Called when a task is removed.
103      *
104      * @param taskId id of the task.
105     */
onTaskRemoved(int taskId)106     void onTaskRemoved(int taskId);
107 
108     /**
109      * Called when a task is moved to the front of its stack.
110      *
111      * @param taskInfo info about the task which moved
112     */
onTaskMovedToFront(in ActivityManager.RunningTaskInfo taskInfo)113     void onTaskMovedToFront(in ActivityManager.RunningTaskInfo taskInfo);
114 
115     /**
116      * Called when a task’s description is changed due to an activity calling
117      * ActivityManagerService.setTaskDescription
118      *
119      * @param taskInfo info about the task which changed, with {@link TaskInfo#taskDescription}
120     */
onTaskDescriptionChanged(in ActivityManager.RunningTaskInfo taskInfo)121     void onTaskDescriptionChanged(in ActivityManager.RunningTaskInfo taskInfo);
122 
123     /**
124      * Called when a activity’s orientation is changed due to it calling
125      * ActivityManagerService.setRequestedOrientation
126      *
127      * @param taskId id of the task that the activity is in.
128      * @param requestedOrientation the new requested orientation.
129     */
onActivityRequestedOrientationChanged(int taskId, int requestedOrientation)130     void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation);
131 
132     /**
133      * Called when the task is about to be finished but before its surfaces are
134      * removed from the window manager. This allows interested parties to
135      * perform relevant animations before the window disappears.
136      *
137      * @param taskInfo info about the task being removed
138      */
onTaskRemovalStarted(in ActivityManager.RunningTaskInfo taskInfo)139     void onTaskRemovalStarted(in ActivityManager.RunningTaskInfo taskInfo);
140 
141     /**
142      * Called when the task has been put in a locked state because one or more of the
143      * activities inside it belong to a managed profile user, and that user has just
144      * been locked.
145      */
onTaskProfileLocked(int taskId, int userId)146     void onTaskProfileLocked(int taskId, int userId);
147 
148     /**
149      * Called when a task snapshot got updated.
150      */
onTaskSnapshotChanged(int taskId, in ActivityManager.TaskSnapshot snapshot)151     void onTaskSnapshotChanged(int taskId, in ActivityManager.TaskSnapshot snapshot);
152 
153     /**
154      * Called when the resumed activity is in size compatibility mode and its override configuration
155      * is different from the current one of system.
156      *
157      * @param displayId Id of the display where the activity resides.
158      * @param activityToken Token of the size compatibility mode activity. It will be null when
159      *                      switching to a activity that is not in size compatibility mode or the
160      *                      configuration of the activity.
161      * @see com.android.server.wm.AppWindowToken#inSizeCompatMode
162      */
onSizeCompatModeActivityChanged(int displayId, in IBinder activityToken)163     void onSizeCompatModeActivityChanged(int displayId, in IBinder activityToken);
164 
165     /**
166      * Reports that an Activity received a back key press when there were no additional activities
167      * on the back stack.
168      *
169      * @param taskInfo info about the task which received the back press
170      */
onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo)171     void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo);
172 
173     /*
174      * Called when contents are drawn for the first time on a display which can only contain one
175      * task.
176      *
177      * @param displayId the id of the display on which contents are drawn.
178      */
onSingleTaskDisplayDrawn(int displayId)179     void onSingleTaskDisplayDrawn(int displayId);
180 
181     /*
182      * Called when the last task is removed from a display which can only contain one task.
183      *
184      * @param displayId the id of the display from which the window is removed.
185      */
onSingleTaskDisplayEmpty(int displayId)186     void onSingleTaskDisplayEmpty(int displayId);
187 
188     /**
189      * Called when a task is reparented to a stack on a different display.
190      *
191      * @param taskId id of the task which was moved to a different display.
192      * @param newDisplayId id of the new display.
193      */
onTaskDisplayChanged(int taskId, int newDisplayId)194     void onTaskDisplayChanged(int taskId, int newDisplayId);
195 }
196