blob: 94cf092baed3af479a77c131a2de954d4b1462aa [file] [log] [blame]
Yorke Leebd54c2a2016-10-25 13:49:23 -07001/*
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
17package com.android.server.am;
18
Jorim Jaggifb9d78a2017-01-05 18:57:12 +010019import android.app.ActivityManager;
20import android.app.ActivityManager.TaskSnapshot;
Yorke Leebd54c2a2016-10-25 13:49:23 -070021import android.app.ITaskStackListener;
22import android.app.ActivityManager.TaskDescription;
23import android.content.ComponentName;
Yorke Lee13294072017-01-06 14:59:58 -080024import android.os.Binder;
Yorke Leebd54c2a2016-10-25 13:49:23 -070025import android.os.Handler;
26import android.os.Looper;
27import android.os.Message;
28import android.os.RemoteCallbackList;
29import android.os.RemoteException;
30
Yorke Lee13294072017-01-06 14:59:58 -080031import java.util.ArrayList;
32
Yorke Leebd54c2a2016-10-25 13:49:23 -070033class TaskChangeNotificationController {
34 static final int LOG_STACK_STATE_MSG = 1;
35 static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG = 2;
36 static final int NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG = 3;
37 static final int NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG = 4;
38 static final int NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG = 5;
39 static final int NOTIFY_FORCED_RESIZABLE_MSG = 6;
40 static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 7;
41 static final int NOTIFY_TASK_ADDED_LISTENERS_MSG = 8;
42 static final int NOTIFY_TASK_REMOVED_LISTENERS_MSG = 9;
43 static final int NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG = 10;
44 static final int NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG = 11;
45 static final int NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS = 12;
46 static final int NOTIFY_TASK_REMOVAL_STARTED_LISTENERS = 13;
Robin Leec41f6ec2017-01-10 17:02:34 +000047 static final int NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG = 14;
Jorim Jaggifb9d78a2017-01-05 18:57:12 +010048 static final int NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG = 15;
Winson Chung85d39982017-02-24 15:21:25 -080049 static final int NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG = 16;
Winson Chungc81c0ce2017-03-17 12:27:30 -070050 static final int NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG = 17;
Yorke Leebd54c2a2016-10-25 13:49:23 -070051
52 // Delay in notifying task stack change listeners (in millis)
53 static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
54
55 private final ActivityManagerService mService;
56 private final ActivityStackSupervisor mStackSupervisor;
57 private final Handler mHandler;
58
Yorke Lee13294072017-01-06 14:59:58 -080059 // Task stack change listeners in a remote process.
60 private final RemoteCallbackList<ITaskStackListener> mRemoteTaskStackListeners =
61 new RemoteCallbackList<>();
62
63 /*
64 * Task stack change listeners in a local process. Tracked separately so that they can be
65 * called on the same thread.
66 */
67 private final ArrayList<ITaskStackListener> mLocalTaskStackListeners = new ArrayList<>();
68
69 private final TaskStackConsumer mNotifyTaskStackChanged = (l, m) -> {
70 l.onTaskStackChanged();
71 };
72
73 private final TaskStackConsumer mNotifyTaskCreated = (l, m) -> {
74 l.onTaskCreated(m.arg1, (ComponentName) m.obj);
75 };
76
77 private final TaskStackConsumer mNotifyTaskRemoved = (l, m) -> {
78 l.onTaskRemoved(m.arg1);
79 };
80
81 private final TaskStackConsumer mNotifyTaskMovedToFront = (l, m) -> {
82 l.onTaskMovedToFront(m.arg1);
83 };
84
85 private final TaskStackConsumer mNotifyTaskDescriptionChanged = (l, m) -> {
86 l.onTaskDescriptionChanged(m.arg1, (TaskDescription) m.obj);
87 };
88
89 private final TaskStackConsumer mNotifyActivityRequestedOrientationChanged = (l, m) -> {
90 l.onActivityRequestedOrientationChanged(m.arg1, m.arg2);
91 };
92
93 private final TaskStackConsumer mNotifyTaskRemovalStarted = (l, m) -> {
94 l.onTaskRemovalStarted(m.arg1);
95 };
96
97 private final TaskStackConsumer mNotifyActivityPinned = (l, m) -> {
Winson Chungc81c0ce2017-03-17 12:27:30 -070098 l.onActivityPinned((String) m.obj);
99 };
100
101 private final TaskStackConsumer mNotifyActivityUnpinned = (l, m) -> {
102 l.onActivityUnpinned();
Yorke Lee13294072017-01-06 14:59:58 -0800103 };
104
105 private final TaskStackConsumer mNotifyPinnedActivityRestartAttempt = (l, m) -> {
Winson Chungd95687c2017-03-03 12:06:21 -0800106 l.onPinnedActivityRestartAttempt();
Yorke Lee13294072017-01-06 14:59:58 -0800107 };
108
Winson Chung85d39982017-02-24 15:21:25 -0800109 private final TaskStackConsumer mNotifyPinnedStackAnimationStarted = (l, m) -> {
110 l.onPinnedStackAnimationStarted();
111 };
112
Yorke Lee13294072017-01-06 14:59:58 -0800113 private final TaskStackConsumer mNotifyPinnedStackAnimationEnded = (l, m) -> {
114 l.onPinnedStackAnimationEnded();
115 };
116
117 private final TaskStackConsumer mNotifyActivityForcedResizable = (l, m) -> {
118 l.onActivityForcedResizable((String) m.obj, m.arg1);
119 };
120
121 private final TaskStackConsumer mNotifyActivityDismissingDockedStack = (l, m) -> {
122 l.onActivityDismissingDockedStack();
123 };
124
125 private final TaskStackConsumer mNotifyTaskProfileLocked = (l, m) -> {
126 l.onTaskProfileLocked(m.arg1, m.arg2);
127 };
Yorke Leebd54c2a2016-10-25 13:49:23 -0700128
Jorim Jaggifb9d78a2017-01-05 18:57:12 +0100129 private final TaskStackConsumer mNotifyTaskSnapshotChanged = (l, m) -> {
130 l.onTaskSnapshotChanged(m.arg1, (TaskSnapshot) m.obj);
131 };
132
Yorke Leebd54c2a2016-10-25 13:49:23 -0700133 @FunctionalInterface
Yorke Lee13294072017-01-06 14:59:58 -0800134 public interface TaskStackConsumer {
135 void accept(ITaskStackListener t, Message m) throws RemoteException;
Yorke Leebd54c2a2016-10-25 13:49:23 -0700136 }
137
138 private class MainHandler extends Handler {
139 public MainHandler(Looper looper) {
140 super(looper);
141 }
142
143 @Override
144 public void handleMessage(Message msg) {
145 switch (msg.what) {
146 case LOG_STACK_STATE_MSG: {
147 synchronized (mService) {
148 mStackSupervisor.logStackState();
149 }
150 break;
151 }
152 case NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800153 forAllRemoteListeners(mNotifyTaskStackChanged, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700154 break;
155 case NOTIFY_TASK_ADDED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800156 forAllRemoteListeners(mNotifyTaskCreated, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700157 break;
158 case NOTIFY_TASK_REMOVED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800159 forAllRemoteListeners(mNotifyTaskRemoved, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700160 break;
161 case NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800162 forAllRemoteListeners(mNotifyTaskMovedToFront, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700163 break;
164 case NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800165 forAllRemoteListeners(mNotifyTaskDescriptionChanged, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700166 break;
167 case NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS:
Yorke Lee13294072017-01-06 14:59:58 -0800168 forAllRemoteListeners(mNotifyActivityRequestedOrientationChanged, msg);
Yorke Lee64fd1ce2017-01-05 17:15:20 -0800169 break;
Yorke Leebd54c2a2016-10-25 13:49:23 -0700170 case NOTIFY_TASK_REMOVAL_STARTED_LISTENERS:
Yorke Lee13294072017-01-06 14:59:58 -0800171 forAllRemoteListeners(mNotifyTaskRemovalStarted, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700172 break;
173 case NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800174 forAllRemoteListeners(mNotifyActivityPinned, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700175 break;
Winson Chungc81c0ce2017-03-17 12:27:30 -0700176 case NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG:
177 forAllRemoteListeners(mNotifyActivityUnpinned, msg);
178 break;
Yorke Leebd54c2a2016-10-25 13:49:23 -0700179 case NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800180 forAllRemoteListeners(mNotifyPinnedActivityRestartAttempt, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700181 break;
Winson Chung85d39982017-02-24 15:21:25 -0800182 case NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG:
183 forAllRemoteListeners(mNotifyPinnedStackAnimationStarted, msg);
184 break;
Yorke Leebd54c2a2016-10-25 13:49:23 -0700185 case NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800186 forAllRemoteListeners(mNotifyPinnedStackAnimationEnded, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700187 break;
188 case NOTIFY_FORCED_RESIZABLE_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800189 forAllRemoteListeners(mNotifyActivityForcedResizable, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700190 break;
191 case NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800192 forAllRemoteListeners(mNotifyActivityDismissingDockedStack, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700193 break;
Robin Leec41f6ec2017-01-10 17:02:34 +0000194 case NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG:
Yorke Lee13294072017-01-06 14:59:58 -0800195 forAllRemoteListeners(mNotifyTaskProfileLocked, msg);
Jorim Jaggifb9d78a2017-01-05 18:57:12 +0100196 break;
197 case NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG:
198 forAllRemoteListeners(mNotifyTaskSnapshotChanged, msg);
Robin Leec41f6ec2017-01-10 17:02:34 +0000199 break;
Yorke Leebd54c2a2016-10-25 13:49:23 -0700200 }
201 }
202 }
203
204 public TaskChangeNotificationController(ActivityManagerService service,
205 ActivityStackSupervisor stackSupervisor, Handler handler) {
206 mService = service;
207 mStackSupervisor = stackSupervisor;
208 mHandler = new MainHandler(handler.getLooper());
209 }
210
211 public void registerTaskStackListener(ITaskStackListener listener) {
212 synchronized (mService) {
213 if (listener != null) {
Yorke Lee13294072017-01-06 14:59:58 -0800214 if (Binder.getCallingPid() == android.os.Process.myPid()) {
215 if (!mLocalTaskStackListeners.contains(listener)) {
216 mLocalTaskStackListeners.add(listener);
217 }
218 } else {
219 mRemoteTaskStackListeners.register(listener);
220 }
Yorke Leebd54c2a2016-10-25 13:49:23 -0700221 }
222 }
223 }
224
225 public void unregisterTaskStackListener(ITaskStackListener listener) {
226 synchronized (mService) {
227 if (listener != null) {
Yorke Lee13294072017-01-06 14:59:58 -0800228 if (Binder.getCallingPid() == android.os.Process.myPid()) {
229 mLocalTaskStackListeners.remove(listener);
230 } else {
231 mRemoteTaskStackListeners.unregister(listener);
232 }
Yorke Leebd54c2a2016-10-25 13:49:23 -0700233 }
234 }
235 }
236
Yorke Lee13294072017-01-06 14:59:58 -0800237 void forAllRemoteListeners(TaskStackConsumer callback, Message message) {
Yorke Leebd54c2a2016-10-25 13:49:23 -0700238 synchronized (mService) {
Yorke Lee13294072017-01-06 14:59:58 -0800239 for (int i = mRemoteTaskStackListeners.beginBroadcast() - 1; i >= 0; i--) {
Yorke Leebd54c2a2016-10-25 13:49:23 -0700240 try {
241 // Make a one-way callback to the listener
Yorke Lee13294072017-01-06 14:59:58 -0800242 callback.accept(mRemoteTaskStackListeners.getBroadcastItem(i), message);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700243 } catch (RemoteException e) {
244 // Handled by the RemoteCallbackList.
245 }
246 }
Yorke Lee13294072017-01-06 14:59:58 -0800247 mRemoteTaskStackListeners.finishBroadcast();
248 }
249 }
250
251 void forAllLocalListeners(TaskStackConsumer callback, Message message) {
252 synchronized (mService) {
253 for (int i = mLocalTaskStackListeners.size() - 1; i >= 0; i--) {
254 try {
255 callback.accept(mLocalTaskStackListeners.get(i), message);
256 } catch (RemoteException e) {
257 // Never thrown since this is called locally.
258 }
259 }
260 }
261 }
Yorke Leebd54c2a2016-10-25 13:49:23 -0700262
263 /** Notifies all listeners when the task stack has changed. */
264 void notifyTaskStackChanged() {
265 mHandler.sendEmptyMessage(LOG_STACK_STATE_MSG);
266 mHandler.removeMessages(NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800267 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG);
268 forAllLocalListeners(mNotifyTaskStackChanged, msg);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700269 // Only the main task stack change notification requires a delay.
270 mHandler.sendMessageDelayed(msg, NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY);
271 }
272
273 /** Notifies all listeners when an Activity is pinned. */
Winson Chungc81c0ce2017-03-17 12:27:30 -0700274 void notifyActivityPinned(String packageName) {
Yorke Leebd54c2a2016-10-25 13:49:23 -0700275 mHandler.removeMessages(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG);
Winson Chungc81c0ce2017-03-17 12:27:30 -0700276 final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_PINNED_LISTENERS_MSG,
277 packageName);
Yorke Lee13294072017-01-06 14:59:58 -0800278 forAllLocalListeners(mNotifyActivityPinned, msg);
279 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700280 }
281
Winson Chungc81c0ce2017-03-17 12:27:30 -0700282 /** Notifies all listeners when an Activity is unpinned. */
283 void notifyActivityUnpinned() {
284 mHandler.removeMessages(NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG);
285 final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_UNPINNED_LISTENERS_MSG);
286 forAllLocalListeners(mNotifyActivityUnpinned, msg);
287 msg.sendToTarget();
288 }
289
Yorke Leebd54c2a2016-10-25 13:49:23 -0700290 /**
291 * Notifies all listeners when an attempt was made to start an an activity that is already
292 * running in the pinned stack and the activity was not actually started, but the task is
293 * either brought to the front or a new Intent is delivered to it.
294 */
Winson Chungd95687c2017-03-03 12:06:21 -0800295 void notifyPinnedActivityRestartAttempt() {
Yorke Leebd54c2a2016-10-25 13:49:23 -0700296 mHandler.removeMessages(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800297 final Message msg =
Winson Chungd95687c2017-03-03 12:06:21 -0800298 mHandler.obtainMessage(NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800299 forAllLocalListeners(mNotifyPinnedActivityRestartAttempt, msg);
300 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700301 }
302
Winson Chung85d39982017-02-24 15:21:25 -0800303 /** Notifies all listeners when the pinned stack animation starts. */
304 void notifyPinnedStackAnimationStarted() {
305 mHandler.removeMessages(NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG);
306 final Message msg =
307 mHandler.obtainMessage(NOTIFY_PINNED_STACK_ANIMATION_STARTED_LISTENERS_MSG);
308 forAllLocalListeners(mNotifyPinnedStackAnimationStarted, msg);
309 msg.sendToTarget();
310 }
311
Yorke Leebd54c2a2016-10-25 13:49:23 -0700312 /** Notifies all listeners when the pinned stack animation ends. */
313 void notifyPinnedStackAnimationEnded() {
314 mHandler.removeMessages(NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800315 final Message msg =
316 mHandler.obtainMessage(NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG);
317 forAllLocalListeners(mNotifyPinnedStackAnimationEnded, msg);
318 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700319 }
320
321 void notifyActivityDismissingDockedStack() {
322 mHandler.removeMessages(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800323 final Message message = mHandler.obtainMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);
324 forAllLocalListeners(mNotifyActivityDismissingDockedStack, message);
Yorke Leebd54c2a2016-10-25 13:49:23 -0700325 }
326
327 void notifyActivityForcedResizable(int taskId, String packageName) {
328 mHandler.removeMessages(NOTIFY_FORCED_RESIZABLE_MSG);
Yorke Lee13294072017-01-06 14:59:58 -0800329 final Message msg = mHandler.obtainMessage(NOTIFY_FORCED_RESIZABLE_MSG, taskId,
330 0 /* unused */, packageName);
331 forAllLocalListeners(mNotifyActivityForcedResizable, msg);
332 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700333 }
334
335 void notifyTaskCreated(int taskId, ComponentName componentName) {
Yorke Lee13294072017-01-06 14:59:58 -0800336 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_ADDED_LISTENERS_MSG,
337 taskId, 0 /* unused */, componentName);
338 forAllLocalListeners(mNotifyTaskCreated, msg);
339 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700340 }
341
342 void notifyTaskRemoved(int taskId) {
Yorke Lee13294072017-01-06 14:59:58 -0800343 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_REMOVED_LISTENERS_MSG,
344 taskId, 0 /* unused */);
345 forAllLocalListeners(mNotifyTaskRemoved, msg);
346 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700347 }
348
349 void notifyTaskMovedToFront(int taskId) {
Yorke Lee13294072017-01-06 14:59:58 -0800350 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_MOVED_TO_FRONT_LISTENERS_MSG,
351 taskId, 0 /* unused */);
352 forAllLocalListeners(mNotifyTaskMovedToFront, msg);
353 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700354 }
355
356 void notifyTaskDescriptionChanged(int taskId, TaskDescription taskDescription) {
Yorke Lee13294072017-01-06 14:59:58 -0800357 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG,
358 taskId, 0 /* unused */, taskDescription);
359 forAllLocalListeners(mNotifyTaskDescriptionChanged, msg);
360 msg.sendToTarget();
361
Yorke Leebd54c2a2016-10-25 13:49:23 -0700362 }
363
364 void notifyActivityRequestedOrientationChanged(int taskId, int orientation) {
Yorke Lee13294072017-01-06 14:59:58 -0800365 final Message msg = mHandler.obtainMessage(
366 NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS, taskId, orientation);
367 forAllLocalListeners(mNotifyActivityRequestedOrientationChanged, msg);
368 msg.sendToTarget();
Yorke Leebd54c2a2016-10-25 13:49:23 -0700369 }
370
371 /**
372 * Notify listeners that the task is about to be finished before its surfaces are removed from
373 * the window manager. This allows interested parties to perform relevant animations before
374 * the window disappears.
375 */
376 void notifyTaskRemovalStarted(int taskId) {
Yorke Lee13294072017-01-06 14:59:58 -0800377 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_REMOVAL_STARTED_LISTENERS, taskId,
378 0 /* unused */);
379 forAllLocalListeners(mNotifyTaskRemovalStarted, msg);
380 msg.sendToTarget();
381
Yorke Leebd54c2a2016-10-25 13:49:23 -0700382 }
Robin Leec41f6ec2017-01-10 17:02:34 +0000383
384 /**
385 * Notify listeners that the task has been put in a locked state because one or more of the
386 * activities inside it belong to a managed profile user that has been locked.
387 */
388 void notifyTaskProfileLocked(int taskId, int userId) {
Yorke Lee13294072017-01-06 14:59:58 -0800389 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG, taskId,
390 userId);
391 forAllLocalListeners(mNotifyTaskProfileLocked, msg);
392 msg.sendToTarget();
Robin Leec41f6ec2017-01-10 17:02:34 +0000393 }
Jorim Jaggifb9d78a2017-01-05 18:57:12 +0100394
395 /**
396 * Notify listeners that the snapshot of a task has changed.
397 */
398 void notifyTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) {
399 final Message msg = mHandler.obtainMessage(NOTIFY_TASK_SNAPSHOT_CHANGED_LISTENERS_MSG,
400 taskId, 0, snapshot);
401 forAllLocalListeners(mNotifyTaskSnapshotChanged, msg);
402 msg.sendToTarget();
403 }
Yorke Leebd54c2a2016-10-25 13:49:23 -0700404}