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 | |
| 19 | import android.os.IBinder; |
| 20 | |
| 21 | import java.io.PrintWriter; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 22 | |
| 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 | */ |
| 29 | class 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 Mautner | 7b1aa77 | 2012-11-30 16:14:45 -0800 | [diff] [blame] | 50 | final WindowList windows = new WindowList(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 51 | |
| 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 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 | |
| 80 | void dump(PrintWriter pw, String prefix) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 81 | 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 Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 85 | if (waitingToShow || waitingToHide || sendingToBottom) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 86 | pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow); |
| 87 | pw.print(" waitingToHide="); pw.print(waitingToHide); |
| 88 | pw.print(" sendingToBottom="); pw.print(sendingToBottom); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 89 | } |
| 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 Hackborn | ef03a7f | 2012-10-29 18:46:52 -0700 | [diff] [blame] | 98 | sb.append(" "); sb.append(token); sb.append('}'); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 99 | stringName = sb.toString(); |
| 100 | } |
| 101 | return stringName; |
| 102 | } |
| 103 | } |