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 * Reports that an Activity received a back key press when there were no additional activities 149 * on the back stack. 150 * 151 * @param taskInfo info about the task which received the back press 152 */ onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo)153 void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo); 154 155 /** 156 * Called when a task is reparented to a stack on a different display. 157 * 158 * @param taskId id of the task which was moved to a different display. 159 * @param newDisplayId id of the new display. 160 */ onTaskDisplayChanged(int taskId, int newDisplayId)161 void onTaskDisplayChanged(int taskId, int newDisplayId); 162 163 /** 164 * Called when any additions or deletions to the recent tasks list have been made. 165 */ onRecentTaskListUpdated()166 void onRecentTaskListUpdated(); 167 168 /** 169 * Called when Recent Tasks list is frozen or unfrozen. 170 * 171 * @param frozen if true, Recents Tasks list is currently frozen, false otherwise 172 */ onRecentTaskListFrozenChanged(boolean frozen)173 void onRecentTaskListFrozenChanged(boolean frozen); 174 175 /** 176 * Called when a task gets or loses focus. 177 * 178 * @param taskId id of the task. 179 * @param {@code true} if the task got focus, {@code false} if it lost it. 180 */ onTaskFocusChanged(int taskId, boolean focused)181 void onTaskFocusChanged(int taskId, boolean focused); 182 183 /** 184 * Called when a task changes its requested orientation. It is different from {@link 185 * #onActivityRequestedOrientationChanged(int, int)} in the sense that this method is called 186 * when a task changes requested orientation due to activity launch, dimiss or reparenting. 187 * 188 * @param taskId id of the task. 189 * @param requestedOrientation the new requested orientation of this task as screen orientations 190 * in {@link android.content.pm.ActivityInfo}. 191 */ onTaskRequestedOrientationChanged(int taskId, int requestedOrientation)192 void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation); 193 194 /** 195 * Called when a rotation is about to start on the foreground activity. 196 * This applies for: 197 * * free sensor rotation 198 * * forced rotation 199 * * rotation settings set through adb command line 200 * * rotation that occurs when rotation tile is toggled in quick settings 201 * 202 * @param displayId id of the display where activity will rotate 203 */ onActivityRotation(int displayId)204 void onActivityRotation(int displayId); 205 206 /** 207 * Called when a task is moved to the back behind the home stack. 208 * 209 * @param taskInfo info about the task which moved 210 */ onTaskMovedToBack(in ActivityManager.RunningTaskInfo taskInfo)211 void onTaskMovedToBack(in ActivityManager.RunningTaskInfo taskInfo); 212 213 /** 214 * Called when the lock task mode changes. See ActivityManager#LOCK_TASK_MODE_* and 215 * LockTaskController. 216 */ onLockTaskModeChanged(int mode)217 void onLockTaskModeChanged(int mode); 218 } 219