blob: 22671234c5384ff4461b98e7cef6d7966068ed15 [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;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080022
23/**
24 * Container of a set of related windows in the window manager. Often this
25 * is an AppWindowToken, which is the handle for an Activity that it uses
26 * to display windows. For nested windows, there is a WindowToken created for
27 * the parent window to manage its children.
28 */
29class WindowToken {
30 // The window manager!
31 final WindowManagerService service;
32
33 // The actual token.
34 final IBinder token;
35
36 // The type of window this token is for, as per WindowManager.LayoutParams.
37 final int windowType;
38
39 // Set if this token was explicitly added by a client, so should
40 // not be removed when all windows are removed.
41 final boolean explicit;
42
43 // For printing.
44 String stringName;
45
46 // If this is an AppWindowToken, this is non-null.
47 AppWindowToken appWindowToken;
48
49 // All of the windows associated with this token.
Craig Mautner7b1aa772012-11-30 16:14:45 -080050 final WindowList windows = new WindowList();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080051
52 // Is key dispatching paused for this token?
53 boolean paused = false;
54
55 // Should this token's windows be hidden?
56 boolean hidden;
57
58 // Temporary for finding which tokens no longer have visible windows.
59 boolean hasVisible;
60
61 // Set to true when this token is in a pending transaction where it
62 // will be shown.
63 boolean waitingToShow;
64
65 // Set to true when this token is in a pending transaction where it
66 // will be hidden.
67 boolean waitingToHide;
68
69 // Set to true when this token is in a pending transaction where its
70 // windows will be put to the bottom of the list.
71 boolean sendingToBottom;
72
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080073 WindowToken(WindowManagerService _service, IBinder _token, int type, boolean _explicit) {
74 service = _service;
75 token = _token;
76 windowType = type;
77 explicit = _explicit;
78 }
79
80 void dump(PrintWriter pw, String prefix) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080081 pw.print(prefix); pw.print("windows="); pw.println(windows);
82 pw.print(prefix); pw.print("windowType="); pw.print(windowType);
83 pw.print(" hidden="); pw.print(hidden);
84 pw.print(" hasVisible="); pw.println(hasVisible);
Craig Mautneref25d7a2012-05-15 23:01:47 -070085 if (waitingToShow || waitingToHide || sendingToBottom) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080086 pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow);
87 pw.print(" waitingToHide="); pw.print(waitingToHide);
88 pw.print(" sendingToBottom="); pw.print(sendingToBottom);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080089 }
90 }
91
92 @Override
93 public String toString() {
94 if (stringName == null) {
95 StringBuilder sb = new StringBuilder();
96 sb.append("WindowToken{");
97 sb.append(Integer.toHexString(System.identityHashCode(this)));
Dianne Hackbornef03a7f2012-10-29 18:46:52 -070098 sb.append(" "); sb.append(token); sb.append('}');
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080099 stringName = sb.toString();
100 }
101 return stringName;
102 }
103}