OSDN Git Service

Merge "docs: Add documentation for equals() method" into qt-dev
[android-x86/frameworks-base.git] / packages / SystemUI / shared / src / com / android / systemui / shared / system / TaskStackChangeListener.java
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.content.ComponentName;
21 import android.os.IBinder;
22 import android.os.UserHandle;
23 import android.util.Log;
24
25 import com.android.systemui.shared.recents.model.ThumbnailData;
26
27 /**
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.
30  */
31 public abstract class TaskStackChangeListener {
32
33     // Binder thread callbacks
34     public void onTaskStackChangedBackground() { }
35
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() { }
47
48     public void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo) {
49         onActivityLaunchOnSecondaryDisplayFailed();
50     }
51
52     /**
53      * @see #onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo)
54      */
55     public void onActivityLaunchOnSecondaryDisplayRerouted() { }
56
57     /**
58      * Called when an activity was requested to be launched on a secondary display but was rerouted
59      * to default display.
60      *
61      * @param taskInfo info about the Activity's task
62      */
63     public void onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo) {
64         onActivityLaunchOnSecondaryDisplayRerouted();
65     }
66
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) { }
71
72     public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
73         onTaskMovedToFront(taskInfo.taskId);
74     }
75
76     public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { }
77     public void onSizeCompatModeActivityChanged(int displayId, IBinder activityToken) { }
78
79     public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { }
80
81     /**
82      * Called when a task is reparented to a stack on a different display.
83      *
84      * @param taskId id of the task which was moved to a different display.
85      * @param newDisplayId id of the new display.
86      */
87     public void onTaskDisplayChanged(int taskId, int newDisplayId) { }
88
89     /**
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.
94      */
95     protected final boolean checkCurrentUserId(int currentUserId, boolean debug) {
96         int processUserId = UserHandle.myUserId();
97         if (processUserId != currentUserId) {
98             if (debug) {
99                 Log.d("TaskStackChangeListener", "UID mismatch. Process is uid=" + processUserId
100                         + " and the current user is uid=" + currentUserId);
101             }
102             return false;
103         }
104         return true;
105     }
106 }