blob: a60be3b95d6abe6fb0a5d2224679c852c59d8621 [file] [log] [blame]
Craig Mautnerb1fd65c2013-02-05 13:34:57 -08001/*
2 * Copyright (C) 2013 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.wm;
18
Craig Mautner42bf39e2014-02-21 16:46:22 -080019import static com.android.server.wm.WindowManagerService.TAG;
20
Craig Mautner2c2549c2013-11-12 08:31:15 -080021import android.util.EventLog;
Craig Mautner42bf39e2014-02-21 16:46:22 -080022import android.util.Slog;
Craig Mautner2c2549c2013-11-12 08:31:15 -080023
Craig Mautnerc00204b2013-03-05 15:02:14 -080024class Task {
Craig Mautnerc00204b2013-03-05 15:02:14 -080025 TaskStack mStack;
Craig Mautner05d62722013-02-11 09:39:27 -080026 final AppTokenList mAppTokens = new AppTokenList();
27 final int taskId;
Craig Mautnerac6f8432013-07-17 13:24:59 -070028 final int mUserId;
Craig Mautner9ef471f2014-02-07 13:11:47 -080029 boolean mDeferRemoval = false;
Craig Mautnerb1fd65c2013-02-05 13:34:57 -080030
Craig Mautnerac6f8432013-07-17 13:24:59 -070031 Task(AppWindowToken wtoken, TaskStack stack, int userId) {
Craig Mautnerb1fd65c2013-02-05 13:34:57 -080032 taskId = wtoken.groupId;
Craig Mautnerb1fd65c2013-02-05 13:34:57 -080033 mAppTokens.add(wtoken);
Craig Mautnerc00204b2013-03-05 15:02:14 -080034 mStack = stack;
Craig Mautnerac6f8432013-07-17 13:24:59 -070035 mUserId = userId;
Craig Mautnerc00204b2013-03-05 15:02:14 -080036 }
37
38 DisplayContent getDisplayContent() {
39 return mStack.getDisplayContent();
40 }
41
42 void addAppToken(int addPos, AppWindowToken wtoken) {
Craig Mautner42bf39e2014-02-21 16:46:22 -080043 final int lastPos = mAppTokens.size();
Craig Mautner01f79cf2014-08-27 09:56:02 -070044 for (int pos = 0; pos < lastPos && pos < addPos; ++pos) {
45 if (mAppTokens.get(pos).removed) {
46 // addPos assumes removed tokens are actually gone.
47 ++addPos;
48 }
Craig Mautner42bf39e2014-02-21 16:46:22 -080049 }
Craig Mautnerc00204b2013-03-05 15:02:14 -080050 mAppTokens.add(addPos, wtoken);
Craig Mautner42bf39e2014-02-21 16:46:22 -080051 mDeferRemoval = false;
Craig Mautnerc00204b2013-03-05 15:02:14 -080052 }
53
54 boolean removeAppToken(AppWindowToken wtoken) {
Craig Mautner42bf39e2014-02-21 16:46:22 -080055 boolean removed = mAppTokens.remove(wtoken);
Craig Mautnerc00204b2013-03-05 15:02:14 -080056 if (mAppTokens.size() == 0) {
Craig Mautner2c2549c2013-11-12 08:31:15 -080057 EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
58 "removeAppToken: last token");
Craig Mautnerc00204b2013-03-05 15:02:14 -080059 }
Craig Mautner42bf39e2014-02-21 16:46:22 -080060 return removed;
Craig Mautnerb1fd65c2013-02-05 13:34:57 -080061 }
Craig Mautner5d9c7be2013-02-15 14:02:56 -080062
Craig Mautnercbd84af2014-10-22 13:21:22 -070063 void setSendingToBottom(boolean toBottom) {
64 for (int appTokenNdx = 0; appTokenNdx < mAppTokens.size(); appTokenNdx++) {
65 mAppTokens.get(appTokenNdx).sendingToBottom = toBottom;
66 }
67 }
68
Craig Mautner5d9c7be2013-02-15 14:02:56 -080069 @Override
70 public String toString() {
Craig Mautner4cd0c132013-04-16 15:55:52 -070071 return "{taskId=" + taskId + " appTokens=" + mAppTokens + "}";
Craig Mautner5d9c7be2013-02-15 14:02:56 -080072 }
Craig Mautnerb1fd65c2013-02-05 13:34:57 -080073}