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 static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; |
| 20 | import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 21 | import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 22 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 23 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 25 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 26 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 27 | import com.android.server.input.InputWindowHandle; |
| 28 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 29 | import android.content.Context; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 30 | import android.content.res.Configuration; |
| 31 | import android.graphics.Matrix; |
| 32 | import android.graphics.PixelFormat; |
| 33 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 34 | import android.graphics.RectF; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | import android.graphics.Region; |
| 36 | import android.os.IBinder; |
| 37 | import android.os.RemoteException; |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 38 | import android.os.UserHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 39 | import android.util.Slog; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 40 | import android.view.DisplayInfo; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 41 | import android.view.Gravity; |
| 42 | import android.view.IApplicationToken; |
| 43 | import android.view.IWindow; |
| 44 | import android.view.InputChannel; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 45 | import android.view.View; |
| 46 | import android.view.ViewTreeObserver; |
| 47 | import android.view.WindowManager; |
| 48 | import android.view.WindowManagerPolicy; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 49 | |
| 50 | import java.io.PrintWriter; |
| 51 | import java.util.ArrayList; |
| 52 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 53 | class WindowList extends ArrayList<WindowState> { |
| 54 | } |
| 55 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 56 | /** |
| 57 | * A window in the window manager. |
| 58 | */ |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 59 | final class WindowState implements WindowManagerPolicy.WindowState { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 60 | static final String TAG = "WindowState"; |
| 61 | |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 62 | static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY; |
| 63 | static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS; |
Dianne Hackborn | 3699174 | 2011-10-11 21:35:26 -0700 | [diff] [blame] | 64 | static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 65 | static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC; |
| 66 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 67 | final WindowManagerService mService; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 68 | final WindowManagerPolicy mPolicy; |
| 69 | final Context mContext; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 70 | final Session mSession; |
| 71 | final IWindow mClient; |
| 72 | WindowToken mToken; |
| 73 | WindowToken mRootToken; |
| 74 | AppWindowToken mAppToken; |
| 75 | AppWindowToken mTargetAppToken; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 76 | |
| 77 | // mAttrs.flags is tested in animation without being locked. If the bits tested are ever |
| 78 | // modified they will need to be locked. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 79 | final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams(); |
| 80 | final DeathRecipient mDeathRecipient; |
| 81 | final WindowState mAttachedWindow; |
Craig Mautner | 7b1aa77 | 2012-11-30 16:14:45 -0800 | [diff] [blame] | 82 | final WindowList mChildWindows = new WindowList(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 83 | final int mBaseLayer; |
| 84 | final int mSubLayer; |
| 85 | final boolean mLayoutAttached; |
| 86 | final boolean mIsImWindow; |
| 87 | final boolean mIsWallpaper; |
| 88 | final boolean mIsFloatingLayer; |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 89 | int mSeq; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 90 | boolean mEnforceSizeCompat; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 91 | int mViewVisibility; |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 92 | int mSystemUiVisibility; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 93 | boolean mPolicyVisibility = true; |
| 94 | boolean mPolicyVisibilityAfterAnim = true; |
| 95 | boolean mAppFreezing; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 96 | boolean mAttachedHidden; // is our parent window hidden? |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 97 | boolean mWallpaperVisible; // for wallpaper, what was last vis report? |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * The window size that was requested by the application. These are in |
| 101 | * the application's coordinate space (without compatibility scale applied). |
| 102 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 103 | int mRequestedWidth; |
| 104 | int mRequestedHeight; |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 105 | int mLastRequestedWidth; |
| 106 | int mLastRequestedHeight; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 107 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 108 | int mLayer; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 109 | boolean mHaveFrame; |
| 110 | boolean mObscured; |
| 111 | boolean mTurnOnScreen; |
| 112 | |
| 113 | int mLayoutSeq = -1; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 114 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 115 | Configuration mConfiguration = null; |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 116 | // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned. |
| 117 | // Used only on {@link #TYPE_KEYGUARD}. |
| 118 | private boolean mConfigHasChanged; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 119 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 120 | /** |
| 121 | * Actual frame shown on-screen (may be modified by animation). These |
| 122 | * are in the screen's coordinate space (WITH the compatibility scale |
| 123 | * applied). |
| 124 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 125 | final RectF mShownFrame = new RectF(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 126 | |
| 127 | /** |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 128 | * Insets that determine the actually visible area. These are in the application's |
| 129 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 130 | */ |
| 131 | final Rect mVisibleInsets = new Rect(); |
| 132 | final Rect mLastVisibleInsets = new Rect(); |
| 133 | boolean mVisibleInsetsChanged; |
| 134 | |
| 135 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 136 | * Insets that are covered by system windows (such as the status bar) and |
| 137 | * transient docking windows (such as the IME). These are in the application's |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 138 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 139 | */ |
| 140 | final Rect mContentInsets = new Rect(); |
| 141 | final Rect mLastContentInsets = new Rect(); |
| 142 | boolean mContentInsetsChanged; |
| 143 | |
| 144 | /** |
| 145 | * Set to true if we are waiting for this window to receive its |
| 146 | * given internal insets before laying out other windows based on it. |
| 147 | */ |
| 148 | boolean mGivenInsetsPending; |
| 149 | |
| 150 | /** |
| 151 | * These are the content insets that were given during layout for |
| 152 | * this window, to be applied to windows behind it. |
| 153 | */ |
| 154 | final Rect mGivenContentInsets = new Rect(); |
| 155 | |
| 156 | /** |
| 157 | * These are the visible insets that were given during layout for |
| 158 | * this window, to be applied to windows behind it. |
| 159 | */ |
| 160 | final Rect mGivenVisibleInsets = new Rect(); |
| 161 | |
| 162 | /** |
| 163 | * This is the given touchable area relative to the window frame, or null if none. |
| 164 | */ |
| 165 | final Region mGivenTouchableRegion = new Region(); |
| 166 | |
| 167 | /** |
| 168 | * Flag indicating whether the touchable region should be adjusted by |
| 169 | * the visible insets; if false the area outside the visible insets is |
| 170 | * NOT touchable, so we must use those to adjust the frame during hit |
| 171 | * tests. |
| 172 | */ |
| 173 | int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; |
| 174 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 175 | /** |
| 176 | * This is rectangle of the window's surface that is not covered by |
| 177 | * system decorations. |
| 178 | */ |
| 179 | final Rect mSystemDecorRect = new Rect(); |
| 180 | final Rect mLastSystemDecorRect = new Rect(); |
| 181 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 182 | // Current transformation being applied. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 183 | float mGlobalScale=1; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 184 | float mInvGlobalScale=1; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 185 | float mHScale=1, mVScale=1; |
| 186 | float mLastHScale=1, mLastVScale=1; |
| 187 | final Matrix mTmpMatrix = new Matrix(); |
| 188 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 189 | // "Real" frame that the application sees, in display coordinate space. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 190 | final Rect mFrame = new Rect(); |
| 191 | final Rect mLastFrame = new Rect(); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 192 | // Frame that is scaled to the application's coordinate space when in |
| 193 | // screen size compatibility mode. |
| 194 | final Rect mCompatFrame = new Rect(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 195 | |
| 196 | final Rect mContainingFrame = new Rect(); |
| 197 | final Rect mDisplayFrame = new Rect(); |
| 198 | final Rect mContentFrame = new Rect(); |
| 199 | final Rect mParentFrame = new Rect(); |
| 200 | final Rect mVisibleFrame = new Rect(); |
| 201 | |
| 202 | boolean mContentChanged; |
| 203 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 204 | // If a window showing a wallpaper: the requested offset for the |
| 205 | // wallpaper; if a wallpaper window: the currently applied offset. |
| 206 | float mWallpaperX = -1; |
| 207 | float mWallpaperY = -1; |
| 208 | |
| 209 | // If a window showing a wallpaper: what fraction of the offset |
| 210 | // range corresponds to a full virtual screen. |
| 211 | float mWallpaperXStep = -1; |
| 212 | float mWallpaperYStep = -1; |
| 213 | |
| 214 | // Wallpaper windows: pixels offset based on above variables. |
| 215 | int mXOffset; |
| 216 | int mYOffset; |
| 217 | |
| 218 | // This is set after IWindowSession.relayout() has been called at |
| 219 | // least once for the window. It allows us to detect the situation |
| 220 | // where we don't yet have a surface, but should have one soon, so |
| 221 | // we can give the window focus before waiting for the relayout. |
| 222 | boolean mRelayoutCalled; |
| 223 | |
Dianne Hackborn | b7ff51b | 2012-01-23 19:15:27 -0800 | [diff] [blame] | 224 | // If the application has called relayout() with changes that can |
| 225 | // impact its window's size, we need to perform a layout pass on it |
| 226 | // even if it is not currently visible for layout. This is set |
| 227 | // when in that case until the layout is done. |
| 228 | boolean mLayoutNeeded; |
| 229 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 230 | // Currently running an exit animation? |
| 231 | boolean mExiting; |
| 232 | |
| 233 | // Currently on the mDestroySurface list? |
| 234 | boolean mDestroying; |
| 235 | |
| 236 | // Completely remove from window manager after exit animation? |
| 237 | boolean mRemoveOnExit; |
| 238 | |
| 239 | // Set when the orientation is changing and this window has not yet |
| 240 | // been updated for the new orientation. |
| 241 | boolean mOrientationChanging; |
| 242 | |
| 243 | // Is this window now (or just being) removed? |
| 244 | boolean mRemoved; |
| 245 | |
| 246 | // Temp for keeping track of windows that have been removed when |
| 247 | // rebuilding window list. |
| 248 | boolean mRebuilding; |
| 249 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 250 | // Input channel and input window handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 251 | final InputWindowHandle mInputWindowHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 252 | InputChannel mInputChannel; |
| 253 | |
| 254 | // Used to improve performance of toString() |
| 255 | String mStringNameCache; |
| 256 | CharSequence mLastTitle; |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 257 | boolean mWasExiting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 258 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 259 | final WindowStateAnimator mWinAnimator; |
| 260 | |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 261 | boolean mHasSurface = false; |
| 262 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 263 | DisplayContent mDisplayContent; |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 264 | |
Craig Mautner | a2d7b11 | 2012-08-21 15:12:20 -0700 | [diff] [blame] | 265 | // UserId and appId of the owner. Don't display windows of non-current user. |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 266 | int mOwnerUid; |
| 267 | |
| 268 | /** When true this window can be displayed on screens owther than mOwnerUid's */ |
| 269 | private boolean mShowToOwnerOnly; |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 270 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 271 | WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 272 | WindowState attachedWindow, int seq, WindowManager.LayoutParams a, |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 273 | int viewVisibility, final DisplayContent displayContent) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 274 | mService = service; |
| 275 | mSession = s; |
| 276 | mClient = c; |
| 277 | mToken = token; |
Craig Mautner | a2d7b11 | 2012-08-21 15:12:20 -0700 | [diff] [blame] | 278 | mOwnerUid = s.mUid; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 279 | mAttrs.copyFrom(a); |
| 280 | mViewVisibility = viewVisibility; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 281 | mDisplayContent = displayContent; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 282 | mPolicy = mService.mPolicy; |
| 283 | mContext = mService.mContext; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 284 | DeathRecipient deathRecipient = new DeathRecipient(); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 285 | mSeq = seq; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 286 | mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 287 | if (WindowManagerService.localLOGV) Slog.v( |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 288 | TAG, "Window " + this + " client=" + c.asBinder() |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 289 | + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 290 | try { |
| 291 | c.asBinder().linkToDeath(deathRecipient, 0); |
| 292 | } catch (RemoteException e) { |
| 293 | mDeathRecipient = null; |
| 294 | mAttachedWindow = null; |
| 295 | mLayoutAttached = false; |
| 296 | mIsImWindow = false; |
| 297 | mIsWallpaper = false; |
| 298 | mIsFloatingLayer = false; |
| 299 | mBaseLayer = 0; |
| 300 | mSubLayer = 0; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 301 | mInputWindowHandle = null; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 302 | mWinAnimator = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 303 | return; |
| 304 | } |
| 305 | mDeathRecipient = deathRecipient; |
| 306 | |
| 307 | if ((mAttrs.type >= FIRST_SUB_WINDOW && |
| 308 | mAttrs.type <= LAST_SUB_WINDOW)) { |
| 309 | // The multiplier here is to reserve space for multiple |
| 310 | // windows in the same type layer. |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 311 | mBaseLayer = mPolicy.windowTypeToLayerLw( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 312 | attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 313 | + WindowManagerService.TYPE_LAYER_OFFSET; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 314 | mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 315 | mAttachedWindow = attachedWindow; |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 316 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 317 | mAttachedWindow.mChildWindows.add(this); |
| 318 | mLayoutAttached = mAttrs.type != |
| 319 | WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 320 | mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD |
| 321 | || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 322 | mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER; |
| 323 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 324 | } else { |
| 325 | // The multiplier here is to reserve space for multiple |
| 326 | // windows in the same type layer. |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 327 | mBaseLayer = mPolicy.windowTypeToLayerLw(a.type) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 328 | * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 329 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 330 | mSubLayer = 0; |
| 331 | mAttachedWindow = null; |
| 332 | mLayoutAttached = false; |
| 333 | mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD |
| 334 | || mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 335 | mIsWallpaper = mAttrs.type == TYPE_WALLPAPER; |
| 336 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 337 | } |
| 338 | |
| 339 | WindowState appWin = this; |
| 340 | while (appWin.mAttachedWindow != null) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 341 | appWin = appWin.mAttachedWindow; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 342 | } |
| 343 | WindowToken appToken = appWin.mToken; |
| 344 | while (appToken.appWindowToken == null) { |
| 345 | WindowToken parent = mService.mTokenMap.get(appToken.token); |
| 346 | if (parent == null || appToken == parent) { |
| 347 | break; |
| 348 | } |
| 349 | appToken = parent; |
| 350 | } |
| 351 | mRootToken = appToken; |
| 352 | mAppToken = appToken.appWindowToken; |
| 353 | |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 354 | mWinAnimator = new WindowStateAnimator(this); |
| 355 | mWinAnimator.mAlpha = a.alpha; |
| 356 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 357 | mRequestedWidth = 0; |
| 358 | mRequestedHeight = 0; |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 359 | mLastRequestedWidth = 0; |
| 360 | mLastRequestedHeight = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 361 | mXOffset = 0; |
| 362 | mYOffset = 0; |
| 363 | mLayer = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 364 | mInputWindowHandle = new InputWindowHandle( |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 365 | mAppToken != null ? mAppToken.mInputApplicationHandle : null, this, |
| 366 | displayContent.getDisplayId()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | void attach() { |
| 370 | if (WindowManagerService.localLOGV) Slog.v( |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 371 | TAG, "Attaching " + this + " token=" + mToken |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 372 | + ", list=" + mToken.windows); |
| 373 | mSession.windowAddedLocked(); |
| 374 | } |
| 375 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 376 | @Override |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 377 | public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 378 | mHaveFrame = true; |
| 379 | |
| 380 | final Rect container = mContainingFrame; |
| 381 | container.set(pf); |
| 382 | |
| 383 | final Rect display = mDisplayFrame; |
| 384 | display.set(df); |
| 385 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 386 | final int pw = container.right - container.left; |
| 387 | final int ph = container.bottom - container.top; |
| 388 | |
| 389 | int w,h; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 390 | if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) { |
| 391 | if (mAttrs.width < 0) { |
| 392 | w = pw; |
| 393 | } else if (mEnforceSizeCompat) { |
| 394 | w = (int)(mAttrs.width * mGlobalScale + .5f); |
| 395 | } else { |
| 396 | w = mAttrs.width; |
| 397 | } |
| 398 | if (mAttrs.height < 0) { |
| 399 | h = ph; |
| 400 | } else if (mEnforceSizeCompat) { |
| 401 | h = (int)(mAttrs.height * mGlobalScale + .5f); |
| 402 | } else { |
| 403 | h = mAttrs.height; |
| 404 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 405 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 406 | if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) { |
| 407 | w = pw; |
| 408 | } else if (mEnforceSizeCompat) { |
| 409 | w = (int)(mRequestedWidth * mGlobalScale + .5f); |
| 410 | } else { |
| 411 | w = mRequestedWidth; |
| 412 | } |
| 413 | if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 414 | h = ph; |
| 415 | } else if (mEnforceSizeCompat) { |
| 416 | h = (int)(mRequestedHeight * mGlobalScale + .5f); |
| 417 | } else { |
| 418 | h = mRequestedHeight; |
| 419 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | if (!mParentFrame.equals(pf)) { |
| 423 | //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame |
| 424 | // + " to " + pf); |
| 425 | mParentFrame.set(pf); |
| 426 | mContentChanged = true; |
| 427 | } |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 428 | if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { |
| 429 | mLastRequestedWidth = mRequestedWidth; |
| 430 | mLastRequestedHeight = mRequestedHeight; |
| 431 | mContentChanged = true; |
| 432 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 433 | |
| 434 | final Rect content = mContentFrame; |
| 435 | content.set(cf); |
| 436 | |
| 437 | final Rect visible = mVisibleFrame; |
| 438 | visible.set(vf); |
| 439 | |
| 440 | final Rect frame = mFrame; |
| 441 | final int fw = frame.width(); |
| 442 | final int fh = frame.height(); |
| 443 | |
| 444 | //System.out.println("In: w=" + w + " h=" + h + " container=" + |
| 445 | // container + " x=" + mAttrs.x + " y=" + mAttrs.y); |
| 446 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 447 | float x, y; |
| 448 | if (mEnforceSizeCompat) { |
| 449 | x = mAttrs.x * mGlobalScale; |
| 450 | y = mAttrs.y * mGlobalScale; |
| 451 | } else { |
| 452 | x = mAttrs.x; |
| 453 | y = mAttrs.y; |
| 454 | } |
| 455 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 456 | Gravity.apply(mAttrs.gravity, w, h, container, |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 457 | (int) (x + mAttrs.horizontalMargin * pw), |
| 458 | (int) (y + mAttrs.verticalMargin * ph), frame); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 459 | |
| 460 | //System.out.println("Out: " + mFrame); |
| 461 | |
| 462 | // Now make sure the window fits in the overall display. |
| 463 | Gravity.applyDisplay(mAttrs.gravity, df, frame); |
| 464 | |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 465 | // Make sure the system, content and visible frames are inside of the |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 466 | // final window frame. |
| 467 | if (content.left < frame.left) content.left = frame.left; |
| 468 | if (content.top < frame.top) content.top = frame.top; |
| 469 | if (content.right > frame.right) content.right = frame.right; |
| 470 | if (content.bottom > frame.bottom) content.bottom = frame.bottom; |
| 471 | if (visible.left < frame.left) visible.left = frame.left; |
| 472 | if (visible.top < frame.top) visible.top = frame.top; |
| 473 | if (visible.right > frame.right) visible.right = frame.right; |
| 474 | if (visible.bottom > frame.bottom) visible.bottom = frame.bottom; |
| 475 | |
| 476 | final Rect contentInsets = mContentInsets; |
| 477 | contentInsets.left = content.left-frame.left; |
| 478 | contentInsets.top = content.top-frame.top; |
| 479 | contentInsets.right = frame.right-content.right; |
| 480 | contentInsets.bottom = frame.bottom-content.bottom; |
| 481 | |
| 482 | final Rect visibleInsets = mVisibleInsets; |
| 483 | visibleInsets.left = visible.left-frame.left; |
| 484 | visibleInsets.top = visible.top-frame.top; |
| 485 | visibleInsets.right = frame.right-visible.right; |
| 486 | visibleInsets.bottom = frame.bottom-visible.bottom; |
| 487 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 488 | mCompatFrame.set(frame); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 489 | if (mEnforceSizeCompat) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 490 | // If there is a size compatibility scale being applied to the |
| 491 | // window, we need to apply this to its insets so that they are |
| 492 | // reported to the app in its coordinate space. |
| 493 | contentInsets.scale(mInvGlobalScale); |
| 494 | visibleInsets.scale(mInvGlobalScale); |
| 495 | |
| 496 | // Also the scaled frame that we report to the app needs to be |
| 497 | // adjusted to be in its coordinate space. |
| 498 | mCompatFrame.scale(mInvGlobalScale); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 499 | } |
| 500 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 501 | if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 502 | final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); |
| 503 | mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight, |
| 504 | false); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | if (WindowManagerService.localLOGV) { |
| 508 | //if ("com.google.android.youtube".equals(mAttrs.packageName) |
| 509 | // && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 510 | Slog.v(TAG, "Resolving (mRequestedWidth=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 511 | + mRequestedWidth + ", mRequestedheight=" |
| 512 | + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph |
| 513 | + "): frame=" + mFrame.toShortString() |
| 514 | + " ci=" + contentInsets.toShortString() |
| 515 | + " vi=" + visibleInsets.toShortString()); |
| 516 | //} |
| 517 | } |
| 518 | } |
| 519 | |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 520 | MagnificationSpec getWindowMagnificationSpecLocked() { |
| 521 | MagnificationSpec spec = mDisplayContent.mMagnificationSpec; |
| 522 | if (spec != null && !spec.isNop()) { |
| 523 | if (mAttachedWindow != null) { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 524 | if (!mPolicy.canMagnifyWindowLw(mAttachedWindow.mAttrs)) { |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 525 | return null; |
| 526 | } |
| 527 | } |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 528 | if (!mPolicy.canMagnifyWindowLw(mAttrs)) { |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 529 | return null; |
| 530 | } |
| 531 | } |
| 532 | return spec; |
| 533 | } |
| 534 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 535 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 536 | public Rect getFrameLw() { |
| 537 | return mFrame; |
| 538 | } |
| 539 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 540 | @Override |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 541 | public RectF getShownFrameLw() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 542 | return mShownFrame; |
| 543 | } |
| 544 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 545 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 546 | public Rect getDisplayFrameLw() { |
| 547 | return mDisplayFrame; |
| 548 | } |
| 549 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 550 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 551 | public Rect getContentFrameLw() { |
| 552 | return mContentFrame; |
| 553 | } |
| 554 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 555 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 556 | public Rect getVisibleFrameLw() { |
| 557 | return mVisibleFrame; |
| 558 | } |
| 559 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 560 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 561 | public boolean getGivenInsetsPendingLw() { |
| 562 | return mGivenInsetsPending; |
| 563 | } |
| 564 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 565 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 566 | public Rect getGivenContentInsetsLw() { |
| 567 | return mGivenContentInsets; |
| 568 | } |
| 569 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 570 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 571 | public Rect getGivenVisibleInsetsLw() { |
| 572 | return mGivenVisibleInsets; |
| 573 | } |
| 574 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 575 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 576 | public WindowManager.LayoutParams getAttrs() { |
| 577 | return mAttrs; |
| 578 | } |
| 579 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 580 | @Override |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 581 | public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) { |
| 582 | int index = -1; |
| 583 | WindowState ws = this; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 584 | WindowList windows = getWindowList(); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 585 | while (true) { |
| 586 | if ((ws.mAttrs.privateFlags |
| 587 | & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) { |
| 588 | return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0; |
| 589 | } |
| 590 | // If we reached the bottom of the range of windows we are considering, |
| 591 | // assume no menu is needed. |
| 592 | if (ws == bottom) { |
| 593 | return false; |
| 594 | } |
| 595 | // The current window hasn't specified whether menu key is needed; |
| 596 | // look behind it. |
| 597 | // First, we may need to determine the starting position. |
| 598 | if (index < 0) { |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 599 | index = windows.indexOf(ws); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 600 | } |
| 601 | index--; |
| 602 | if (index < 0) { |
| 603 | return false; |
| 604 | } |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 605 | ws = windows.get(index); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 606 | } |
| 607 | } |
| 608 | |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 609 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 610 | public int getSystemUiVisibility() { |
| 611 | return mSystemUiVisibility; |
| 612 | } |
| 613 | |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 614 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 615 | public int getSurfaceLayer() { |
| 616 | return mLayer; |
| 617 | } |
| 618 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 619 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 620 | public IApplicationToken getAppToken() { |
| 621 | return mAppToken != null ? mAppToken.appToken : null; |
| 622 | } |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 623 | |
| 624 | public int getDisplayId() { |
| 625 | return mDisplayContent.getDisplayId(); |
| 626 | } |
| 627 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 628 | public long getInputDispatchingTimeoutNanos() { |
| 629 | return mAppToken != null |
| 630 | ? mAppToken.inputDispatchingTimeoutNanos |
| 631 | : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS; |
| 632 | } |
| 633 | |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 634 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 635 | public boolean hasAppShownWindows() { |
Craig Mautner | f412095 | 2012-06-21 18:25:39 -0700 | [diff] [blame] | 636 | return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 637 | } |
| 638 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 639 | boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { |
| 640 | if (dsdx < .99999f || dsdx > 1.00001f) return false; |
| 641 | if (dtdy < .99999f || dtdy > 1.00001f) return false; |
| 642 | if (dtdx < -.000001f || dtdx > .000001f) return false; |
| 643 | if (dsdy < -.000001f || dsdy > .000001f) return false; |
| 644 | return true; |
| 645 | } |
| 646 | |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 647 | void prelayout() { |
| 648 | if (mEnforceSizeCompat) { |
| 649 | mGlobalScale = mService.mCompatibleScreenScale; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 650 | mInvGlobalScale = 1/mGlobalScale; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 651 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 652 | mGlobalScale = mInvGlobalScale = 1; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 656 | /** |
| 657 | * Is this window visible? It is not visible if there is no |
| 658 | * surface, or we are in the process of running an exit animation |
| 659 | * that will remove the surface, or its app token has been hidden. |
| 660 | */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 661 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 662 | public boolean isVisibleLw() { |
| 663 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 664 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 665 | && (atoken == null || !atoken.hiddenRequested) |
| 666 | && !mExiting && !mDestroying; |
| 667 | } |
| 668 | |
| 669 | /** |
| 670 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 671 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 672 | * things like window flags that impact the keyguard. |
| 673 | * XXX I am starting to think we need to have ANOTHER visibility flag |
| 674 | * for this "hidden behind keyguard" state rather than overloading |
| 675 | * mPolicyVisibility. Ungh. |
| 676 | */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 677 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 678 | public boolean isVisibleOrBehindKeyguardLw() { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 679 | if (mRootToken.waitingToShow && |
| 680 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 681 | return false; |
| 682 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 683 | final AppWindowToken atoken = mAppToken; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 684 | final boolean animating = atoken != null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 685 | ? (atoken.mAppAnimator.animation != null) : false; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 686 | return mHasSurface && !mDestroying && !mExiting |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 687 | && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 688 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 689 | && !mRootToken.hidden) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 690 | || mWinAnimator.mAnimation != null || animating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | /** |
| 694 | * Is this window visible, ignoring its app token? It is not visible |
| 695 | * if there is no surface, or we are in the process of running an exit animation |
| 696 | * that will remove the surface. |
| 697 | */ |
| 698 | public boolean isWinVisibleLw() { |
| 699 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 700 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 701 | && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 702 | && !mExiting && !mDestroying; |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * The same as isVisible(), but follows the current hidden state of |
| 707 | * the associated app token, not the pending requested hidden state. |
| 708 | */ |
| 709 | boolean isVisibleNow() { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 710 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 711 | && !mRootToken.hidden && !mExiting && !mDestroying; |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Can this window possibly be a drag/drop target? The test here is |
| 716 | * a combination of the above "visible now" with the check that the |
| 717 | * Input Manager uses when discarding windows from input consideration. |
| 718 | */ |
| 719 | boolean isPotentialDragTarget() { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 720 | return isVisibleNow() && !mRemoved |
| 721 | && mInputChannel != null && mInputWindowHandle != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | /** |
| 725 | * Same as isVisible(), but we also count it as visible between the |
| 726 | * call to IWindowSession.add() and the first relayout(). |
| 727 | */ |
| 728 | boolean isVisibleOrAdding() { |
| 729 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | bf08af3 | 2012-05-16 19:43:42 -0700 | [diff] [blame] | 730 | return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 731 | && mPolicyVisibility && !mAttachedHidden |
| 732 | && (atoken == null || !atoken.hiddenRequested) |
| 733 | && !mExiting && !mDestroying; |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * Is this window currently on-screen? It is on-screen either if it |
| 738 | * is visible or it is currently running an animation before no longer |
| 739 | * being visible. |
| 740 | */ |
| 741 | boolean isOnScreen() { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 742 | if (!mHasSurface || !mPolicyVisibility || mDestroying) { |
| 743 | return false; |
| 744 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 745 | final AppWindowToken atoken = mAppToken; |
| 746 | if (atoken != null) { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 747 | return ((!mAttachedHidden && !atoken.hiddenRequested) |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 748 | || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 749 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 750 | return !mAttachedHidden || mWinAnimator.mAnimation != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | /** |
| 754 | * Like isOnScreen(), but we don't return true if the window is part |
| 755 | * of a transition that has not yet been started. |
| 756 | */ |
| 757 | boolean isReadyForDisplay() { |
| 758 | if (mRootToken.waitingToShow && |
| 759 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 760 | return false; |
| 761 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 762 | return mHasSurface && mPolicyVisibility && !mDestroying |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 763 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 764 | && !mRootToken.hidden) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 765 | || mWinAnimator.mAnimation != null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 766 | || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null))); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 767 | } |
| 768 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 769 | /** |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 770 | * Like isReadyForDisplay(), but ignores any force hiding of the window due |
| 771 | * to the keyguard. |
| 772 | */ |
| 773 | boolean isReadyForDisplayIgnoringKeyguard() { |
| 774 | if (mRootToken.waitingToShow && |
| 775 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 776 | return false; |
| 777 | } |
| 778 | final AppWindowToken atoken = mAppToken; |
| 779 | if (atoken == null && !mPolicyVisibility) { |
| 780 | // If this is not an app window, and the policy has asked to force |
| 781 | // hide, then we really do want to hide. |
| 782 | return false; |
| 783 | } |
| 784 | return mHasSurface && !mDestroying |
| 785 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 786 | && !mRootToken.hidden) |
| 787 | || mWinAnimator.mAnimation != null |
Craig Mautner | 9c5bf3b | 2012-06-22 15:19:13 -0700 | [diff] [blame] | 788 | || ((atoken != null) && (atoken.mAppAnimator.animation != null) |
| 789 | && !mWinAnimator.isDummyAnimation())); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | /** |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 793 | * Like isOnScreen, but returns false if the surface hasn't yet |
| 794 | * been drawn. |
| 795 | */ |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 796 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 797 | public boolean isDisplayedLw() { |
| 798 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | bf90eaa | 2012-03-15 11:28:53 -0700 | [diff] [blame] | 799 | return isDrawnLw() && mPolicyVisibility |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 800 | && ((!mAttachedHidden && |
| 801 | (atoken == null || !atoken.hiddenRequested)) |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 802 | || mWinAnimator.mAnimating |
| 803 | || (atoken != null && atoken.mAppAnimator.animation != null)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 804 | } |
| 805 | |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 806 | /** |
| 807 | * Return true if this window (or a window it is attached to, but not |
| 808 | * considering its app token) is currently animating. |
| 809 | */ |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 810 | @Override |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 811 | public boolean isAnimatingLw() { |
| 812 | return mWinAnimator.mAnimation != null; |
| 813 | } |
| 814 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 815 | @Override |
Dianne Hackborn | cfbf7de | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 816 | public boolean isGoneForLayoutLw() { |
| 817 | final AppWindowToken atoken = mAppToken; |
| 818 | return mViewVisibility == View.GONE |
| 819 | || !mRelayoutCalled |
| 820 | || (atoken == null && mRootToken.hidden) |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 821 | || (atoken != null && (atoken.hiddenRequested || atoken.hidden)) |
Dianne Hackborn | cfbf7de | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 822 | || mAttachedHidden |
| 823 | || mExiting || mDestroying; |
| 824 | } |
| 825 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 826 | /** |
| 827 | * Returns true if the window has a surface that it has drawn a |
| 828 | * complete UI in to. |
| 829 | */ |
| 830 | public boolean isDrawnLw() { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 831 | return mHasSurface && !mDestroying && |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 832 | (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW |
| 833 | || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | /** |
| 837 | * Return true if the window is opaque and fully drawn. This indicates |
| 838 | * it may obscure windows behind it. |
| 839 | */ |
| 840 | boolean isOpaqueDrawn() { |
| 841 | return (mAttrs.format == PixelFormat.OPAQUE |
| 842 | || mAttrs.type == TYPE_WALLPAPER) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 843 | && isDrawnLw() && mWinAnimator.mAnimation == null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 844 | && (mAppToken == null || mAppToken.mAppAnimator.animation == null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /** |
| 848 | * Return whether this window is wanting to have a translation |
| 849 | * animation applied to it for an in-progress move. (Only makes |
| 850 | * sense to call from performLayoutAndPlaceSurfacesLockedInner().) |
| 851 | */ |
| 852 | boolean shouldAnimateMove() { |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 853 | return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay() |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 854 | && (mFrame.top != mLastFrame.top |
| 855 | || mFrame.left != mLastFrame.left) |
Craig Mautner | 2fb98b1 | 2012-03-20 17:24:00 -0700 | [diff] [blame] | 856 | && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 857 | } |
| 858 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 859 | boolean isFullscreen(int screenWidth, int screenHeight) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 860 | return mFrame.left <= 0 && mFrame.top <= 0 && |
| 861 | mFrame.right >= screenWidth && mFrame.bottom >= screenHeight; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 862 | } |
| 863 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 864 | boolean isConfigChanged() { |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 865 | boolean configChanged = mConfiguration != mService.mCurConfiguration |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 866 | && (mConfiguration == null |
| 867 | || (mConfiguration.diff(mService.mCurConfiguration) != 0)); |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 868 | |
| 869 | if (mAttrs.type == TYPE_KEYGUARD) { |
| 870 | // Retain configuration changed status until resetConfiguration called. |
| 871 | mConfigHasChanged |= configChanged; |
| 872 | configChanged = mConfigHasChanged; |
| 873 | } |
| 874 | |
| 875 | return configChanged; |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | boolean isConfigDiff(int mask) { |
| 879 | return mConfiguration != mService.mCurConfiguration |
| 880 | && mConfiguration != null |
| 881 | && (mConfiguration.diff(mService.mCurConfiguration) & mask) != 0; |
| 882 | } |
| 883 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 884 | void removeLocked() { |
| 885 | disposeInputChannel(); |
| 886 | |
| 887 | if (mAttachedWindow != null) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 888 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 889 | mAttachedWindow.mChildWindows.remove(this); |
| 890 | } |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 891 | mWinAnimator.destroyDeferredSurfaceLocked(false); |
| 892 | mWinAnimator.destroySurfaceLocked(false); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 893 | mSession.windowRemovedLocked(); |
| 894 | try { |
| 895 | mClient.asBinder().unlinkToDeath(mDeathRecipient, 0); |
| 896 | } catch (RuntimeException e) { |
| 897 | // Ignore if it has already been removed (usually because |
| 898 | // we are doing this as part of processing a death note.) |
| 899 | } |
| 900 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 901 | |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 902 | void setConfiguration(final Configuration newConfig) { |
| 903 | mConfiguration = newConfig; |
| 904 | mConfigHasChanged = false; |
| 905 | } |
| 906 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 907 | void setInputChannel(InputChannel inputChannel) { |
| 908 | if (mInputChannel != null) { |
| 909 | throw new IllegalStateException("Window already has an input channel."); |
| 910 | } |
| 911 | |
| 912 | mInputChannel = inputChannel; |
| 913 | mInputWindowHandle.inputChannel = inputChannel; |
| 914 | } |
| 915 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 916 | void disposeInputChannel() { |
| 917 | if (mInputChannel != null) { |
| 918 | mService.mInputManager.unregisterInputChannel(mInputChannel); |
| 919 | |
| 920 | mInputChannel.dispose(); |
| 921 | mInputChannel = null; |
| 922 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 923 | |
| 924 | mInputWindowHandle.inputChannel = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | private class DeathRecipient implements IBinder.DeathRecipient { |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 928 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 929 | public void binderDied() { |
| 930 | try { |
| 931 | synchronized(mService.mWindowMap) { |
| 932 | WindowState win = mService.windowForClientLocked(mSession, mClient, false); |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 933 | Slog.i(TAG, "WIN DEATH: " + win); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 934 | if (win != null) { |
| 935 | mService.removeWindowLocked(mSession, win); |
| 936 | } |
| 937 | } |
| 938 | } catch (IllegalArgumentException ex) { |
| 939 | // This will happen if the window has already been |
| 940 | // removed. |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 945 | /** Returns true if this window desires key events. |
| 946 | * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget} |
| 947 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 948 | public final boolean canReceiveKeys() { |
| 949 | return isVisibleOrAdding() |
| 950 | && (mViewVisibility == View.VISIBLE) |
| 951 | && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0); |
| 952 | } |
| 953 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 954 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 955 | public boolean hasDrawnLw() { |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 956 | return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 957 | } |
| 958 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 959 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 960 | public boolean showLw(boolean doAnimation) { |
| 961 | return showLw(doAnimation, true); |
| 962 | } |
| 963 | |
| 964 | boolean showLw(boolean doAnimation, boolean requestAnim) { |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 965 | if (isHiddenFromUserLocked()) { |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 966 | Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display " |
Craig Mautner | a2d7b11 | 2012-08-21 15:12:20 -0700 | [diff] [blame] | 967 | + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid); |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 968 | return false; |
| 969 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 970 | if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 971 | // Already showing. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 972 | return false; |
| 973 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 974 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 975 | if (doAnimation) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 976 | if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility=" |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 977 | + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation); |
Craig Mautner | 2fb98b1 | 2012-03-20 17:24:00 -0700 | [diff] [blame] | 978 | if (!mService.okToDisplay()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 979 | doAnimation = false; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 980 | } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 981 | // Check for the case where we are currently visible and |
| 982 | // not animating; we do not want to do animation at such a |
| 983 | // point to become visible when we already are. |
| 984 | doAnimation = false; |
| 985 | } |
| 986 | } |
| 987 | mPolicyVisibility = true; |
| 988 | mPolicyVisibilityAfterAnim = true; |
| 989 | if (doAnimation) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 990 | mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 991 | } |
| 992 | if (requestAnim) { |
Craig Mautner | 711f90a | 2012-07-03 18:43:52 -0700 | [diff] [blame] | 993 | mService.updateLayoutToAnimationLocked(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 994 | } |
| 995 | return true; |
| 996 | } |
| 997 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 998 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 999 | public boolean hideLw(boolean doAnimation) { |
| 1000 | return hideLw(doAnimation, true); |
| 1001 | } |
| 1002 | |
| 1003 | boolean hideLw(boolean doAnimation, boolean requestAnim) { |
| 1004 | if (doAnimation) { |
Craig Mautner | 2fb98b1 | 2012-03-20 17:24:00 -0700 | [diff] [blame] | 1005 | if (!mService.okToDisplay()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1006 | doAnimation = false; |
| 1007 | } |
| 1008 | } |
| 1009 | boolean current = doAnimation ? mPolicyVisibilityAfterAnim |
| 1010 | : mPolicyVisibility; |
| 1011 | if (!current) { |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 1012 | // Already hiding. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1013 | return false; |
| 1014 | } |
| 1015 | if (doAnimation) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1016 | mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1017 | if (mWinAnimator.mAnimation == null) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1018 | doAnimation = false; |
| 1019 | } |
| 1020 | } |
| 1021 | if (doAnimation) { |
| 1022 | mPolicyVisibilityAfterAnim = false; |
| 1023 | } else { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1024 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1025 | mPolicyVisibilityAfterAnim = false; |
| 1026 | mPolicyVisibility = false; |
| 1027 | // Window is no longer visible -- make sure if we were waiting |
| 1028 | // for it to be displayed before enabling the display, that |
| 1029 | // we allow the display to be enabled now. |
| 1030 | mService.enableScreenIfNeededLocked(); |
| 1031 | if (mService.mCurrentFocus == this) { |
| 1032 | mService.mFocusMayChange = true; |
| 1033 | } |
| 1034 | } |
| 1035 | if (requestAnim) { |
Craig Mautner | 711f90a | 2012-07-03 18:43:52 -0700 | [diff] [blame] | 1036 | mService.updateLayoutToAnimationLocked(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1037 | } |
| 1038 | return true; |
| 1039 | } |
| 1040 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1041 | @Override |
| 1042 | public boolean isAlive() { |
| 1043 | return mClient.asBinder().isBinderAlive(); |
| 1044 | } |
| 1045 | |
Craig Mautner | a987d43 | 2012-10-11 14:07:58 -0700 | [diff] [blame] | 1046 | boolean isClosing() { |
| 1047 | return mExiting || (mService.mClosingApps.contains(mAppToken)); |
| 1048 | } |
| 1049 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1050 | @Override |
| 1051 | public boolean isDefaultDisplay() { |
| 1052 | return mDisplayContent.isDefaultDisplay; |
| 1053 | } |
| 1054 | |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1055 | public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) { |
| 1056 | mShowToOwnerOnly = showToOwnerOnly; |
| 1057 | } |
| 1058 | |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1059 | boolean isHiddenFromUserLocked() { |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1060 | // Attached windows are evaluated based on the window that they are attached to. |
| 1061 | WindowState win = this; |
| 1062 | while (win.mAttachedWindow != null) { |
| 1063 | win = win.mAttachedWindow; |
| 1064 | } |
| 1065 | if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1066 | && win.mAppToken != null && win.mAppToken.showWhenLocked) { |
| 1067 | // Save some cycles by not calling getDisplayInfo unless it is an application |
| 1068 | // window intended for all users. |
| 1069 | final DisplayInfo displayInfo = win.mDisplayContent.getDisplayInfo(); |
| 1070 | if (win.mFrame.left <= 0 && win.mFrame.top <= 0 |
| 1071 | && win.mFrame.right >= displayInfo.appWidth |
| 1072 | && win.mFrame.bottom >= displayInfo.appHeight) { |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1073 | // Is a fullscreen window, like the clock alarm. Show to everyone. |
| 1074 | return false; |
| 1075 | } |
| 1076 | } |
| 1077 | |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1078 | return win.mShowToOwnerOnly |
| 1079 | && UserHandle.getUserId(win.mOwnerUid) != mService.mCurrentUserId; |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1082 | private static void applyInsets(Region outRegion, Rect frame, Rect inset) { |
| 1083 | outRegion.set( |
| 1084 | frame.left + inset.left, frame.top + inset.top, |
| 1085 | frame.right - inset.right, frame.bottom - inset.bottom); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1086 | } |
| 1087 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1088 | public void getTouchableRegion(Region outRegion) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1089 | final Rect frame = mFrame; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1090 | switch (mTouchableInsets) { |
| 1091 | default: |
| 1092 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME: |
| 1093 | outRegion.set(frame); |
| 1094 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1095 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1096 | applyInsets(outRegion, frame, mGivenContentInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1097 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1098 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1099 | applyInsets(outRegion, frame, mGivenVisibleInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1100 | break; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1101 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: { |
| 1102 | final Region givenTouchableRegion = mGivenTouchableRegion; |
| 1103 | outRegion.set(givenTouchableRegion); |
| 1104 | outRegion.translate(frame.left, frame.top); |
| 1105 | break; |
| 1106 | } |
| 1107 | } |
| 1108 | } |
| 1109 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1110 | WindowList getWindowList() { |
| 1111 | return mDisplayContent.getWindowList(); |
| 1112 | } |
| 1113 | |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1114 | void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1115 | pw.print(prefix); pw.print("mDisplayId="); pw.print(mDisplayContent.getDisplayId()); |
| 1116 | pw.print(" mSession="); pw.print(mSession); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1117 | pw.print(" mClient="); pw.println(mClient.asBinder()); |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1118 | pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid); |
| 1119 | pw.print(" mShowToOwnerOnly="); pw.println(mShowToOwnerOnly); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1120 | pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1121 | pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); |
| 1122 | pw.print(" h="); pw.print(mRequestedHeight); |
| 1123 | pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 1124 | if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { |
| 1125 | pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth); |
| 1126 | pw.print(" h="); pw.println(mLastRequestedHeight); |
| 1127 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1128 | if (mAttachedWindow != null || mLayoutAttached) { |
| 1129 | pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); |
| 1130 | pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); |
| 1131 | } |
| 1132 | if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) { |
| 1133 | pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow); |
| 1134 | pw.print(" mIsWallpaper="); pw.print(mIsWallpaper); |
| 1135 | pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer); |
| 1136 | pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible); |
| 1137 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1138 | if (dumpAll) { |
| 1139 | pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); |
| 1140 | pw.print(" mSubLayer="); pw.print(mSubLayer); |
| 1141 | pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1142 | pw.print((mTargetAppToken != null ? |
| 1143 | mTargetAppToken.mAppAnimator.animLayerAdjustment |
| 1144 | : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0))); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1145 | pw.print("="); pw.print(mWinAnimator.mAnimLayer); |
| 1146 | pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer); |
Dianne Hackborn | 6d05fd3 | 2011-11-19 14:36:15 -0800 | [diff] [blame] | 1147 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1148 | if (dumpAll) { |
| 1149 | pw.print(prefix); pw.print("mToken="); pw.println(mToken); |
| 1150 | pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); |
| 1151 | if (mAppToken != null) { |
| 1152 | pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); |
| 1153 | } |
| 1154 | if (mTargetAppToken != null) { |
| 1155 | pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); |
| 1156 | } |
| 1157 | pw.print(prefix); pw.print("mViewVisibility=0x"); |
| 1158 | pw.print(Integer.toHexString(mViewVisibility)); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1159 | pw.print(" mHaveFrame="); pw.print(mHaveFrame); |
| 1160 | pw.print(" mObscured="); pw.println(mObscured); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 1161 | pw.print(prefix); pw.print("mSeq="); pw.print(mSeq); |
| 1162 | pw.print(" mSystemUiVisibility=0x"); |
| 1163 | pw.println(Integer.toHexString(mSystemUiVisibility)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1164 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1165 | if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { |
| 1166 | pw.print(prefix); pw.print("mPolicyVisibility="); |
| 1167 | pw.print(mPolicyVisibility); |
| 1168 | pw.print(" mPolicyVisibilityAfterAnim="); |
| 1169 | pw.print(mPolicyVisibilityAfterAnim); |
| 1170 | pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); |
| 1171 | } |
Dianne Hackborn | b7ff51b | 2012-01-23 19:15:27 -0800 | [diff] [blame] | 1172 | if (!mRelayoutCalled || mLayoutNeeded) { |
| 1173 | pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled); |
| 1174 | pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1175 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1176 | if (mXOffset != 0 || mYOffset != 0) { |
| 1177 | pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); |
| 1178 | pw.print(" y="); pw.println(mYOffset); |
| 1179 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1180 | if (dumpAll) { |
| 1181 | pw.print(prefix); pw.print("mGivenContentInsets="); |
| 1182 | mGivenContentInsets.printShortString(pw); |
| 1183 | pw.print(" mGivenVisibleInsets="); |
| 1184 | mGivenVisibleInsets.printShortString(pw); |
| 1185 | pw.println(); |
| 1186 | if (mTouchableInsets != 0 || mGivenInsetsPending) { |
| 1187 | pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); |
| 1188 | pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1189 | Region region = new Region(); |
| 1190 | getTouchableRegion(region); |
| 1191 | pw.print(prefix); pw.print("touchable region="); pw.println(region); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1192 | } |
| 1193 | pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1194 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1195 | pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface); |
Craig Mautner | 178af59 | 2012-09-17 10:37:29 -0700 | [diff] [blame] | 1196 | pw.print(" mShownFrame="); mShownFrame.printShortString(pw); |
| 1197 | pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay()); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1198 | if (dumpAll) { |
| 1199 | pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); |
| 1200 | pw.print(" last="); mLastFrame.printShortString(pw); |
| 1201 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1202 | pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw); |
| 1203 | pw.print(" last="); mLastSystemDecorRect.printShortString(pw); |
| 1204 | pw.println(); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1205 | } |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1206 | if (mEnforceSizeCompat) { |
| 1207 | pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1208 | pw.println(); |
| 1209 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1210 | if (dumpAll) { |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1211 | pw.print(prefix); pw.print("Frames: containing="); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1212 | mContainingFrame.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1213 | pw.print(" parent="); mParentFrame.printShortString(pw); |
| 1214 | pw.print(" display="); mDisplayFrame.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1215 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1216 | pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1217 | pw.print(" visible="); mVisibleFrame.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1218 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1219 | pw.print(prefix); pw.print("Cur insets: content="); |
| 1220 | mContentInsets.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1221 | pw.print(" visible="); mVisibleInsets.printShortString(pw); |
| 1222 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1223 | pw.print(prefix); pw.print("Lst insets: content="); |
| 1224 | mLastContentInsets.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1225 | pw.print(" visible="); mLastVisibleInsets.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1226 | pw.println(); |
| 1227 | } |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 1228 | pw.print(prefix); pw.print(mWinAnimator); pw.println(":"); |
| 1229 | mWinAnimator.dump(pw, prefix + " ", dumpAll); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1230 | if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { |
| 1231 | pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); |
| 1232 | pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); |
| 1233 | pw.print(" mDestroying="); pw.print(mDestroying); |
| 1234 | pw.print(" mRemoved="); pw.println(mRemoved); |
| 1235 | } |
| 1236 | if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { |
| 1237 | pw.print(prefix); pw.print("mOrientationChanging="); |
| 1238 | pw.print(mOrientationChanging); |
| 1239 | pw.print(" mAppFreezing="); pw.print(mAppFreezing); |
| 1240 | pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); |
| 1241 | } |
| 1242 | if (mHScale != 1 || mVScale != 1) { |
| 1243 | pw.print(prefix); pw.print("mHScale="); pw.print(mHScale); |
| 1244 | pw.print(" mVScale="); pw.println(mVScale); |
| 1245 | } |
| 1246 | if (mWallpaperX != -1 || mWallpaperY != -1) { |
| 1247 | pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); |
| 1248 | pw.print(" mWallpaperY="); pw.println(mWallpaperY); |
| 1249 | } |
| 1250 | if (mWallpaperXStep != -1 || mWallpaperYStep != -1) { |
| 1251 | pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep); |
| 1252 | pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep); |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | String makeInputChannelName() { |
| 1257 | return Integer.toHexString(System.identityHashCode(this)) |
| 1258 | + " " + mAttrs.getTitle(); |
| 1259 | } |
| 1260 | |
| 1261 | @Override |
| 1262 | public String toString() { |
| 1263 | if (mStringNameCache == null || mLastTitle != mAttrs.getTitle() |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 1264 | || mWasExiting != mExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1265 | mLastTitle = mAttrs.getTitle(); |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 1266 | mWasExiting = mExiting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1267 | mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 1268 | + " u" + UserHandle.getUserId(mSession.mUid) |
Craig Mautner | a987d43 | 2012-10-11 14:07:58 -0700 | [diff] [blame] | 1269 | + " " + mLastTitle + (mExiting ? " EXITING}" : "}"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1270 | } |
| 1271 | return mStringNameCache; |
| 1272 | } |
satok | cef37fb | 2011-10-24 21:49:38 +0900 | [diff] [blame] | 1273 | } |