blob: 7894ccfe09a1122f4c01810a20bfde5e1ba05bd6 [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
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080019import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
20import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
21
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080022import android.os.IBinder;
Svetoslav3a5c7212014-10-14 09:54:26 -070023import android.util.Slog;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080024
25import java.io.PrintWriter;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080026
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 */
33class WindowToken {
34 // The window manager!
35 final WindowManagerService service;
Svetoslav3a5c7212014-10-14 09:54:26 -070036
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080037 // 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.
Craig Mautner7b1aa772012-11-30 16:14:45 -080054 final WindowList windows = new WindowList();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080055
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
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080069 // 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
Svetoslav3a5c7212014-10-14 09:54:26 -070080 void removeAllWindows() {
81 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
82 WindowState win = windows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080083 if (DEBUG_WINDOW_MOVEMENT) Slog.w(TAG_WM, "removeAllWindows: removing win=" + win);
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -070084 win.mService.removeWindowLocked(win);
Svetoslav3a5c7212014-10-14 09:54:26 -070085 }
Craig Mautnere3119b72015-01-20 15:02:36 -080086 windows.clear();
Svetoslav3a5c7212014-10-14 09:54:26 -070087 }
88
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080089 void dump(PrintWriter pw, String prefix) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080090 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);
Wale Ogunwale10cb5e22015-05-24 12:36:21 -070094 if (waitingToShow || sendingToBottom) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080095 pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080096 pw.print(" sendingToBottom="); pw.print(sendingToBottom);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097 }
98 }
99
100 @Override
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)));
Dianne Hackbornef03a7f2012-10-29 18:46:52 -0700106 sb.append(" "); sb.append(token); sb.append('}');
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800107 stringName = sb.toString();
108 }
109 return stringName;
110 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800111}