blob: bd0ace89e49d1ea8a876d7a389f2716ed19ab279 [file] [log] [blame]
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001/*
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
17package com.android.server.wm;
18
19import android.os.IBinder;
20
21import java.io.PrintWriter;
22import 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 */
30class 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.
Craig Mautner7b1aa772012-11-30 16:14:45 -080051 final WindowList windows = new WindowList();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080052
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
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080074 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) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080082 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);
Craig Mautneref25d7a2012-05-15 23:01:47 -070086 if (waitingToShow || waitingToHide || sendingToBottom) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080087 pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow);
88 pw.print(" waitingToHide="); pw.print(waitingToHide);
89 pw.print(" sendingToBottom="); pw.print(sendingToBottom);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080090 }
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)));
Dianne Hackbornef03a7f2012-10-29 18:46:52 -070099 sb.append(" "); sb.append(token); sb.append('}');
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800100 stringName = sb.toString();
101 }
102 return stringName;
103 }
104}