• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     // Set to true when this token is in a pending transaction where its
75     // windows will be put to the top of the list.
76     boolean sendingToTop;
77 
WindowToken(WindowManagerService _service, IBinder _token, int type, boolean _explicit)78     WindowToken(WindowManagerService _service, IBinder _token, int type, boolean _explicit) {
79         service = _service;
80         token = _token;
81         windowType = type;
82         explicit = _explicit;
83     }
84 
dump(PrintWriter pw, String prefix)85     void dump(PrintWriter pw, String prefix) {
86         pw.print(prefix); pw.print("token="); pw.println(token);
87         pw.print(prefix); pw.print("windows="); pw.println(windows);
88         pw.print(prefix); pw.print("windowType="); pw.print(windowType);
89                 pw.print(" hidden="); pw.print(hidden);
90                 pw.print(" hasVisible="); pw.println(hasVisible);
91         if (waitingToShow || waitingToHide || sendingToBottom || sendingToTop) {
92             pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow);
93                     pw.print(" waitingToHide="); pw.print(waitingToHide);
94                     pw.print(" sendingToBottom="); pw.print(sendingToBottom);
95                     pw.print(" sendingToTop="); pw.println(sendingToTop);
96         }
97     }
98 
99     @Override
toString()100     public String toString() {
101         if (stringName == null) {
102             StringBuilder sb = new StringBuilder();
103             sb.append("WindowToken{");
104             sb.append(Integer.toHexString(System.identityHashCode(this)));
105             sb.append(" token="); sb.append(token); sb.append('}');
106             stringName = sb.toString();
107         }
108         return stringName;
109     }
110 }