Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Wale Ogunwale | 5950709 | 2018-10-29 09:00:30 -0700 | [diff] [blame] | 17 | package com.android.server.wm; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 18 | |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 19 | import android.app.ActivityManager; |
| 20 | import android.app.ActivityManager.RunningTaskInfo; |
Jorim Jaggi | fb9d78a | 2017-01-05 18:57:12 +0100 | [diff] [blame] | 21 | import android.app.ActivityManager.TaskSnapshot; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 22 | import android.app.ITaskStackListener; |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 23 | import android.app.TaskInfo; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 24 | import android.content.ComponentName; |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 25 | import android.os.Binder; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 26 | import android.os.Handler; |
Riddle Hsu | 7b766fd | 2019-01-28 21:14:59 +0800 | [diff] [blame] | 27 | import android.os.IBinder; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 28 | import android.os.Looper; |
| 29 | import android.os.Message; |
| 30 | import android.os.RemoteCallbackList; |
| 31 | import android.os.RemoteException; |
| 32 | |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 33 | import java.util.ArrayList; |
| 34 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 35 | class TaskChangeNotificationController { |
Wale Ogunwale | f1b2ec9 | 2017-06-05 07:09:35 -0700 | [diff] [blame] | 36 | private static final int LOG_STACK_STATE_MSG = 1; |
| 37 | private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG = 2; |
| 38 | private static final int NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG = 3; |
| 39 | private static final int NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG = 4; |
| 40 | private static final int NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG = 5; |
| 41 | private static final int NOTIFY_FORCED_RESIZABLE_MSG = 6; |
| 42 | private static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 7; |
| 43 | private static final int NOTIFY_TASK_ADDED_LISTENERS_MSG = 8; |
| 44 | private static final int NOTIFY_TASK_REMOVED_LISTENERS_MSG = 9; |
| 45 | private static final int NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG = 10; |
| 46 | private static final int NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG = 11; |
| 47 | private static final int NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS = 12; |
| 48 | private static final int NOTIFY_TASK_REMOVAL_STARTED_LISTENERS = 13; |
| 49 | private static final int NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG = 14; |
| 50 | private static final int NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG = 15; |
| 51 | private static final int NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG = 16; |
| 52 | private static final int NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG = 17; |
| 53 | private static final int NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED_MSG = 18; |
Jeff Chang | bf29986 | 2019-02-26 20:07:22 +0800 | [diff] [blame] | 54 | private static final int NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG = 19; |
Riddle Hsu | 7b766fd | 2019-01-28 21:14:59 +0800 | [diff] [blame] | 55 | private static final int NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG = 20; |
Mark Renouf | 446251d | 2019-04-26 10:22:41 -0400 | [diff] [blame] | 56 | private static final int NOTIFY_BACK_PRESSED_ON_TASK_ROOT = 21; |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 57 | private static final int NOTIFY_SINGLE_TASK_DISPLAY_DRAWN = 22; |
davidln | 1ceedb5 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 58 | private static final int NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG = 23; |
Vinit Nayak | 3e73749 | 2019-07-24 13:03:15 -0700 | [diff] [blame] | 59 | private static final int NOTIFY_TASK_LIST_UPDATED_LISTENERS_MSG = 24; |
Mady Mellor | 06b770c | 2019-08-29 18:01:00 -0700 | [diff] [blame] | 60 | private static final int NOTIFY_SINGLE_TASK_DISPLAY_EMPTY = 25; |
Vinit Nayak | 8e54796 | 2019-10-07 10:36:41 -0700 | [diff] [blame] | 61 | private static final int NOTIFY_TASK_LIST_FROZEN_UNFROZEN_MSG = 26; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 62 | |
| 63 | // Delay in notifying task stack change listeners (in millis) |
Wale Ogunwale | f1b2ec9 | 2017-06-05 07:09:35 -0700 | [diff] [blame] | 64 | private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 65 | |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 66 | // Global lock used by the service the instantiate objects of this class. |
| 67 | private final Object mServiceLock; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 68 | private final ActivityStackSupervisor mStackSupervisor; |
| 69 | private final Handler mHandler; |
| 70 | |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 71 | // Task stack change listeners in a remote process. |
| 72 | private final RemoteCallbackList<ITaskStackListener> mRemoteTaskStackListeners = |
| 73 | new RemoteCallbackList<>(); |
| 74 | |
| 75 | /* |
| 76 | * Task stack change listeners in a local process. Tracked separately so that they can be |
| 77 | * called on the same thread. |
| 78 | */ |
| 79 | private final ArrayList<ITaskStackListener> mLocalTaskStackListeners = new ArrayList<>(); |
| 80 | |
| 81 | private final TaskStackConsumer mNotifyTaskStackChanged = (l, m) -> { |
| 82 | l.onTaskStackChanged(); |
| 83 | }; |
| 84 | |
| 85 | private final TaskStackConsumer mNotifyTaskCreated = (l, m) -> { |
| 86 | l.onTaskCreated(m.arg1, (ComponentName) m.obj); |
| 87 | }; |
| 88 | |
| 89 | private final TaskStackConsumer mNotifyTaskRemoved = (l, m) -> { |
| 90 | l.onTaskRemoved(m.arg1); |
| 91 | }; |
| 92 | |
| 93 | private final TaskStackConsumer mNotifyTaskMovedToFront = (l, m) -> { |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 94 | l.onTaskMovedToFront((RunningTaskInfo) m.obj); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | private final TaskStackConsumer mNotifyTaskDescriptionChanged = (l, m) -> { |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 98 | l.onTaskDescriptionChanged((RunningTaskInfo) m.obj); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
Mark Renouf | 446251d | 2019-04-26 10:22:41 -0400 | [diff] [blame] | 101 | private final TaskStackConsumer mNotifyBackPressedOnTaskRoot = (l, m) -> { |
| 102 | l.onBackPressedOnTaskRoot((RunningTaskInfo) m.obj); |
| 103 | }; |
| 104 | |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 105 | private final TaskStackConsumer mNotifyActivityRequestedOrientationChanged = (l, m) -> { |
| 106 | l.onActivityRequestedOrientationChanged(m.arg1, m.arg2); |
| 107 | }; |
| 108 | |
| 109 | private final TaskStackConsumer mNotifyTaskRemovalStarted = (l, m) -> { |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 110 | l.onTaskRemovalStarted((RunningTaskInfo) m.obj); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | private final TaskStackConsumer mNotifyActivityPinned = (l, m) -> { |
Wale Ogunwale | b7cf063 | 2017-11-07 13:20:53 -0800 | [diff] [blame] | 114 | l.onActivityPinned((String) m.obj /* packageName */, m.sendingUid /* userId */, |
| 115 | m.arg1 /* taskId */, m.arg2 /* stackId */); |
Winson Chung | c81c0ce | 2017-03-17 12:27:30 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | private final TaskStackConsumer mNotifyActivityUnpinned = (l, m) -> { |
| 119 | l.onActivityUnpinned(); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | private final TaskStackConsumer mNotifyPinnedActivityRestartAttempt = (l, m) -> { |
Winson Chung | e6385a2 | 2017-05-02 18:15:16 -0700 | [diff] [blame] | 123 | l.onPinnedActivityRestartAttempt(m.arg1 != 0); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 124 | }; |
| 125 | |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 126 | private final TaskStackConsumer mNotifyPinnedStackAnimationStarted = (l, m) -> { |
| 127 | l.onPinnedStackAnimationStarted(); |
| 128 | }; |
| 129 | |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 130 | private final TaskStackConsumer mNotifyPinnedStackAnimationEnded = (l, m) -> { |
| 131 | l.onPinnedStackAnimationEnded(); |
| 132 | }; |
| 133 | |
| 134 | private final TaskStackConsumer mNotifyActivityForcedResizable = (l, m) -> { |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 135 | l.onActivityForcedResizable((String) m.obj, m.arg1, m.arg2); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | private final TaskStackConsumer mNotifyActivityDismissingDockedStack = (l, m) -> { |
| 139 | l.onActivityDismissingDockedStack(); |
| 140 | }; |
| 141 | |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 142 | private final TaskStackConsumer mNotifyActivityLaunchOnSecondaryDisplayFailed = (l, m) -> { |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 143 | l.onActivityLaunchOnSecondaryDisplayFailed((RunningTaskInfo) m.obj, m.arg1); |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
Jeff Chang | bf29986 | 2019-02-26 20:07:22 +0800 | [diff] [blame] | 146 | private final TaskStackConsumer mNotifyActivityLaunchOnSecondaryDisplayRerouted = (l, m) -> { |
| 147 | l.onActivityLaunchOnSecondaryDisplayRerouted((RunningTaskInfo) m.obj, m.arg1); |
| 148 | }; |
| 149 | |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 150 | private final TaskStackConsumer mNotifyTaskProfileLocked = (l, m) -> { |
| 151 | l.onTaskProfileLocked(m.arg1, m.arg2); |
| 152 | }; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 153 | |
Jorim Jaggi | fb9d78a | 2017-01-05 18:57:12 +0100 | [diff] [blame] | 154 | private final TaskStackConsumer mNotifyTaskSnapshotChanged = (l, m) -> { |
| 155 | l.onTaskSnapshotChanged(m.arg1, (TaskSnapshot) m.obj); |
| 156 | }; |
| 157 | |
Riddle Hsu | 7b766fd | 2019-01-28 21:14:59 +0800 | [diff] [blame] | 158 | private final TaskStackConsumer mOnSizeCompatModeActivityChanged = (l, m) -> { |
| 159 | l.onSizeCompatModeActivityChanged(m.arg1, (IBinder) m.obj); |
| 160 | }; |
| 161 | |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 162 | private final TaskStackConsumer mNotifySingleTaskDisplayDrawn = (l, m) -> { |
| 163 | l.onSingleTaskDisplayDrawn(m.arg1); |
| 164 | }; |
| 165 | |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 166 | private final TaskStackConsumer mNotifySingleTaskDisplayEmpty = (l, m) -> { |
| 167 | l.onSingleTaskDisplayEmpty(m.arg1); |
| 168 | }; |
| 169 | |
davidln | 1ceedb5 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 170 | private final TaskStackConsumer mNotifyTaskDisplayChanged = (l, m) -> { |
| 171 | l.onTaskDisplayChanged(m.arg1, m.arg2); |
| 172 | }; |
| 173 | |
Vinit Nayak | 3e73749 | 2019-07-24 13:03:15 -0700 | [diff] [blame] | 174 | private final TaskStackConsumer mNotifyTaskListUpdated = (l, m) -> { |
| 175 | l.onRecentTaskListUpdated(); |
| 176 | }; |
| 177 | |
Vinit Nayak | 8e54796 | 2019-10-07 10:36:41 -0700 | [diff] [blame] | 178 | private final TaskStackConsumer mNotifyTaskListFrozen = (l, m) -> { |
| 179 | l.onRecentTaskListFrozenChanged(m.arg1 != 0); |
| 180 | }; |
| 181 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 182 | @FunctionalInterface |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 183 | public interface TaskStackConsumer { |
| 184 | void accept(ITaskStackListener t, Message m) throws RemoteException; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | private class MainHandler extends Handler { |
| 188 | public MainHandler(Looper looper) { |
| 189 | super(looper); |
| 190 | } |
| 191 | |
| 192 | @Override |
| 193 | public void handleMessage(Message msg) { |
| 194 | switch (msg.what) { |
| 195 | case LOG_STACK_STATE_MSG: { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 196 | synchronized (mServiceLock) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 197 | mStackSupervisor.logStackState(); |
| 198 | } |
| 199 | break; |
| 200 | } |
| 201 | case NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 202 | forAllRemoteListeners(mNotifyTaskStackChanged, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 203 | break; |
| 204 | case NOTIFY_TASK_ADDED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 205 | forAllRemoteListeners(mNotifyTaskCreated, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 206 | break; |
| 207 | case NOTIFY_TASK_REMOVED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 208 | forAllRemoteListeners(mNotifyTaskRemoved, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 209 | break; |
| 210 | case NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 211 | forAllRemoteListeners(mNotifyTaskMovedToFront, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 212 | break; |
| 213 | case NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 214 | forAllRemoteListeners(mNotifyTaskDescriptionChanged, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 215 | break; |
| 216 | case NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 217 | forAllRemoteListeners(mNotifyActivityRequestedOrientationChanged, msg); |
Yorke Lee | 64fd1ce | 2017-01-05 17:15:20 -0800 | [diff] [blame] | 218 | break; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 219 | case NOTIFY_TASK_REMOVAL_STARTED_LISTENERS: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 220 | forAllRemoteListeners(mNotifyTaskRemovalStarted, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 221 | break; |
| 222 | case NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 223 | forAllRemoteListeners(mNotifyActivityPinned, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 224 | break; |
Winson Chung | c81c0ce | 2017-03-17 12:27:30 -0700 | [diff] [blame] | 225 | case NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG: |
| 226 | forAllRemoteListeners(mNotifyActivityUnpinned, msg); |
| 227 | break; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 228 | case NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 229 | forAllRemoteListeners(mNotifyPinnedActivityRestartAttempt, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 230 | break; |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 231 | case NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG: |
| 232 | forAllRemoteListeners(mNotifyPinnedStackAnimationStarted, msg); |
| 233 | break; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 234 | case NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 235 | forAllRemoteListeners(mNotifyPinnedStackAnimationEnded, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 236 | break; |
| 237 | case NOTIFY_FORCED_RESIZABLE_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 238 | forAllRemoteListeners(mNotifyActivityForcedResizable, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 239 | break; |
| 240 | case NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 241 | forAllRemoteListeners(mNotifyActivityDismissingDockedStack, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 242 | break; |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 243 | case NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED_MSG: |
| 244 | forAllRemoteListeners(mNotifyActivityLaunchOnSecondaryDisplayFailed, msg); |
| 245 | break; |
Jeff Chang | bf29986 | 2019-02-26 20:07:22 +0800 | [diff] [blame] | 246 | case NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG: |
| 247 | forAllRemoteListeners(mNotifyActivityLaunchOnSecondaryDisplayRerouted, msg); |
| 248 | break; |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 249 | case NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG: |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 250 | forAllRemoteListeners(mNotifyTaskProfileLocked, msg); |
Jorim Jaggi | fb9d78a | 2017-01-05 18:57:12 +0100 | [diff] [blame] | 251 | break; |
| 252 | case NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG: |
| 253 | forAllRemoteListeners(mNotifyTaskSnapshotChanged, msg); |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 254 | break; |
Riddle Hsu | 7b766fd | 2019-01-28 21:14:59 +0800 | [diff] [blame] | 255 | case NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG: |
| 256 | forAllRemoteListeners(mOnSizeCompatModeActivityChanged, msg); |
| 257 | break; |
Mark Renouf | 446251d | 2019-04-26 10:22:41 -0400 | [diff] [blame] | 258 | case NOTIFY_BACK_PRESSED_ON_TASK_ROOT: |
| 259 | forAllRemoteListeners(mNotifyBackPressedOnTaskRoot, msg); |
| 260 | break; |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 261 | case NOTIFY_SINGLE_TASK_DISPLAY_DRAWN: |
| 262 | forAllRemoteListeners(mNotifySingleTaskDisplayDrawn, msg); |
| 263 | break; |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 264 | case NOTIFY_SINGLE_TASK_DISPLAY_EMPTY: |
| 265 | forAllRemoteListeners(mNotifySingleTaskDisplayEmpty, msg); |
| 266 | break; |
davidln | 1ceedb5 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 267 | case NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG: |
| 268 | forAllRemoteListeners(mNotifyTaskDisplayChanged, msg); |
| 269 | break; |
Vinit Nayak | 3e73749 | 2019-07-24 13:03:15 -0700 | [diff] [blame] | 270 | case NOTIFY_TASK_LIST_UPDATED_LISTENERS_MSG: |
| 271 | forAllRemoteListeners(mNotifyTaskListUpdated, msg); |
| 272 | break; |
Vinit Nayak | 8e54796 | 2019-10-07 10:36:41 -0700 | [diff] [blame] | 273 | case NOTIFY_TASK_LIST_FROZEN_UNFROZEN_MSG: |
| 274 | forAllRemoteListeners(mNotifyTaskListFrozen, msg); |
| 275 | break; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 280 | public TaskChangeNotificationController(Object serviceLock, |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 281 | ActivityStackSupervisor stackSupervisor, Handler handler) { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 282 | mServiceLock = serviceLock; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 283 | mStackSupervisor = stackSupervisor; |
| 284 | mHandler = new MainHandler(handler.getLooper()); |
| 285 | } |
| 286 | |
| 287 | public void registerTaskStackListener(ITaskStackListener listener) { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 288 | synchronized (mServiceLock) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 289 | if (listener != null) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 290 | if (Binder.getCallingPid() == android.os.Process.myPid()) { |
| 291 | if (!mLocalTaskStackListeners.contains(listener)) { |
| 292 | mLocalTaskStackListeners.add(listener); |
| 293 | } |
| 294 | } else { |
| 295 | mRemoteTaskStackListeners.register(listener); |
| 296 | } |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | public void unregisterTaskStackListener(ITaskStackListener listener) { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 302 | synchronized (mServiceLock) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 303 | if (listener != null) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 304 | if (Binder.getCallingPid() == android.os.Process.myPid()) { |
| 305 | mLocalTaskStackListeners.remove(listener); |
| 306 | } else { |
| 307 | mRemoteTaskStackListeners.unregister(listener); |
| 308 | } |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
Wale Ogunwale | f1b2ec9 | 2017-06-05 07:09:35 -0700 | [diff] [blame] | 313 | private void forAllRemoteListeners(TaskStackConsumer callback, Message message) { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 314 | synchronized (mServiceLock) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 315 | for (int i = mRemoteTaskStackListeners.beginBroadcast() - 1; i >= 0; i--) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 316 | try { |
| 317 | // Make a one-way callback to the listener |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 318 | callback.accept(mRemoteTaskStackListeners.getBroadcastItem(i), message); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 319 | } catch (RemoteException e) { |
| 320 | // Handled by the RemoteCallbackList. |
| 321 | } |
| 322 | } |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 323 | mRemoteTaskStackListeners.finishBroadcast(); |
| 324 | } |
| 325 | } |
| 326 | |
Wale Ogunwale | f1b2ec9 | 2017-06-05 07:09:35 -0700 | [diff] [blame] | 327 | private void forAllLocalListeners(TaskStackConsumer callback, Message message) { |
Wale Ogunwale | c9e57de | 2018-05-08 14:28:07 -0700 | [diff] [blame] | 328 | synchronized (mServiceLock) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 329 | for (int i = mLocalTaskStackListeners.size() - 1; i >= 0; i--) { |
| 330 | try { |
| 331 | callback.accept(mLocalTaskStackListeners.get(i), message); |
| 332 | } catch (RemoteException e) { |
| 333 | // Never thrown since this is called locally. |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | } |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 338 | |
| 339 | /** Notifies all listeners when the task stack has changed. */ |
| 340 | void notifyTaskStackChanged() { |
| 341 | mHandler.sendEmptyMessage(LOG_STACK_STATE_MSG); |
| 342 | mHandler.removeMessages(NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 343 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG); |
| 344 | forAllLocalListeners(mNotifyTaskStackChanged, msg); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 345 | // Only the main task stack change notification requires a delay. |
| 346 | mHandler.sendMessageDelayed(msg, NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY); |
| 347 | } |
| 348 | |
| 349 | /** Notifies all listeners when an Activity is pinned. */ |
Wale Ogunwale | 89be576 | 2017-10-04 13:27:49 -0700 | [diff] [blame] | 350 | void notifyActivityPinned(ActivityRecord r) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 351 | mHandler.removeMessages(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG); |
Wale Ogunwale | b7cf063 | 2017-11-07 13:20:53 -0800 | [diff] [blame] | 352 | final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG, |
Wale Ogunwale | 4e79a1c | 2019-10-05 20:52:40 -0700 | [diff] [blame] | 353 | r.getTaskRecord().mTaskId, r.getStackId(), r.packageName); |
Wale Ogunwale | 8b19de9 | 2018-11-29 19:58:26 -0800 | [diff] [blame] | 354 | msg.sendingUid = r.mUserId; |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 355 | forAllLocalListeners(mNotifyActivityPinned, msg); |
| 356 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 357 | } |
| 358 | |
Winson Chung | c81c0ce | 2017-03-17 12:27:30 -0700 | [diff] [blame] | 359 | /** Notifies all listeners when an Activity is unpinned. */ |
| 360 | void notifyActivityUnpinned() { |
| 361 | mHandler.removeMessages(NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG); |
| 362 | final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG); |
| 363 | forAllLocalListeners(mNotifyActivityUnpinned, msg); |
| 364 | msg.sendToTarget(); |
| 365 | } |
| 366 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 367 | /** |
| 368 | * Notifies all listeners when an attempt was made to start an an activity that is already |
| 369 | * running in the pinned stack and the activity was not actually started, but the task is |
| 370 | * either brought to the front or a new Intent is delivered to it. |
| 371 | */ |
Winson Chung | e6385a2 | 2017-05-02 18:15:16 -0700 | [diff] [blame] | 372 | void notifyPinnedActivityRestartAttempt(boolean clearedTask) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 373 | mHandler.removeMessages(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 374 | final Message msg = |
Winson Chung | e6385a2 | 2017-05-02 18:15:16 -0700 | [diff] [blame] | 375 | mHandler.obtainMessage(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG, |
| 376 | clearedTask ? 1 : 0, 0); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 377 | forAllLocalListeners(mNotifyPinnedActivityRestartAttempt, msg); |
| 378 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 379 | } |
| 380 | |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 381 | /** Notifies all listeners when the pinned stack animation starts. */ |
| 382 | void notifyPinnedStackAnimationStarted() { |
| 383 | mHandler.removeMessages(NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG); |
| 384 | final Message msg = |
| 385 | mHandler.obtainMessage(NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG); |
| 386 | forAllLocalListeners(mNotifyPinnedStackAnimationStarted, msg); |
| 387 | msg.sendToTarget(); |
| 388 | } |
| 389 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 390 | /** Notifies all listeners when the pinned stack animation ends. */ |
| 391 | void notifyPinnedStackAnimationEnded() { |
| 392 | mHandler.removeMessages(NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 393 | final Message msg = |
| 394 | mHandler.obtainMessage(NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG); |
| 395 | forAllLocalListeners(mNotifyPinnedStackAnimationEnded, msg); |
| 396 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | void notifyActivityDismissingDockedStack() { |
| 400 | mHandler.removeMessages(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG); |
Wale Ogunwale | f1b2ec9 | 2017-06-05 07:09:35 -0700 | [diff] [blame] | 401 | final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG); |
| 402 | forAllLocalListeners(mNotifyActivityDismissingDockedStack, msg); |
| 403 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 404 | } |
| 405 | |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 406 | void notifyActivityForcedResizable(int taskId, int reason, String packageName) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 407 | mHandler.removeMessages(NOTIFY_FORCED_RESIZABLE_MSG); |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 408 | final Message msg = mHandler.obtainMessage(NOTIFY_FORCED_RESIZABLE_MSG, taskId, reason, |
| 409 | packageName); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 410 | forAllLocalListeners(mNotifyActivityForcedResizable, msg); |
| 411 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 414 | void notifyActivityLaunchOnSecondaryDisplayFailed(TaskInfo ti, int requestedDisplayId) { |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 415 | mHandler.removeMessages(NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED_MSG); |
| 416 | final Message msg = mHandler.obtainMessage( |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 417 | NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED_MSG, requestedDisplayId, |
| 418 | 0 /* unused */, ti); |
Andrii Kulian | 036e3ad | 2017-04-19 10:55:10 -0700 | [diff] [blame] | 419 | forAllLocalListeners(mNotifyActivityLaunchOnSecondaryDisplayFailed, msg); |
| 420 | msg.sendToTarget(); |
| 421 | } |
| 422 | |
Jeff Chang | bf29986 | 2019-02-26 20:07:22 +0800 | [diff] [blame] | 423 | void notifyActivityLaunchOnSecondaryDisplayRerouted(TaskInfo ti, int requestedDisplayId) { |
| 424 | mHandler.removeMessages(NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG); |
| 425 | final Message msg = mHandler.obtainMessage( |
| 426 | NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG, requestedDisplayId, |
| 427 | 0 /* unused */, ti); |
| 428 | forAllLocalListeners(mNotifyActivityLaunchOnSecondaryDisplayRerouted, msg); |
| 429 | msg.sendToTarget(); |
| 430 | } |
| 431 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 432 | void notifyTaskCreated(int taskId, ComponentName componentName) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 433 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_ADDED_LISTENERS_MSG, |
| 434 | taskId, 0 /* unused */, componentName); |
| 435 | forAllLocalListeners(mNotifyTaskCreated, msg); |
| 436 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | void notifyTaskRemoved(int taskId) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 440 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_REMOVED_LISTENERS_MSG, |
| 441 | taskId, 0 /* unused */); |
| 442 | forAllLocalListeners(mNotifyTaskRemoved, msg); |
| 443 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 446 | void notifyTaskMovedToFront(TaskInfo ti) { |
| 447 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG, ti); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 448 | forAllLocalListeners(mNotifyTaskMovedToFront, msg); |
| 449 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 452 | void notifyTaskDescriptionChanged(TaskInfo taskInfo) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 453 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG, |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 454 | taskInfo); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 455 | forAllLocalListeners(mNotifyTaskDescriptionChanged, msg); |
| 456 | msg.sendToTarget(); |
| 457 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | void notifyActivityRequestedOrientationChanged(int taskId, int orientation) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 461 | final Message msg = mHandler.obtainMessage( |
| 462 | NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS, taskId, orientation); |
| 463 | forAllLocalListeners(mNotifyActivityRequestedOrientationChanged, msg); |
| 464 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Notify listeners that the task is about to be finished before its surfaces are removed from |
| 469 | * the window manager. This allows interested parties to perform relevant animations before |
| 470 | * the window disappears. |
| 471 | */ |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 472 | void notifyTaskRemovalStarted(ActivityManager.RunningTaskInfo taskInfo) { |
| 473 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_REMOVAL_STARTED_LISTENERS, taskInfo); |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 474 | forAllLocalListeners(mNotifyTaskRemovalStarted, msg); |
| 475 | msg.sendToTarget(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 476 | } |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 477 | |
| 478 | /** |
| 479 | * Notify listeners that the task has been put in a locked state because one or more of the |
| 480 | * activities inside it belong to a managed profile user that has been locked. |
| 481 | */ |
| 482 | void notifyTaskProfileLocked(int taskId, int userId) { |
Yorke Lee | 1329407 | 2017-01-06 14:59:58 -0800 | [diff] [blame] | 483 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG, taskId, |
| 484 | userId); |
| 485 | forAllLocalListeners(mNotifyTaskProfileLocked, msg); |
| 486 | msg.sendToTarget(); |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 487 | } |
Jorim Jaggi | fb9d78a | 2017-01-05 18:57:12 +0100 | [diff] [blame] | 488 | |
| 489 | /** |
| 490 | * Notify listeners that the snapshot of a task has changed. |
| 491 | */ |
| 492 | void notifyTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) { |
| 493 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG, |
| 494 | taskId, 0, snapshot); |
| 495 | forAllLocalListeners(mNotifyTaskSnapshotChanged, msg); |
| 496 | msg.sendToTarget(); |
| 497 | } |
Riddle Hsu | 7b766fd | 2019-01-28 21:14:59 +0800 | [diff] [blame] | 498 | |
| 499 | /** |
| 500 | * Notify listeners that whether a size compatibility mode activity is using the override |
| 501 | * bounds which is not fit its parent. |
| 502 | */ |
| 503 | void notifySizeCompatModeActivityChanged(int displayId, IBinder activityToken) { |
| 504 | final Message msg = mHandler.obtainMessage(NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG, |
| 505 | displayId, 0 /* unused */, activityToken); |
| 506 | forAllLocalListeners(mOnSizeCompatModeActivityChanged, msg); |
| 507 | msg.sendToTarget(); |
| 508 | } |
Mark Renouf | 446251d | 2019-04-26 10:22:41 -0400 | [diff] [blame] | 509 | |
| 510 | /** |
| 511 | * Notify listeners that an activity received a back press when there are no other activities |
| 512 | * in the back stack. |
| 513 | */ |
| 514 | void notifyBackPressedOnTaskRoot(TaskInfo taskInfo) { |
| 515 | final Message msg = mHandler.obtainMessage(NOTIFY_BACK_PRESSED_ON_TASK_ROOT, |
| 516 | taskInfo); |
| 517 | forAllLocalListeners(mNotifyBackPressedOnTaskRoot, msg); |
| 518 | msg.sendToTarget(); |
| 519 | } |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 520 | |
| 521 | /** |
| 522 | * Notify listeners that contents are drawn for the first time on a single task display. |
| 523 | */ |
| 524 | void notifySingleTaskDisplayDrawn(int displayId) { |
| 525 | final Message msg = mHandler.obtainMessage(NOTIFY_SINGLE_TASK_DISPLAY_DRAWN, |
| 526 | displayId, 0 /* unused */); |
| 527 | forAllLocalListeners(mNotifySingleTaskDisplayDrawn, msg); |
| 528 | msg.sendToTarget(); |
| 529 | } |
davidln | 1ceedb5 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 530 | |
| 531 | /** |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 532 | * Notify listeners that the last task is removed from a single task display. |
| 533 | */ |
| 534 | void notifySingleTaskDisplayEmpty(int displayId) { |
| 535 | final Message msg = mHandler.obtainMessage( |
| 536 | NOTIFY_SINGLE_TASK_DISPLAY_EMPTY, |
| 537 | displayId, 0 /* unused */); |
| 538 | forAllLocalListeners(mNotifySingleTaskDisplayEmpty, msg); |
| 539 | msg.sendToTarget(); |
| 540 | } |
davidln | eaeae18 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 541 | |
| 542 | /** |
davidln | 1ceedb5 | 2019-05-30 14:25:01 -0700 | [diff] [blame] | 543 | * Notify listeners that a task is reparented to another display. |
| 544 | */ |
| 545 | void notifyTaskDisplayChanged(int taskId, int newDisplayId) { |
| 546 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG, |
| 547 | taskId, newDisplayId); |
| 548 | forAllLocalListeners(mNotifyTaskStackChanged, msg); |
| 549 | msg.sendToTarget(); |
| 550 | } |
Vinit Nayak | 3e73749 | 2019-07-24 13:03:15 -0700 | [diff] [blame] | 551 | |
| 552 | /** |
| 553 | * Called when any additions or deletions to the recent tasks list have been made. |
| 554 | */ |
| 555 | void notifyTaskListUpdated() { |
| 556 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_LIST_UPDATED_LISTENERS_MSG); |
| 557 | forAllLocalListeners(mNotifyTaskListUpdated, msg); |
| 558 | msg.sendToTarget(); |
| 559 | } |
Vinit Nayak | 8e54796 | 2019-10-07 10:36:41 -0700 | [diff] [blame] | 560 | |
| 561 | /** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */ |
| 562 | void notifyTaskListFrozen(boolean frozen) { |
| 563 | final Message msg = mHandler.obtainMessage(NOTIFY_TASK_LIST_FROZEN_UNFROZEN_MSG, |
| 564 | frozen ? 1 : 0, 0 /* unused */); |
| 565 | forAllLocalListeners(mNotifyTaskListFrozen, msg); |
| 566 | msg.sendToTarget(); |
| 567 | } |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 568 | } |