1 /* 2 * Copyright (C) 2011 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.os.IBinder; 20 21 import java.io.PrintWriter; 22 import java.util.ArrayList; 23 24 /** 25 * Container of a set of related windows in the window manager. Often this 26 * is an AppWindowToken, which is the handle for an Activity that it uses 27 * to display windows. For nested windows, there is a WindowToken created for 28 * the parent window to manage its children. 29 */ 30 class WindowToken { 31 // The window manager! 32 final WindowManagerService service; 33 34 // The actual token. 35 final IBinder token; 36 37 // The type of window this token is for, as per WindowManager.LayoutParams. 38 final int windowType; 39 40 // Set if this token was explicitly added by a client, so should 41 // not be removed when all windows are removed. 42 final boolean explicit; 43 44 // For printing. 45 String stringName; 46 47 // If this is an AppWindowToken, this is non-null. 48 AppWindowToken appWindowToken; 49 50 // All of the windows associated with this token. 51 final ArrayList<WindowState> windows = new ArrayList<WindowState>(); 52 53 // Is key dispatching paused for this token? 54 boolean paused = false; 55 56 // Should this token's windows be hidden? 57 boolean hidden; 58 59 // Temporary for finding which tokens no longer have visible windows. 60 boolean hasVisible; 61 62 // Set to true when this token is in a pending transaction where it 63 // will be shown. 64 boolean waitingToShow; 65 66 // Set to true when this token is in a pending transaction where it 67 // will be hidden. 68 boolean waitingToHide; 69 70 // Set to true when this token is in a pending transaction where its 71 // windows will be put to the bottom of the list. 72 boolean sendingToBottom; 73 74 WindowToken(WindowManagerService _service, IBinder _token, int type, boolean _explicit) { 75 service = _service; 76 token = _token; 77 windowType = type; 78 explicit = _explicit; 79 } 80 81 void dump(PrintWriter pw, String prefix) { 82 pw.print(prefix); pw.print("windows="); pw.println(windows); 83 pw.print(prefix); pw.print("windowType="); pw.print(windowType); 84 pw.print(" hidden="); pw.print(hidden); 85 pw.print(" hasVisible="); pw.println(hasVisible); 86 if (waitingToShow || waitingToHide || sendingToBottom) { 87 pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow); 88 pw.print(" waitingToHide="); pw.print(waitingToHide); 89 pw.print(" sendingToBottom="); pw.print(sendingToBottom); 90 } 91 } 92 93 @Override 94 public String toString() { 95 if (stringName == null) { 96 StringBuilder sb = new StringBuilder(); 97 sb.append("WindowToken{"); 98 sb.append(Integer.toHexString(System.identityHashCode(this))); 99 sb.append(" "); sb.append(token); sb.append('}'); 100 stringName = sb.toString(); 101 } 102 return stringName; 103 } 104 }