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