1 /* 2 * Copyright (C) 2017 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 com.android.systemui.shared.system; 18 19 import android.app.ActivityManager.RunningTaskInfo; 20 import android.app.ITaskStackListener; 21 import android.content.ComponentName; 22 23 import com.android.systemui.shared.recents.model.ThumbnailData; 24 25 /** 26 * An interface to track task stack changes. Classes should implement this instead of 27 * {@link android.app.ITaskStackListener} to reduce IPC calls from system services. 28 */ 29 public interface TaskStackChangeListener { 30 31 // Binder thread callbacks onTaskStackChangedBackground()32 default void onTaskStackChangedBackground() { } 33 34 // Main thread callbacks onTaskStackChanged()35 default void onTaskStackChanged() { } 36 37 /** 38 * @return whether the snapshot is consumed and the lifecycle of the snapshot extends beyond 39 * the lifecycle of this callback. 40 */ onTaskSnapshotChanged(int taskId, ThumbnailData snapshot)41 default boolean onTaskSnapshotChanged(int taskId, ThumbnailData snapshot) { 42 return false; 43 } onActivityPinned(String packageName, int userId, int taskId, int stackId)44 default void onActivityPinned(String packageName, int userId, int taskId, int stackId) { } onActivityUnpinned()45 default void onActivityUnpinned() { } onActivityRestartAttempt(RunningTaskInfo task, boolean homeTaskVisible, boolean clearedTask, boolean wasVisible)46 default void onActivityRestartAttempt(RunningTaskInfo task, boolean homeTaskVisible, 47 boolean clearedTask, boolean wasVisible) { } onActivityForcedResizable(String packageName, int taskId, int reason)48 default void onActivityForcedResizable(String packageName, int taskId, int reason) { } onActivityDismissingDockedStack()49 default void onActivityDismissingDockedStack() { } onActivityLaunchOnSecondaryDisplayFailed()50 default void onActivityLaunchOnSecondaryDisplayFailed() { } 51 onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo)52 default void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo) { 53 onActivityLaunchOnSecondaryDisplayFailed(); 54 } 55 56 /** 57 * @see #onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo) 58 */ onActivityLaunchOnSecondaryDisplayRerouted()59 default void onActivityLaunchOnSecondaryDisplayRerouted() { } 60 61 /** 62 * Called when an activity was requested to be launched on a secondary display but was rerouted 63 * to default display. 64 * 65 * @param taskInfo info about the Activity's task 66 */ onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo)67 default void onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo) { 68 onActivityLaunchOnSecondaryDisplayRerouted(); 69 } 70 onTaskProfileLocked(RunningTaskInfo taskInfo, int userId)71 default void onTaskProfileLocked(RunningTaskInfo taskInfo, int userId) { } onTaskCreated(int taskId, ComponentName componentName)72 default void onTaskCreated(int taskId, ComponentName componentName) { } onTaskRemoved(int taskId)73 default void onTaskRemoved(int taskId) { } onTaskMovedToFront(int taskId)74 default void onTaskMovedToFront(int taskId) { } 75 onTaskMovedToFront(RunningTaskInfo taskInfo)76 default void onTaskMovedToFront(RunningTaskInfo taskInfo) { 77 onTaskMovedToFront(taskInfo.taskId); 78 } 79 80 /** 81 * Called when a task’s description is changed due to an activity calling 82 * ActivityManagerService.setTaskDescription 83 * 84 * @param taskInfo info about the task which changed, with 85 * {@link RunningTaskInfo#taskDescription} 86 */ onTaskDescriptionChanged(RunningTaskInfo taskInfo)87 default void onTaskDescriptionChanged(RunningTaskInfo taskInfo) { } 88 onActivityRequestedOrientationChanged(int taskId, int requestedOrientation)89 default void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { } 90 onBackPressedOnTaskRoot(RunningTaskInfo taskInfo)91 default void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { } 92 93 /** 94 * Called when a task is reparented to a stack on a different display. 95 * 96 * @param taskId id of the task which was moved to a different display. 97 * @param newDisplayId id of the new display. 98 */ onTaskDisplayChanged(int taskId, int newDisplayId)99 default void onTaskDisplayChanged(int taskId, int newDisplayId) { } 100 101 /** 102 * Called when any additions or deletions to the recent tasks list have been made. 103 */ onRecentTaskListUpdated()104 default void onRecentTaskListUpdated() { } 105 106 /** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */ onRecentTaskListFrozenChanged(boolean frozen)107 default void onRecentTaskListFrozenChanged(boolean frozen) { } 108 109 /** @see ITaskStackListener#onActivityRotation(int)*/ onActivityRotation(int displayId)110 default void onActivityRotation(int displayId) { } 111 112 /** 113 * Called when the lock task mode changes. See ActivityManager#LOCK_TASK_MODE_* and 114 * LockTaskController. 115 */ onLockTaskModeChanged(int mode)116 default void onLockTaskModeChanged(int mode) { } 117 } 118