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