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 import android.window.TaskSnapshot; 22 23 /** @hide */ 24 oneway interface ITaskStackListener { 25 /** Activity was resized to be displayed in split-screen. */ 26 const int FORCED_RESIZEABLE_REASON_SPLIT_SCREEN = 1; 27 /** Activity was resized to be displayed on a secondary display. */ 28 const int FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY = 2; 29 30 /** Called whenever there are changes to the state of tasks in a stack. */ onTaskStackChanged()31 void onTaskStackChanged(); 32 33 /** Called whenever an Activity is moved to the pinned stack from another stack. */ onActivityPinned(String packageName, int userId, int taskId, int stackId)34 void onActivityPinned(String packageName, int userId, int taskId, int stackId); 35 36 /** Called whenever an Activity is moved from the pinned stack to another stack. */ onActivityUnpinned()37 void onActivityUnpinned(); 38 39 /** 40 * Called whenever IActivityManager.startActivity is called on an activity that is already 41 * running, but the task is either brought to the front or a new Intent is delivered to it. 42 * 43 * @param task information about the task the activity was relaunched into 44 * @param homeVisible whether or not the home task is visible 45 * @param clearedTask whether or not the launch activity also cleared the task as a part of 46 * starting 47 * @param wasVisible whether the activity was visible before the restart attempt 48 */ onActivityRestartAttempt(in ActivityManager.RunningTaskInfo task, boolean homeTaskVisible, boolean clearedTask, boolean wasVisible)49 void onActivityRestartAttempt(in ActivityManager.RunningTaskInfo task, boolean homeTaskVisible, 50 boolean clearedTask, boolean wasVisible); 51 52 /** 53 * Called when we launched an activity that we forced to be resizable. 54 * 55 * @param packageName Package name of the top activity in the task. 56 * @param taskId Id of the task. 57 * @param reason {@link #FORCED_RESIZEABLE_REASON_SPLIT_SCREEN} or 58 * {@link #FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY}. 59 */ onActivityForcedResizable(String packageName, int taskId, int reason)60 void onActivityForcedResizable(String packageName, int taskId, int reason); 61 62 /** 63 * Called when we launched an activity that dismissed the docked task. 64 */ onActivityDismissingDockedTask()65 void onActivityDismissingDockedTask(); 66 67 /** 68 * Called when an activity was requested to be launched on a secondary display but was not 69 * allowed there. 70 * 71 * @param taskInfo info about the Activity's task 72 * @param requestedDisplayId the id of the requested launch display 73 */ onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo, int requestedDisplayId)74 void onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo, 75 int requestedDisplayId); 76 77 /** 78 * Called when an activity was requested to be launched on a secondary display but was rerouted 79 * to default display. 80 * 81 * @param taskInfo info about the Activity's task 82 * @param requestedDisplayId the id of the requested launch display 83 */ onActivityLaunchOnSecondaryDisplayRerouted(in ActivityManager.RunningTaskInfo taskInfo, int requestedDisplayId)84 void onActivityLaunchOnSecondaryDisplayRerouted(in ActivityManager.RunningTaskInfo taskInfo, 85 int requestedDisplayId); 86 87 /** 88 * Called when a task is added. 89 * 90 * @param taskId id of the task. 91 * @param componentName of the activity that the task is being started with. 92 */ onTaskCreated(int taskId, in ComponentName componentName)93 void onTaskCreated(int taskId, in ComponentName componentName); 94 95 /** 96 * Called when a task is removed. 97 * 98 * @param taskId id of the task. 99 */ onTaskRemoved(int taskId)100 void onTaskRemoved(int taskId); 101 102 /** 103 * Called when a task is moved to the front of its stack. 104 * 105 * @param taskInfo info about the task which moved 106 */ onTaskMovedToFront(in ActivityManager.RunningTaskInfo taskInfo)107 void onTaskMovedToFront(in ActivityManager.RunningTaskInfo taskInfo); 108 109 /** 110 * Called when a task’s description is changed due to an activity calling 111 * ActivityManagerService.setTaskDescription 112 * 113 * @param taskInfo info about the task which changed, with {@link TaskInfo#taskDescription} 114 */ onTaskDescriptionChanged(in ActivityManager.RunningTaskInfo taskInfo)115 void onTaskDescriptionChanged(in ActivityManager.RunningTaskInfo taskInfo); 116 117 /** 118 * Called when a activity’s orientation is changed due to it calling 119 * ActivityManagerService.setRequestedOrientation 120 * 121 * @param taskId id of the task that the activity is in. 122 * @param requestedOrientation the new requested orientation. 123 */ onActivityRequestedOrientationChanged(int taskId, int requestedOrientation)124 void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation); 125 126 /** 127 * Called when the task is about to be finished but before its surfaces are 128 * removed from the window manager. This allows interested parties to 129 * perform relevant animations before the window disappears. 130 * 131 * @param taskInfo info about the task being removed 132 */ onTaskRemovalStarted(in ActivityManager.RunningTaskInfo taskInfo)133 void onTaskRemovalStarted(in ActivityManager.RunningTaskInfo taskInfo); 134 135 /** 136 * Called when the task has been put in a locked state because one or more of the 137 * activities inside it belong to a managed profile user, and that user has just 138 * been locked. 139 */ onTaskProfileLocked(in ActivityManager.RunningTaskInfo taskInfo, int userId)140 void onTaskProfileLocked(in ActivityManager.RunningTaskInfo taskInfo, int userId); 141 142 /** 143 * Called when a task snapshot got updated. 144 */ onTaskSnapshotChanged(int taskId, in TaskSnapshot snapshot)145 void onTaskSnapshotChanged(int taskId, in TaskSnapshot snapshot); 146 147 /** 148 * Called when a task snapshot become invalidated. 149 */ onTaskSnapshotInvalidated(int taskId)150 void onTaskSnapshotInvalidated(int taskId); 151 152 /** 153 * Reports that an Activity received a back key press when there were no additional activities 154 * on the back stack. 155 * 156 * @param taskInfo info about the task which received the back press 157 */ onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo)158 void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo); 159 160 /** 161 * Called when a task is reparented to a stack on a different display. 162 * 163 * @param taskId id of the task which was moved to a different display. 164 * @param newDisplayId id of the new display. 165 */ onTaskDisplayChanged(int taskId, int newDisplayId)166 void onTaskDisplayChanged(int taskId, int newDisplayId); 167 168 /** 169 * Called when any additions or deletions to the recent tasks list have been made. 170 */ onRecentTaskListUpdated()171 void onRecentTaskListUpdated(); 172 173 /** 174 * Called when Recent Tasks list is frozen or unfrozen. 175 * 176 * @param frozen if true, Recents Tasks list is currently frozen, false otherwise 177 */ onRecentTaskListFrozenChanged(boolean frozen)178 void onRecentTaskListFrozenChanged(boolean frozen); 179 180 /** 181 * Called when a task gets or loses focus. 182 * 183 * @param taskId id of the task. 184 * @param {@code true} if the task got focus, {@code false} if it lost it. 185 */ onTaskFocusChanged(int taskId, boolean focused)186 void onTaskFocusChanged(int taskId, boolean focused); 187 188 /** 189 * Called when a task changes its requested orientation. It is different from {@link 190 * #onActivityRequestedOrientationChanged(int, int)} in the sense that this method is called 191 * when a task changes requested orientation due to activity launch, dimiss or reparenting. 192 * 193 * @param taskId id of the task. 194 * @param requestedOrientation the new requested orientation of this task as screen orientations 195 * in {@link android.content.pm.ActivityInfo}. 196 */ onTaskRequestedOrientationChanged(int taskId, int requestedOrientation)197 void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation); 198 199 /** 200 * Called when a rotation is about to start on the foreground activity. 201 * This applies for: 202 * * free sensor rotation 203 * * forced rotation 204 * * rotation settings set through adb command line 205 * * rotation that occurs when rotation tile is toggled in quick settings 206 * 207 * @param displayId id of the display where activity will rotate 208 */ onActivityRotation(int displayId)209 void onActivityRotation(int displayId); 210 211 /** 212 * Called when a task is moved to the back behind the home stack. 213 * 214 * @param taskInfo info about the task which moved 215 */ onTaskMovedToBack(in ActivityManager.RunningTaskInfo taskInfo)216 void onTaskMovedToBack(in ActivityManager.RunningTaskInfo taskInfo); 217 218 /** 219 * Called when the lock task mode changes. See ActivityManager#LOCK_TASK_MODE_* and 220 * LockTaskController. 221 */ onLockTaskModeChanged(int mode)222 void onLockTaskModeChanged(int mode); 223 } 224