Home | History | Annotate | Download | only in wm
      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 android.util.EventLog;
     20 import com.android.server.EventLogTags;
     21 
     22 class Task {
     23 //    private final String TAG = "TaskGroup";
     24     TaskStack mStack;
     25     final AppTokenList mAppTokens = new AppTokenList();
     26     final int taskId;
     27     final int mUserId;
     28 
     29     Task(AppWindowToken wtoken, TaskStack stack, int userId) {
     30         taskId = wtoken.groupId;
     31         mAppTokens.add(wtoken);
     32         mStack = stack;
     33         mUserId = userId;
     34     }
     35 
     36     DisplayContent getDisplayContent() {
     37         return mStack.getDisplayContent();
     38     }
     39 
     40     void addAppToken(int addPos, AppWindowToken wtoken) {
     41         mAppTokens.add(addPos, wtoken);
     42     }
     43 
     44     boolean removeAppToken(AppWindowToken wtoken) {
     45         mAppTokens.remove(wtoken);
     46         if (mAppTokens.size() == 0) {
     47             EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
     48                     "removeAppToken: last token");
     49             mStack.removeTask(this);
     50             return true;
     51         }
     52         return false;
     53     }
     54 
     55     @Override
     56     public String toString() {
     57         return "{taskId=" + taskId + " appTokens=" + mAppTokens + "}";
     58     }
     59 }
     60