Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 19 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT; |
| 20 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 21 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 22 | import android.os.IBinder; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 23 | import android.util.Slog; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 24 | |
| 25 | import java.io.PrintWriter; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 36 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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. |
Craig Mautner | 7b1aa77 | 2012-11-30 16:14:45 -0800 | [diff] [blame] | 54 | final WindowList windows = new WindowList(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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 Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 73 | WindowToken(WindowManagerService _service, IBinder _token, int type, boolean _explicit) { |
| 74 | service = _service; |
| 75 | token = _token; |
| 76 | windowType = type; |
| 77 | explicit = _explicit; |
| 78 | } |
| 79 | |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 80 | void removeAllWindows() { |
| 81 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 82 | WindowState win = windows.get(winNdx); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 83 | if (DEBUG_WINDOW_MOVEMENT) Slog.w(TAG_WM, "removeAllWindows: removing win=" + win); |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 84 | win.mService.removeWindowLocked(win); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 85 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 86 | windows.clear(); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 89 | void dump(PrintWriter pw, String prefix) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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); |
Wale Ogunwale | 10cb5e2 | 2015-05-24 12:36:21 -0700 | [diff] [blame] | 94 | if (waitingToShow || sendingToBottom) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 96 | pw.print(" sendingToBottom="); pw.print(sendingToBottom); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 97 | } |
| 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 Hackborn | ef03a7f | 2012-10-29 18:46:52 -0700 | [diff] [blame] | 106 | sb.append(" "); sb.append(token); sb.append('}'); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 107 | stringName = sb.toString(); |
| 108 | } |
| 109 | return stringName; |
| 110 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 111 | } |