1 /* 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 17 package com.android.server.wm; 18 19 import static com.android.server.wm.WindowManagerService.TAG; 20 21 import android.util.EventLog; 22 import android.util.Slog; 23 24 class Task { 25 TaskStack mStack; 26 final AppTokenList mAppTokens = new AppTokenList(); 27 final int taskId; 28 final int mUserId; 29 boolean mDeferRemoval = false; 30 Task(AppWindowToken wtoken, TaskStack stack, int userId)31 Task(AppWindowToken wtoken, TaskStack stack, int userId) { 32 taskId = wtoken.groupId; 33 mAppTokens.add(wtoken); 34 mStack = stack; 35 mUserId = userId; 36 } 37 getDisplayContent()38 DisplayContent getDisplayContent() { 39 return mStack.getDisplayContent(); 40 } 41 addAppToken(int addPos, AppWindowToken wtoken)42 void addAppToken(int addPos, AppWindowToken wtoken) { 43 final int lastPos = mAppTokens.size(); 44 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 } 49 } 50 mAppTokens.add(addPos, wtoken); 51 mDeferRemoval = false; 52 } 53 removeAppToken(AppWindowToken wtoken)54 boolean removeAppToken(AppWindowToken wtoken) { 55 boolean removed = mAppTokens.remove(wtoken); 56 if (mAppTokens.size() == 0) { 57 EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId, 58 "removeAppToken: last token"); 59 } 60 return removed; 61 } 62 setSendingToBottom(boolean toBottom)63 void setSendingToBottom(boolean toBottom) { 64 for (int appTokenNdx = 0; appTokenNdx < mAppTokens.size(); appTokenNdx++) { 65 mAppTokens.get(appTokenNdx).sendingToBottom = toBottom; 66 } 67 } 68 69 @Override toString()70 public String toString() { 71 return "{taskId=" + taskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}"; 72 } 73 } 74