blob: 036804c55b7d0d73e2e2551a0cebc35ddb828f96 [file] [log] [blame]
Craig Mautnerb1fd65c02013-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 Mautner2c2549c2013-11-12 08:31:15 -080019import android.util.EventLog;
20import com.android.server.EventLogTags;
21
Craig Mautnerc00204b2013-03-05 15:02:14 -080022class Task {
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080023// private final String TAG = "TaskGroup";
Craig Mautnerc00204b2013-03-05 15:02:14 -080024 TaskStack mStack;
Craig Mautner05d6272ba2013-02-11 09:39:27 -080025 final AppTokenList mAppTokens = new AppTokenList();
26 final int taskId;
Craig Mautnerac6f8432013-07-17 13:24:59 -070027 final int mUserId;
Craig Mautner9ef471f2014-02-07 13:11:47 -080028 boolean mDeferRemoval = false;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080029
Craig Mautnerac6f8432013-07-17 13:24:59 -070030 Task(AppWindowToken wtoken, TaskStack stack, int userId) {
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080031 taskId = wtoken.groupId;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080032 mAppTokens.add(wtoken);
Craig Mautnerc00204b2013-03-05 15:02:14 -080033 mStack = stack;
Craig Mautnerac6f8432013-07-17 13:24:59 -070034 mUserId = userId;
Craig Mautnerc00204b2013-03-05 15:02:14 -080035 }
36
37 DisplayContent getDisplayContent() {
38 return mStack.getDisplayContent();
39 }
40
41 void addAppToken(int addPos, AppWindowToken wtoken) {
42 mAppTokens.add(addPos, wtoken);
43 }
44
45 boolean removeAppToken(AppWindowToken wtoken) {
46 mAppTokens.remove(wtoken);
47 if (mAppTokens.size() == 0) {
Craig Mautner2c2549c2013-11-12 08:31:15 -080048 EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
49 "removeAppToken: last token");
Craig Mautnerc00204b2013-03-05 15:02:14 -080050 return true;
51 }
52 return false;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080053 }
Craig Mautner5d9c7be2013-02-15 14:02:56 -080054
55 @Override
56 public String toString() {
Craig Mautner4cd0c13f2013-04-16 15:55:52 -070057 return "{taskId=" + taskId + " appTokens=" + mAppTokens + "}";
Craig Mautner5d9c7be2013-02-15 14:02:56 -080058 }
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080059}