2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.systemui.shared.system;
19 import android.app.ActivityManager.RunningTaskInfo;
20 import android.content.ComponentName;
21 import android.os.IBinder;
22 import android.os.UserHandle;
23 import android.util.Log;
25 import com.android.systemui.shared.recents.model.ThumbnailData;
28 * An interface to track task stack changes. Classes should implement this instead of
29 * {@link android.app.ITaskStackListener} to reduce IPC calls from system services.
31 public abstract class TaskStackChangeListener {
33 // Binder thread callbacks
34 public void onTaskStackChangedBackground() { }
36 // Main thread callbacks
37 public void onTaskStackChanged() { }
38 public void onTaskSnapshotChanged(int taskId, ThumbnailData snapshot) { }
39 public void onActivityPinned(String packageName, int userId, int taskId, int stackId) { }
40 public void onActivityUnpinned() { }
41 public void onPinnedActivityRestartAttempt(boolean clearedTask) { }
42 public void onPinnedStackAnimationStarted() { }
43 public void onPinnedStackAnimationEnded() { }
44 public void onActivityForcedResizable(String packageName, int taskId, int reason) { }
45 public void onActivityDismissingDockedStack() { }
46 public void onActivityLaunchOnSecondaryDisplayFailed() { }
48 public void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo) {
49 onActivityLaunchOnSecondaryDisplayFailed();
53 * @see #onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo)
55 public void onActivityLaunchOnSecondaryDisplayRerouted() { }
58 * Called when an activity was requested to be launched on a secondary display but was rerouted
61 * @param taskInfo info about the Activity's task
63 public void onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo) {
64 onActivityLaunchOnSecondaryDisplayRerouted();
67 public void onTaskProfileLocked(int taskId, int userId) { }
68 public void onTaskCreated(int taskId, ComponentName componentName) { }
69 public void onTaskRemoved(int taskId) { }
70 public void onTaskMovedToFront(int taskId) { }
72 public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
73 onTaskMovedToFront(taskInfo.taskId);
76 public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { }
77 public void onSizeCompatModeActivityChanged(int displayId, IBinder activityToken) { }
79 public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { }
82 * Called when a task is reparented to a stack on a different display.
84 * @param taskId id of the task which was moved to a different display.
85 * @param newDisplayId id of the new display.
87 public void onTaskDisplayChanged(int taskId, int newDisplayId) { }
90 * Checks that the current user matches the process. Since
91 * {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
92 * {@link TaskStackChangeListener} should make this call to verify that we don't act on events
93 * originating from another user's interactions.
95 protected final boolean checkCurrentUserId(int currentUserId, boolean debug) {
96 int processUserId = UserHandle.myUserId();
97 if (processUserId != currentUserId) {
99 Log.d("TaskStackChangeListener", "UID mismatch. Process is uid=" + processUserId
100 + " and the current user is uid=" + currentUserId);