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; |
| 22 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
| 23 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 24 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 25 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 26 | |
| 27 | import com.android.server.wm.WindowManagerService.H; |
| 28 | |
| 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; |
| 42 | import android.view.Surface; |
| 43 | import android.view.View; |
| 44 | import android.view.ViewTreeObserver; |
| 45 | import android.view.WindowManager; |
| 46 | import android.view.WindowManagerPolicy; |
| 47 | import android.view.WindowManager.LayoutParams; |
| 48 | import android.view.animation.Animation; |
| 49 | import android.view.animation.Transformation; |
| 50 | |
| 51 | import java.io.PrintWriter; |
| 52 | import java.util.ArrayList; |
| 53 | |
| 54 | /** |
| 55 | * A window in the window manager. |
| 56 | */ |
| 57 | final class WindowState implements WindowManagerPolicy.WindowState { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 58 | static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY; |
| 59 | static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS; |
| 60 | static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC; |
| 61 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 62 | final WindowManagerService mService; |
| 63 | final Session mSession; |
| 64 | final IWindow mClient; |
| 65 | WindowToken mToken; |
| 66 | WindowToken mRootToken; |
| 67 | AppWindowToken mAppToken; |
| 68 | AppWindowToken mTargetAppToken; |
| 69 | final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams(); |
| 70 | final DeathRecipient mDeathRecipient; |
| 71 | final WindowState mAttachedWindow; |
| 72 | final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>(); |
| 73 | final int mBaseLayer; |
| 74 | final int mSubLayer; |
| 75 | final boolean mLayoutAttached; |
| 76 | final boolean mIsImWindow; |
| 77 | final boolean mIsWallpaper; |
| 78 | final boolean mIsFloatingLayer; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 79 | boolean mEnforceSizeCompat; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 80 | int mViewVisibility; |
| 81 | boolean mPolicyVisibility = true; |
| 82 | boolean mPolicyVisibilityAfterAnim = true; |
| 83 | boolean mAppFreezing; |
| 84 | Surface mSurface; |
| 85 | boolean mReportDestroySurface; |
| 86 | boolean mSurfacePendingDestroy; |
| 87 | boolean mAttachedHidden; // is our parent window hidden? |
| 88 | boolean mLastHidden; // was this window last hidden? |
| 89 | boolean mWallpaperVisible; // for wallpaper, what was last vis report? |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * The window size that was requested by the application. These are in |
| 93 | * the application's coordinate space (without compatibility scale applied). |
| 94 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | int mRequestedWidth; |
| 96 | int mRequestedHeight; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 97 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 98 | int mLayer; |
| 99 | int mAnimLayer; |
| 100 | int mLastLayer; |
| 101 | boolean mHaveFrame; |
| 102 | boolean mObscured; |
| 103 | boolean mTurnOnScreen; |
| 104 | |
| 105 | int mLayoutSeq = -1; |
| 106 | |
| 107 | Configuration mConfiguration = null; |
| 108 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 109 | /** |
| 110 | * Actual frame shown on-screen (may be modified by animation). These |
| 111 | * are in the screen's coordinate space (WITH the compatibility scale |
| 112 | * applied). |
| 113 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 114 | final RectF mShownFrame = new RectF(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Set when we have changed the size of the surface, to know that |
| 118 | * we must tell them application to resize (and thus redraw itself). |
| 119 | */ |
| 120 | boolean mSurfaceResized; |
| 121 | |
| 122 | /** |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 123 | * Insets that determine the actually visible area. These are in the application's |
| 124 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 125 | */ |
| 126 | final Rect mVisibleInsets = new Rect(); |
| 127 | final Rect mLastVisibleInsets = new Rect(); |
| 128 | boolean mVisibleInsetsChanged; |
| 129 | |
| 130 | /** |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 131 | * Insets that are covered by system windows. These are in the application's |
| 132 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 133 | */ |
| 134 | final Rect mContentInsets = new Rect(); |
| 135 | final Rect mLastContentInsets = new Rect(); |
| 136 | boolean mContentInsetsChanged; |
| 137 | |
| 138 | /** |
| 139 | * Set to true if we are waiting for this window to receive its |
| 140 | * given internal insets before laying out other windows based on it. |
| 141 | */ |
| 142 | boolean mGivenInsetsPending; |
| 143 | |
| 144 | /** |
| 145 | * These are the content insets that were given during layout for |
| 146 | * this window, to be applied to windows behind it. |
| 147 | */ |
| 148 | final Rect mGivenContentInsets = new Rect(); |
| 149 | |
| 150 | /** |
| 151 | * These are the visible insets that were given during layout for |
| 152 | * this window, to be applied to windows behind it. |
| 153 | */ |
| 154 | final Rect mGivenVisibleInsets = new Rect(); |
| 155 | |
| 156 | /** |
| 157 | * This is the given touchable area relative to the window frame, or null if none. |
| 158 | */ |
| 159 | final Region mGivenTouchableRegion = new Region(); |
| 160 | |
| 161 | /** |
| 162 | * Flag indicating whether the touchable region should be adjusted by |
| 163 | * the visible insets; if false the area outside the visible insets is |
| 164 | * NOT touchable, so we must use those to adjust the frame during hit |
| 165 | * tests. |
| 166 | */ |
| 167 | int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; |
| 168 | |
| 169 | // Current transformation being applied. |
| 170 | boolean mHaveMatrix; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 171 | float mGlobalScale=1; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 172 | float mInvGlobalScale=1; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 173 | float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1; |
| 174 | float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1; |
| 175 | float mHScale=1, mVScale=1; |
| 176 | float mLastHScale=1, mLastVScale=1; |
| 177 | final Matrix mTmpMatrix = new Matrix(); |
| 178 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 179 | // "Real" frame that the application sees, in display coordinate space. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 180 | final Rect mFrame = new Rect(); |
| 181 | final Rect mLastFrame = new Rect(); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 182 | // Frame that is scaled to the application's coordinate space when in |
| 183 | // screen size compatibility mode. |
| 184 | final Rect mCompatFrame = new Rect(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 185 | |
| 186 | final Rect mContainingFrame = new Rect(); |
| 187 | final Rect mDisplayFrame = new Rect(); |
| 188 | final Rect mContentFrame = new Rect(); |
| 189 | final Rect mParentFrame = new Rect(); |
| 190 | final Rect mVisibleFrame = new Rect(); |
| 191 | |
| 192 | boolean mContentChanged; |
| 193 | |
| 194 | float mShownAlpha = 1; |
| 195 | float mAlpha = 1; |
| 196 | float mLastAlpha = 1; |
| 197 | |
| 198 | // Set to true if, when the window gets displayed, it should perform |
| 199 | // an enter animation. |
| 200 | boolean mEnterAnimationPending; |
| 201 | |
| 202 | // Currently running animation. |
| 203 | boolean mAnimating; |
| 204 | boolean mLocalAnimating; |
| 205 | Animation mAnimation; |
| 206 | boolean mAnimationIsEntrance; |
| 207 | boolean mHasTransformation; |
| 208 | boolean mHasLocalTransformation; |
| 209 | final Transformation mTransformation = new Transformation(); |
| 210 | |
| 211 | // If a window showing a wallpaper: the requested offset for the |
| 212 | // wallpaper; if a wallpaper window: the currently applied offset. |
| 213 | float mWallpaperX = -1; |
| 214 | float mWallpaperY = -1; |
| 215 | |
| 216 | // If a window showing a wallpaper: what fraction of the offset |
| 217 | // range corresponds to a full virtual screen. |
| 218 | float mWallpaperXStep = -1; |
| 219 | float mWallpaperYStep = -1; |
| 220 | |
| 221 | // Wallpaper windows: pixels offset based on above variables. |
| 222 | int mXOffset; |
| 223 | int mYOffset; |
| 224 | |
| 225 | // This is set after IWindowSession.relayout() has been called at |
| 226 | // least once for the window. It allows us to detect the situation |
| 227 | // where we don't yet have a surface, but should have one soon, so |
| 228 | // we can give the window focus before waiting for the relayout. |
| 229 | boolean mRelayoutCalled; |
| 230 | |
| 231 | // This is set after the Surface has been created but before the |
| 232 | // window has been drawn. During this time the surface is hidden. |
| 233 | boolean mDrawPending; |
| 234 | |
| 235 | // This is set after the window has finished drawing for the first |
| 236 | // time but before its surface is shown. The surface will be |
| 237 | // displayed when the next layout is run. |
| 238 | boolean mCommitDrawPending; |
| 239 | |
| 240 | // This is set during the time after the window's drawing has been |
| 241 | // committed, and before its surface is actually shown. It is used |
| 242 | // to delay showing the surface until all windows in a token are ready |
| 243 | // to be shown. |
| 244 | boolean mReadyToShow; |
| 245 | |
| 246 | // Set when the window has been shown in the screen the first time. |
| 247 | boolean mHasDrawn; |
| 248 | |
| 249 | // Currently running an exit animation? |
| 250 | boolean mExiting; |
| 251 | |
| 252 | // Currently on the mDestroySurface list? |
| 253 | boolean mDestroying; |
| 254 | |
| 255 | // Completely remove from window manager after exit animation? |
| 256 | boolean mRemoveOnExit; |
| 257 | |
| 258 | // Set when the orientation is changing and this window has not yet |
| 259 | // been updated for the new orientation. |
| 260 | boolean mOrientationChanging; |
| 261 | |
| 262 | // Is this window now (or just being) removed? |
| 263 | boolean mRemoved; |
| 264 | |
| 265 | // Temp for keeping track of windows that have been removed when |
| 266 | // rebuilding window list. |
| 267 | boolean mRebuilding; |
| 268 | |
| 269 | // For debugging, this is the last information given to the surface flinger. |
| 270 | boolean mSurfaceShown; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 271 | float mSurfaceX, mSurfaceY, mSurfaceW, mSurfaceH; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 272 | int mSurfaceLayer; |
| 273 | float mSurfaceAlpha; |
| 274 | |
| 275 | // Input channel and input window handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 276 | final InputWindowHandle mInputWindowHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 277 | InputChannel mInputChannel; |
| 278 | |
| 279 | // Used to improve performance of toString() |
| 280 | String mStringNameCache; |
| 281 | CharSequence mLastTitle; |
| 282 | boolean mWasPaused; |
| 283 | |
| 284 | WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, |
| 285 | WindowState attachedWindow, WindowManager.LayoutParams a, |
| 286 | int viewVisibility) { |
| 287 | mService = service; |
| 288 | mSession = s; |
| 289 | mClient = c; |
| 290 | mToken = token; |
| 291 | mAttrs.copyFrom(a); |
| 292 | mViewVisibility = viewVisibility; |
| 293 | DeathRecipient deathRecipient = new DeathRecipient(); |
| 294 | mAlpha = a.alpha; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 295 | mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 296 | if (WindowManagerService.localLOGV) Slog.v( |
| 297 | WindowManagerService.TAG, "Window " + this + " client=" + c.asBinder() |
| 298 | + " token=" + token + " (" + mAttrs.token + ")"); |
| 299 | try { |
| 300 | c.asBinder().linkToDeath(deathRecipient, 0); |
| 301 | } catch (RemoteException e) { |
| 302 | mDeathRecipient = null; |
| 303 | mAttachedWindow = null; |
| 304 | mLayoutAttached = false; |
| 305 | mIsImWindow = false; |
| 306 | mIsWallpaper = false; |
| 307 | mIsFloatingLayer = false; |
| 308 | mBaseLayer = 0; |
| 309 | mSubLayer = 0; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 310 | mInputWindowHandle = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 311 | return; |
| 312 | } |
| 313 | mDeathRecipient = deathRecipient; |
| 314 | |
| 315 | if ((mAttrs.type >= FIRST_SUB_WINDOW && |
| 316 | mAttrs.type <= LAST_SUB_WINDOW)) { |
| 317 | // The multiplier here is to reserve space for multiple |
| 318 | // windows in the same type layer. |
| 319 | mBaseLayer = mService.mPolicy.windowTypeToLayerLw( |
| 320 | attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 321 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 322 | mSubLayer = mService.mPolicy.subWindowTypeToLayerLw(a.type); |
| 323 | mAttachedWindow = attachedWindow; |
| 324 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(WindowManagerService.TAG, "Adding " + this + " to " + mAttachedWindow); |
| 325 | mAttachedWindow.mChildWindows.add(this); |
| 326 | mLayoutAttached = mAttrs.type != |
| 327 | WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 328 | mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD |
| 329 | || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 330 | mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER; |
| 331 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 332 | } else { |
| 333 | // The multiplier here is to reserve space for multiple |
| 334 | // windows in the same type layer. |
| 335 | mBaseLayer = mService.mPolicy.windowTypeToLayerLw(a.type) |
| 336 | * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 337 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 338 | mSubLayer = 0; |
| 339 | mAttachedWindow = null; |
| 340 | mLayoutAttached = false; |
| 341 | mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD |
| 342 | || mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 343 | mIsWallpaper = mAttrs.type == TYPE_WALLPAPER; |
| 344 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 345 | } |
| 346 | |
| 347 | WindowState appWin = this; |
| 348 | while (appWin.mAttachedWindow != null) { |
| 349 | appWin = mAttachedWindow; |
| 350 | } |
| 351 | WindowToken appToken = appWin.mToken; |
| 352 | while (appToken.appWindowToken == null) { |
| 353 | WindowToken parent = mService.mTokenMap.get(appToken.token); |
| 354 | if (parent == null || appToken == parent) { |
| 355 | break; |
| 356 | } |
| 357 | appToken = parent; |
| 358 | } |
| 359 | mRootToken = appToken; |
| 360 | mAppToken = appToken.appWindowToken; |
| 361 | |
| 362 | mSurface = null; |
| 363 | mRequestedWidth = 0; |
| 364 | mRequestedHeight = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 365 | mXOffset = 0; |
| 366 | mYOffset = 0; |
| 367 | mLayer = 0; |
| 368 | mAnimLayer = 0; |
| 369 | mLastLayer = 0; |
| 370 | mInputWindowHandle = new InputWindowHandle( |
| 371 | mAppToken != null ? mAppToken.mInputApplicationHandle : null, this); |
| 372 | } |
| 373 | |
| 374 | void attach() { |
| 375 | if (WindowManagerService.localLOGV) Slog.v( |
| 376 | WindowManagerService.TAG, "Attaching " + this + " token=" + mToken |
| 377 | + ", list=" + mToken.windows); |
| 378 | mSession.windowAddedLocked(); |
| 379 | } |
| 380 | |
| 381 | public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) { |
| 382 | mHaveFrame = true; |
| 383 | |
| 384 | final Rect container = mContainingFrame; |
| 385 | container.set(pf); |
| 386 | |
| 387 | final Rect display = mDisplayFrame; |
| 388 | display.set(df); |
| 389 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 390 | final int pw = container.right - container.left; |
| 391 | final int ph = container.bottom - container.top; |
| 392 | |
| 393 | int w,h; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 394 | if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) { |
| 395 | if (mAttrs.width < 0) { |
| 396 | w = pw; |
| 397 | } else if (mEnforceSizeCompat) { |
| 398 | w = (int)(mAttrs.width * mGlobalScale + .5f); |
| 399 | } else { |
| 400 | w = mAttrs.width; |
| 401 | } |
| 402 | if (mAttrs.height < 0) { |
| 403 | h = ph; |
| 404 | } else if (mEnforceSizeCompat) { |
| 405 | h = (int)(mAttrs.height * mGlobalScale + .5f); |
| 406 | } else { |
| 407 | h = mAttrs.height; |
| 408 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 409 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 410 | if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) { |
| 411 | w = pw; |
| 412 | } else if (mEnforceSizeCompat) { |
| 413 | w = (int)(mRequestedWidth * mGlobalScale + .5f); |
| 414 | } else { |
| 415 | w = mRequestedWidth; |
| 416 | } |
| 417 | if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 418 | h = ph; |
| 419 | } else if (mEnforceSizeCompat) { |
| 420 | h = (int)(mRequestedHeight * mGlobalScale + .5f); |
| 421 | } else { |
| 422 | h = mRequestedHeight; |
| 423 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | if (!mParentFrame.equals(pf)) { |
| 427 | //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame |
| 428 | // + " to " + pf); |
| 429 | mParentFrame.set(pf); |
| 430 | mContentChanged = true; |
| 431 | } |
| 432 | |
| 433 | final Rect content = mContentFrame; |
| 434 | content.set(cf); |
| 435 | |
| 436 | final Rect visible = mVisibleFrame; |
| 437 | visible.set(vf); |
| 438 | |
| 439 | final Rect frame = mFrame; |
| 440 | final int fw = frame.width(); |
| 441 | final int fh = frame.height(); |
| 442 | |
| 443 | //System.out.println("In: w=" + w + " h=" + h + " container=" + |
| 444 | // container + " x=" + mAttrs.x + " y=" + mAttrs.y); |
| 445 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 446 | float x, y; |
| 447 | if (mEnforceSizeCompat) { |
| 448 | x = mAttrs.x * mGlobalScale; |
| 449 | y = mAttrs.y * mGlobalScale; |
| 450 | } else { |
| 451 | x = mAttrs.x; |
| 452 | y = mAttrs.y; |
| 453 | } |
| 454 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 455 | Gravity.apply(mAttrs.gravity, w, h, container, |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 456 | (int) (x + mAttrs.horizontalMargin * pw), |
| 457 | (int) (y + mAttrs.verticalMargin * ph), frame); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 458 | |
| 459 | //System.out.println("Out: " + mFrame); |
| 460 | |
| 461 | // Now make sure the window fits in the overall display. |
| 462 | Gravity.applyDisplay(mAttrs.gravity, df, frame); |
| 463 | |
| 464 | // Make sure the content and visible frames are inside of the |
| 465 | // final window frame. |
| 466 | if (content.left < frame.left) content.left = frame.left; |
| 467 | if (content.top < frame.top) content.top = frame.top; |
| 468 | if (content.right > frame.right) content.right = frame.right; |
| 469 | if (content.bottom > frame.bottom) content.bottom = frame.bottom; |
| 470 | if (visible.left < frame.left) visible.left = frame.left; |
| 471 | if (visible.top < frame.top) visible.top = frame.top; |
| 472 | if (visible.right > frame.right) visible.right = frame.right; |
| 473 | if (visible.bottom > frame.bottom) visible.bottom = frame.bottom; |
| 474 | |
| 475 | final Rect contentInsets = mContentInsets; |
| 476 | contentInsets.left = content.left-frame.left; |
| 477 | contentInsets.top = content.top-frame.top; |
| 478 | contentInsets.right = frame.right-content.right; |
| 479 | contentInsets.bottom = frame.bottom-content.bottom; |
| 480 | |
| 481 | final Rect visibleInsets = mVisibleInsets; |
| 482 | visibleInsets.left = visible.left-frame.left; |
| 483 | visibleInsets.top = visible.top-frame.top; |
| 484 | visibleInsets.right = frame.right-visible.right; |
| 485 | visibleInsets.bottom = frame.bottom-visible.bottom; |
| 486 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 487 | mCompatFrame.set(frame); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 488 | if (mEnforceSizeCompat) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 489 | // If there is a size compatibility scale being applied to the |
| 490 | // window, we need to apply this to its insets so that they are |
| 491 | // reported to the app in its coordinate space. |
| 492 | contentInsets.scale(mInvGlobalScale); |
| 493 | visibleInsets.scale(mInvGlobalScale); |
| 494 | |
| 495 | // Also the scaled frame that we report to the app needs to be |
| 496 | // adjusted to be in its coordinate space. |
| 497 | mCompatFrame.scale(mInvGlobalScale); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 498 | } |
| 499 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 500 | if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 501 | mService.updateWallpaperOffsetLocked(this, |
| 502 | mService.mAppDisplayWidth, mService.mAppDisplayHeight, false); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | if (WindowManagerService.localLOGV) { |
| 506 | //if ("com.google.android.youtube".equals(mAttrs.packageName) |
| 507 | // && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { |
| 508 | Slog.v(WindowManagerService.TAG, "Resolving (mRequestedWidth=" |
| 509 | + mRequestedWidth + ", mRequestedheight=" |
| 510 | + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph |
| 511 | + "): frame=" + mFrame.toShortString() |
| 512 | + " ci=" + contentInsets.toShortString() |
| 513 | + " vi=" + visibleInsets.toShortString()); |
| 514 | //} |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | public Rect getFrameLw() { |
| 519 | return mFrame; |
| 520 | } |
| 521 | |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 522 | public RectF getShownFrameLw() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 523 | return mShownFrame; |
| 524 | } |
| 525 | |
| 526 | public Rect getDisplayFrameLw() { |
| 527 | return mDisplayFrame; |
| 528 | } |
| 529 | |
| 530 | public Rect getContentFrameLw() { |
| 531 | return mContentFrame; |
| 532 | } |
| 533 | |
| 534 | public Rect getVisibleFrameLw() { |
| 535 | return mVisibleFrame; |
| 536 | } |
| 537 | |
| 538 | public boolean getGivenInsetsPendingLw() { |
| 539 | return mGivenInsetsPending; |
| 540 | } |
| 541 | |
| 542 | public Rect getGivenContentInsetsLw() { |
| 543 | return mGivenContentInsets; |
| 544 | } |
| 545 | |
| 546 | public Rect getGivenVisibleInsetsLw() { |
| 547 | return mGivenVisibleInsets; |
| 548 | } |
| 549 | |
| 550 | public WindowManager.LayoutParams getAttrs() { |
| 551 | return mAttrs; |
| 552 | } |
| 553 | |
| 554 | public int getSurfaceLayer() { |
| 555 | return mLayer; |
| 556 | } |
| 557 | |
| 558 | public IApplicationToken getAppToken() { |
| 559 | return mAppToken != null ? mAppToken.appToken : null; |
| 560 | } |
| 561 | |
| 562 | public long getInputDispatchingTimeoutNanos() { |
| 563 | return mAppToken != null |
| 564 | ? mAppToken.inputDispatchingTimeoutNanos |
| 565 | : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS; |
| 566 | } |
| 567 | |
| 568 | public boolean hasAppShownWindows() { |
| 569 | return mAppToken != null ? mAppToken.firstWindowDrawn : false; |
| 570 | } |
| 571 | |
| 572 | public void setAnimation(Animation anim) { |
| 573 | if (WindowManagerService.localLOGV) Slog.v( |
| 574 | WindowManagerService.TAG, "Setting animation in " + this + ": " + anim); |
| 575 | mAnimating = false; |
| 576 | mLocalAnimating = false; |
| 577 | mAnimation = anim; |
| 578 | mAnimation.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION); |
| 579 | mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale); |
| 580 | } |
| 581 | |
| 582 | public void clearAnimation() { |
| 583 | if (mAnimation != null) { |
| 584 | mAnimating = true; |
| 585 | mLocalAnimating = false; |
| 586 | mAnimation.cancel(); |
| 587 | mAnimation = null; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | Surface createSurfaceLocked() { |
| 592 | if (mSurface == null) { |
| 593 | mReportDestroySurface = false; |
| 594 | mSurfacePendingDestroy = false; |
| 595 | mDrawPending = true; |
| 596 | mCommitDrawPending = false; |
| 597 | mReadyToShow = false; |
| 598 | if (mAppToken != null) { |
| 599 | mAppToken.allDrawn = false; |
| 600 | } |
| 601 | |
| 602 | int flags = 0; |
| 603 | |
| 604 | if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) { |
| 605 | flags |= Surface.SECURE; |
| 606 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 607 | if (DEBUG_VISIBILITY) Slog.v( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 608 | WindowManagerService.TAG, "Creating surface in session " |
| 609 | + mSession.mSurfaceSession + " window " + this |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 610 | + " w=" + mCompatFrame.width() |
| 611 | + " h=" + mCompatFrame.height() + " format=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 612 | + mAttrs.format + " flags=" + flags); |
| 613 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 614 | int w = mCompatFrame.width(); |
| 615 | int h = mCompatFrame.height(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 616 | if ((mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { |
| 617 | // for a scaled surface, we always want the requested |
| 618 | // size. |
| 619 | w = mRequestedWidth; |
| 620 | h = mRequestedHeight; |
| 621 | } |
| 622 | |
| 623 | // Something is wrong and SurfaceFlinger will not like this, |
| 624 | // try to revert to sane values |
| 625 | if (w <= 0) w = 1; |
| 626 | if (h <= 0) h = 1; |
| 627 | |
| 628 | mSurfaceShown = false; |
| 629 | mSurfaceLayer = 0; |
| 630 | mSurfaceAlpha = 1; |
| 631 | mSurfaceX = 0; |
| 632 | mSurfaceY = 0; |
| 633 | mSurfaceW = w; |
| 634 | mSurfaceH = h; |
| 635 | try { |
| 636 | final boolean isHwAccelerated = (mAttrs.flags & |
| 637 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; |
| 638 | final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : mAttrs.format; |
| 639 | if (isHwAccelerated && mAttrs.format == PixelFormat.OPAQUE) { |
| 640 | flags |= Surface.OPAQUE; |
| 641 | } |
| 642 | mSurface = new Surface( |
| 643 | mSession.mSurfaceSession, mSession.mPid, |
| 644 | mAttrs.getTitle().toString(), |
| 645 | 0, w, h, format, flags); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 646 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG, |
| 647 | " CREATE SURFACE " |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 648 | + mSurface + " IN SESSION " |
| 649 | + mSession.mSurfaceSession |
| 650 | + ": pid=" + mSession.mPid + " format=" |
| 651 | + mAttrs.format + " flags=0x" |
| 652 | + Integer.toHexString(flags) |
| 653 | + " / " + this); |
| 654 | } catch (Surface.OutOfResourcesException e) { |
| 655 | Slog.w(WindowManagerService.TAG, "OutOfResourcesException creating surface"); |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 656 | mService.reclaimSomeSurfaceMemoryLocked(this, "create", true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 657 | return null; |
| 658 | } catch (Exception e) { |
| 659 | Slog.e(WindowManagerService.TAG, "Exception creating surface", e); |
| 660 | return null; |
| 661 | } |
| 662 | |
| 663 | if (WindowManagerService.localLOGV) Slog.v( |
| 664 | WindowManagerService.TAG, "Got surface: " + mSurface |
| 665 | + ", set left=" + mFrame.left + " top=" + mFrame.top |
| 666 | + ", animLayer=" + mAnimLayer); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 667 | if (SHOW_TRANSACTIONS) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 668 | Slog.i(WindowManagerService.TAG, ">>> OPEN TRANSACTION createSurfaceLocked"); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 669 | WindowManagerService.logSurface(this, "CREATE pos=(" + mFrame.left |
| 670 | + "," + mFrame.top + ") (" + |
| 671 | mCompatFrame.width() + "x" + mCompatFrame.height() + "), layer=" + |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 672 | mAnimLayer + " HIDE", null); |
| 673 | } |
| 674 | Surface.openTransaction(); |
| 675 | try { |
| 676 | try { |
| 677 | mSurfaceX = mFrame.left + mXOffset; |
| 678 | mSurfaceY = mFrame.top + mYOffset; |
| 679 | mSurface.setPosition(mSurfaceX, mSurfaceY); |
| 680 | mSurfaceLayer = mAnimLayer; |
| 681 | mSurface.setLayer(mAnimLayer); |
| 682 | mSurfaceShown = false; |
| 683 | mSurface.hide(); |
| 684 | if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 685 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "DITHER", null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 686 | mSurface.setFlags(Surface.SURFACE_DITHER, |
| 687 | Surface.SURFACE_DITHER); |
| 688 | } |
| 689 | } catch (RuntimeException e) { |
| 690 | Slog.w(WindowManagerService.TAG, "Error creating surface in " + w, e); |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 691 | mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 692 | } |
| 693 | mLastHidden = true; |
| 694 | } finally { |
| 695 | Surface.closeTransaction(); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 696 | if (SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "<<< CLOSE TRANSACTION createSurfaceLocked"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 697 | } |
| 698 | if (WindowManagerService.localLOGV) Slog.v( |
| 699 | WindowManagerService.TAG, "Created surface " + this); |
| 700 | } |
| 701 | return mSurface; |
| 702 | } |
| 703 | |
| 704 | void destroySurfaceLocked() { |
| 705 | if (mAppToken != null && this == mAppToken.startingWindow) { |
| 706 | mAppToken.startingDisplayed = false; |
| 707 | } |
| 708 | |
| 709 | if (mSurface != null) { |
| 710 | mDrawPending = false; |
| 711 | mCommitDrawPending = false; |
| 712 | mReadyToShow = false; |
| 713 | |
| 714 | int i = mChildWindows.size(); |
| 715 | while (i > 0) { |
| 716 | i--; |
| 717 | WindowState c = mChildWindows.get(i); |
| 718 | c.mAttachedHidden = true; |
| 719 | } |
| 720 | |
| 721 | if (mReportDestroySurface) { |
| 722 | mReportDestroySurface = false; |
| 723 | mSurfacePendingDestroy = true; |
| 724 | try { |
| 725 | mClient.dispatchGetNewSurface(); |
| 726 | // We'll really destroy on the next time around. |
| 727 | return; |
| 728 | } catch (RemoteException e) { |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | try { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 733 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 734 | RuntimeException e = null; |
| 735 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 736 | e = new RuntimeException(); |
| 737 | e.fillInStackTrace(); |
| 738 | } |
| 739 | Slog.w(WindowManagerService.TAG, "Window " + this + " destroying surface " |
| 740 | + mSurface + ", session " + mSession, e); |
| 741 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 742 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 743 | RuntimeException e = null; |
| 744 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 745 | e = new RuntimeException(); |
| 746 | e.fillInStackTrace(); |
| 747 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 748 | WindowManagerService.logSurface(this, "DESTROY", e); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 749 | } |
| 750 | mSurface.destroy(); |
| 751 | } catch (RuntimeException e) { |
| 752 | Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window " + this |
| 753 | + " surface " + mSurface + " session " + mSession |
| 754 | + ": " + e.toString()); |
| 755 | } |
| 756 | |
| 757 | mSurfaceShown = false; |
| 758 | mSurface = null; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | boolean finishDrawingLocked() { |
| 763 | if (mDrawPending) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 764 | if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 765 | WindowManagerService.TAG, "finishDrawingLocked: " + mSurface); |
| 766 | mCommitDrawPending = true; |
| 767 | mDrawPending = false; |
| 768 | return true; |
| 769 | } |
| 770 | return false; |
| 771 | } |
| 772 | |
| 773 | // This must be called while inside a transaction. |
| 774 | boolean commitFinishDrawingLocked(long currentTime) { |
| 775 | //Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface); |
| 776 | if (!mCommitDrawPending) { |
| 777 | return false; |
| 778 | } |
| 779 | mCommitDrawPending = false; |
| 780 | mReadyToShow = true; |
| 781 | final boolean starting = mAttrs.type == TYPE_APPLICATION_STARTING; |
| 782 | final AppWindowToken atoken = mAppToken; |
| 783 | if (atoken == null || atoken.allDrawn || starting) { |
| 784 | performShowLocked(); |
| 785 | } |
| 786 | return true; |
| 787 | } |
| 788 | |
| 789 | // This must be called while inside a transaction. |
| 790 | boolean performShowLocked() { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 791 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 792 | RuntimeException e = null; |
| 793 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 794 | e = new RuntimeException(); |
| 795 | e.fillInStackTrace(); |
| 796 | } |
| 797 | Slog.v(WindowManagerService.TAG, "performShow on " + this |
| 798 | + ": readyToShow=" + mReadyToShow + " readyForDisplay=" + isReadyForDisplay() |
| 799 | + " starting=" + (mAttrs.type == TYPE_APPLICATION_STARTING), e); |
| 800 | } |
| 801 | if (mReadyToShow && isReadyForDisplay()) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 802 | if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) WindowManagerService.logSurface(this, |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 803 | "SHOW (performShowLocked)", null); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 804 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Showing " + this |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 805 | + " during animation: policyVis=" + mPolicyVisibility |
| 806 | + " attHidden=" + mAttachedHidden |
| 807 | + " tok.hiddenRequested=" |
| 808 | + (mAppToken != null ? mAppToken.hiddenRequested : false) |
| 809 | + " tok.hidden=" |
| 810 | + (mAppToken != null ? mAppToken.hidden : false) |
| 811 | + " animating=" + mAnimating |
| 812 | + " tok animating=" |
| 813 | + (mAppToken != null ? mAppToken.animating : false)); |
| 814 | if (!mService.showSurfaceRobustlyLocked(this)) { |
| 815 | return false; |
| 816 | } |
| 817 | mLastAlpha = -1; |
| 818 | mHasDrawn = true; |
| 819 | mLastHidden = false; |
| 820 | mReadyToShow = false; |
| 821 | mService.enableScreenIfNeededLocked(); |
| 822 | |
| 823 | mService.applyEnterAnimationLocked(this); |
| 824 | |
| 825 | int i = mChildWindows.size(); |
| 826 | while (i > 0) { |
| 827 | i--; |
| 828 | WindowState c = mChildWindows.get(i); |
| 829 | if (c.mAttachedHidden) { |
| 830 | c.mAttachedHidden = false; |
| 831 | if (c.mSurface != null) { |
| 832 | c.performShowLocked(); |
| 833 | // It hadn't been shown, which means layout not |
| 834 | // performed on it, so now we want to make sure to |
| 835 | // do a layout. If called from within the transaction |
| 836 | // loop, this will cause it to restart with a new |
| 837 | // layout. |
| 838 | mService.mLayoutNeeded = true; |
| 839 | } |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | if (mAttrs.type != TYPE_APPLICATION_STARTING |
| 844 | && mAppToken != null) { |
| 845 | mAppToken.firstWindowDrawn = true; |
| 846 | |
| 847 | if (mAppToken.startingData != null) { |
| 848 | if (WindowManagerService.DEBUG_STARTING_WINDOW || WindowManagerService.DEBUG_ANIM) Slog.v(WindowManagerService.TAG, |
| 849 | "Finish starting " + mToken |
| 850 | + ": first real window is shown, no animation"); |
| 851 | // If this initial window is animating, stop it -- we |
| 852 | // will do an animation to reveal it from behind the |
| 853 | // starting window, so there is no need for it to also |
| 854 | // be doing its own stuff. |
| 855 | if (mAnimation != null) { |
| 856 | mAnimation.cancel(); |
| 857 | mAnimation = null; |
| 858 | // Make sure we clean up the animation. |
| 859 | mAnimating = true; |
| 860 | } |
| 861 | mService.mFinishedStarting.add(mAppToken); |
| 862 | mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 863 | } |
| 864 | mAppToken.updateReportedVisibilityLocked(); |
| 865 | } |
| 866 | } |
| 867 | return true; |
| 868 | } |
| 869 | |
| 870 | // This must be called while inside a transaction. Returns true if |
| 871 | // there is more animation to run. |
| 872 | boolean stepAnimationLocked(long currentTime, int dw, int dh) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 873 | if (!mService.mDisplayFrozen && mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 874 | // We will run animations as long as the display isn't frozen. |
| 875 | |
| 876 | if (!mDrawPending && !mCommitDrawPending && mAnimation != null) { |
| 877 | mHasTransformation = true; |
| 878 | mHasLocalTransformation = true; |
| 879 | if (!mLocalAnimating) { |
| 880 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 881 | WindowManagerService.TAG, "Starting animation in " + this + |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 882 | " @ " + currentTime + ": ww=" + mFrame.width() + |
| 883 | " wh=" + mFrame.height() + |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 884 | " dw=" + dw + " dh=" + dh + " scale=" + mService.mWindowAnimationScale); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 885 | mAnimation.initialize(mFrame.width(), mFrame.height(), dw, dh); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 886 | mAnimation.setStartTime(currentTime); |
| 887 | mLocalAnimating = true; |
| 888 | mAnimating = true; |
| 889 | } |
| 890 | mTransformation.clear(); |
| 891 | final boolean more = mAnimation.getTransformation( |
| 892 | currentTime, mTransformation); |
| 893 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 894 | WindowManagerService.TAG, "Stepped animation in " + this + |
| 895 | ": more=" + more + ", xform=" + mTransformation); |
| 896 | if (more) { |
| 897 | // we're not done! |
| 898 | return true; |
| 899 | } |
| 900 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 901 | WindowManagerService.TAG, "Finished animation in " + this + |
| 902 | " @ " + currentTime); |
| 903 | |
| 904 | if (mAnimation != null) { |
| 905 | mAnimation.cancel(); |
| 906 | mAnimation = null; |
| 907 | } |
| 908 | //WindowManagerService.this.dump(); |
| 909 | } |
| 910 | mHasLocalTransformation = false; |
| 911 | if ((!mLocalAnimating || mAnimationIsEntrance) && mAppToken != null |
| 912 | && mAppToken.animation != null) { |
| 913 | // When our app token is animating, we kind-of pretend like |
| 914 | // we are as well. Note the mLocalAnimating mAnimationIsEntrance |
| 915 | // part of this check means that we will only do this if |
| 916 | // our window is not currently exiting, or it is not |
| 917 | // locally animating itself. The idea being that one that |
| 918 | // is exiting and doing a local animation should be removed |
| 919 | // once that animation is done. |
| 920 | mAnimating = true; |
| 921 | mHasTransformation = true; |
| 922 | mTransformation.clear(); |
| 923 | return false; |
| 924 | } else if (mHasTransformation) { |
| 925 | // Little trick to get through the path below to act like |
| 926 | // we have finished an animation. |
| 927 | mAnimating = true; |
| 928 | } else if (isAnimating()) { |
| 929 | mAnimating = true; |
| 930 | } |
| 931 | } else if (mAnimation != null) { |
| 932 | // If the display is frozen, and there is a pending animation, |
| 933 | // clear it and make sure we run the cleanup code. |
| 934 | mAnimating = true; |
| 935 | mLocalAnimating = true; |
| 936 | mAnimation.cancel(); |
| 937 | mAnimation = null; |
| 938 | } |
| 939 | |
| 940 | if (!mAnimating && !mLocalAnimating) { |
| 941 | return false; |
| 942 | } |
| 943 | |
| 944 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 945 | WindowManagerService.TAG, "Animation done in " + this + ": exiting=" + mExiting |
| 946 | + ", reportedVisible=" |
| 947 | + (mAppToken != null ? mAppToken.reportedVisible : false)); |
| 948 | |
| 949 | mAnimating = false; |
| 950 | mLocalAnimating = false; |
| 951 | if (mAnimation != null) { |
| 952 | mAnimation.cancel(); |
| 953 | mAnimation = null; |
| 954 | } |
| 955 | mAnimLayer = mLayer; |
| 956 | if (mIsImWindow) { |
| 957 | mAnimLayer += mService.mInputMethodAnimLayerAdjustment; |
| 958 | } else if (mIsWallpaper) { |
| 959 | mAnimLayer += mService.mWallpaperAnimLayerAdjustment; |
| 960 | } |
| 961 | if (WindowManagerService.DEBUG_LAYERS) Slog.v(WindowManagerService.TAG, "Stepping win " + this |
| 962 | + " anim layer: " + mAnimLayer); |
| 963 | mHasTransformation = false; |
| 964 | mHasLocalTransformation = false; |
| 965 | if (mPolicyVisibility != mPolicyVisibilityAfterAnim) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 966 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 967 | Slog.v(WindowManagerService.TAG, "Policy visibility changing after anim in " + this + ": " |
| 968 | + mPolicyVisibilityAfterAnim); |
| 969 | } |
| 970 | mPolicyVisibility = mPolicyVisibilityAfterAnim; |
Dianne Hackborn | f809870 | 2011-09-13 13:26:38 -0700 | [diff] [blame] | 971 | mService.mLayoutNeeded = true; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 972 | if (!mPolicyVisibility) { |
| 973 | if (mService.mCurrentFocus == this) { |
| 974 | mService.mFocusMayChange = true; |
| 975 | } |
| 976 | // Window is no longer visible -- make sure if we were waiting |
| 977 | // for it to be displayed before enabling the display, that |
| 978 | // we allow the display to be enabled now. |
| 979 | mService.enableScreenIfNeededLocked(); |
| 980 | } |
| 981 | } |
| 982 | mTransformation.clear(); |
| 983 | if (mHasDrawn |
| 984 | && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING |
| 985 | && mAppToken != null |
| 986 | && mAppToken.firstWindowDrawn |
| 987 | && mAppToken.startingData != null) { |
| 988 | if (WindowManagerService.DEBUG_STARTING_WINDOW) Slog.v(WindowManagerService.TAG, "Finish starting " |
| 989 | + mToken + ": first real window done animating"); |
| 990 | mService.mFinishedStarting.add(mAppToken); |
| 991 | mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 992 | } |
| 993 | |
| 994 | finishExit(); |
| 995 | |
| 996 | if (mAppToken != null) { |
| 997 | mAppToken.updateReportedVisibilityLocked(); |
| 998 | } |
| 999 | |
| 1000 | return false; |
| 1001 | } |
| 1002 | |
| 1003 | void finishExit() { |
| 1004 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 1005 | WindowManagerService.TAG, "finishExit in " + this |
| 1006 | + ": exiting=" + mExiting |
| 1007 | + " remove=" + mRemoveOnExit |
| 1008 | + " windowAnimating=" + isWindowAnimating()); |
| 1009 | |
| 1010 | final int N = mChildWindows.size(); |
| 1011 | for (int i=0; i<N; i++) { |
| 1012 | mChildWindows.get(i).finishExit(); |
| 1013 | } |
| 1014 | |
| 1015 | if (!mExiting) { |
| 1016 | return; |
| 1017 | } |
| 1018 | |
| 1019 | if (isWindowAnimating()) { |
| 1020 | return; |
| 1021 | } |
| 1022 | |
| 1023 | if (WindowManagerService.localLOGV) Slog.v( |
| 1024 | WindowManagerService.TAG, "Exit animation finished in " + this |
| 1025 | + ": remove=" + mRemoveOnExit); |
| 1026 | if (mSurface != null) { |
| 1027 | mService.mDestroySurface.add(this); |
| 1028 | mDestroying = true; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1029 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "HIDE (finishExit)", null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1030 | mSurfaceShown = false; |
| 1031 | try { |
| 1032 | mSurface.hide(); |
| 1033 | } catch (RuntimeException e) { |
| 1034 | Slog.w(WindowManagerService.TAG, "Error hiding surface in " + this, e); |
| 1035 | } |
| 1036 | mLastHidden = true; |
| 1037 | } |
| 1038 | mExiting = false; |
| 1039 | if (mRemoveOnExit) { |
| 1040 | mService.mPendingRemove.add(this); |
| 1041 | mRemoveOnExit = false; |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { |
| 1046 | if (dsdx < .99999f || dsdx > 1.00001f) return false; |
| 1047 | if (dtdy < .99999f || dtdy > 1.00001f) return false; |
| 1048 | if (dtdx < -.000001f || dtdx > .000001f) return false; |
| 1049 | if (dsdy < -.000001f || dsdy > .000001f) return false; |
| 1050 | return true; |
| 1051 | } |
| 1052 | |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1053 | void prelayout() { |
| 1054 | if (mEnforceSizeCompat) { |
| 1055 | mGlobalScale = mService.mCompatibleScreenScale; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1056 | mInvGlobalScale = 1/mGlobalScale; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1057 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1058 | mGlobalScale = mInvGlobalScale = 1; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1059 | } |
| 1060 | } |
| 1061 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1062 | void computeShownFrameLocked() { |
| 1063 | final boolean selfTransformation = mHasLocalTransformation; |
| 1064 | Transformation attachedTransformation = |
| 1065 | (mAttachedWindow != null && mAttachedWindow.mHasLocalTransformation) |
| 1066 | ? mAttachedWindow.mTransformation : null; |
| 1067 | Transformation appTransformation = |
| 1068 | (mAppToken != null && mAppToken.hasTransformation) |
| 1069 | ? mAppToken.transformation : null; |
| 1070 | |
| 1071 | // Wallpapers are animated based on the "real" window they |
| 1072 | // are currently targeting. |
| 1073 | if (mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null |
| 1074 | && mService.mWallpaperTarget != null) { |
| 1075 | if (mService.mWallpaperTarget.mHasLocalTransformation && |
| 1076 | mService.mWallpaperTarget.mAnimation != null && |
| 1077 | !mService.mWallpaperTarget.mAnimation.getDetachWallpaper()) { |
| 1078 | attachedTransformation = mService.mWallpaperTarget.mTransformation; |
| 1079 | if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) { |
| 1080 | Slog.v(WindowManagerService.TAG, "WP target attached xform: " + attachedTransformation); |
| 1081 | } |
| 1082 | } |
| 1083 | if (mService.mWallpaperTarget.mAppToken != null && |
| 1084 | mService.mWallpaperTarget.mAppToken.hasTransformation && |
| 1085 | mService.mWallpaperTarget.mAppToken.animation != null && |
| 1086 | !mService.mWallpaperTarget.mAppToken.animation.getDetachWallpaper()) { |
| 1087 | appTransformation = mService.mWallpaperTarget.mAppToken.transformation; |
| 1088 | if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) { |
| 1089 | Slog.v(WindowManagerService.TAG, "WP target app xform: " + appTransformation); |
| 1090 | } |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | final boolean screenAnimation = mService.mScreenRotationAnimation != null |
| 1095 | && mService.mScreenRotationAnimation.isAnimating(); |
| 1096 | if (selfTransformation || attachedTransformation != null |
| 1097 | || appTransformation != null || screenAnimation) { |
| 1098 | // cache often used attributes locally |
| 1099 | final Rect frame = mFrame; |
| 1100 | final float tmpFloats[] = mService.mTmpFloats; |
| 1101 | final Matrix tmpMatrix = mTmpMatrix; |
| 1102 | |
| 1103 | // Compute the desired transformation. |
Dianne Hackborn | 73db0d8 | 2011-09-16 01:09:40 -0700 | [diff] [blame] | 1104 | if (screenAnimation) { |
| 1105 | // If we are doing a screen animation, the global rotation |
| 1106 | // applied to windows can result in windows that are carefully |
| 1107 | // aligned with each other to slightly separate, allowing you |
| 1108 | // to see what is behind them. An unsightly mess. This... |
| 1109 | // thing... magically makes it call good: scale each window |
| 1110 | // slightly (two pixels larger in each dimension, from the |
| 1111 | // window's center). |
| 1112 | final float w = frame.width(); |
| 1113 | final float h = frame.height(); |
| 1114 | tmpMatrix.setScale(1 + 2/w, 1 + 2/h, w/2, h/2); |
| 1115 | } else { |
| 1116 | tmpMatrix.reset(); |
| 1117 | } |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1118 | tmpMatrix.postScale(mGlobalScale, mGlobalScale); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1119 | if (selfTransformation) { |
| 1120 | tmpMatrix.postConcat(mTransformation.getMatrix()); |
| 1121 | } |
| 1122 | tmpMatrix.postTranslate(frame.left + mXOffset, frame.top + mYOffset); |
| 1123 | if (attachedTransformation != null) { |
| 1124 | tmpMatrix.postConcat(attachedTransformation.getMatrix()); |
| 1125 | } |
| 1126 | if (appTransformation != null) { |
| 1127 | tmpMatrix.postConcat(appTransformation.getMatrix()); |
| 1128 | } |
| 1129 | if (screenAnimation) { |
| 1130 | tmpMatrix.postConcat( |
| 1131 | mService.mScreenRotationAnimation.getEnterTransformation().getMatrix()); |
| 1132 | } |
| 1133 | |
| 1134 | // "convert" it into SurfaceFlinger's format |
| 1135 | // (a 2x2 matrix + an offset) |
| 1136 | // Here we must not transform the position of the surface |
| 1137 | // since it is already included in the transformation. |
| 1138 | //Slog.i(TAG, "Transform: " + matrix); |
| 1139 | |
| 1140 | mHaveMatrix = true; |
| 1141 | tmpMatrix.getValues(tmpFloats); |
| 1142 | mDsDx = tmpFloats[Matrix.MSCALE_X]; |
| 1143 | mDtDx = tmpFloats[Matrix.MSKEW_Y]; |
| 1144 | mDsDy = tmpFloats[Matrix.MSKEW_X]; |
| 1145 | mDtDy = tmpFloats[Matrix.MSCALE_Y]; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 1146 | float x = tmpFloats[Matrix.MTRANS_X]; |
| 1147 | float y = tmpFloats[Matrix.MTRANS_Y]; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1148 | int w = frame.width(); |
| 1149 | int h = frame.height(); |
| 1150 | mShownFrame.set(x, y, x+w, y+h); |
| 1151 | |
| 1152 | // Now set the alpha... but because our current hardware |
| 1153 | // can't do alpha transformation on a non-opaque surface, |
| 1154 | // turn it off if we are running an animation that is also |
| 1155 | // transforming since it is more important to have that |
| 1156 | // animation be smooth. |
| 1157 | mShownAlpha = mAlpha; |
| 1158 | if (!mService.mLimitedAlphaCompositing |
| 1159 | || (!PixelFormat.formatHasAlpha(mAttrs.format) |
| 1160 | || (isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy) |
| 1161 | && x == frame.left && y == frame.top))) { |
| 1162 | //Slog.i(TAG, "Applying alpha transform"); |
| 1163 | if (selfTransformation) { |
| 1164 | mShownAlpha *= mTransformation.getAlpha(); |
| 1165 | } |
| 1166 | if (attachedTransformation != null) { |
| 1167 | mShownAlpha *= attachedTransformation.getAlpha(); |
| 1168 | } |
| 1169 | if (appTransformation != null) { |
| 1170 | mShownAlpha *= appTransformation.getAlpha(); |
| 1171 | } |
| 1172 | if (screenAnimation) { |
| 1173 | mShownAlpha *= |
| 1174 | mService.mScreenRotationAnimation.getEnterTransformation().getAlpha(); |
| 1175 | } |
| 1176 | } else { |
| 1177 | //Slog.i(TAG, "Not applying alpha transform"); |
| 1178 | } |
| 1179 | |
| 1180 | if (WindowManagerService.localLOGV) Slog.v( |
| 1181 | WindowManagerService.TAG, "Continuing animation in " + this + |
| 1182 | ": " + mShownFrame + |
| 1183 | ", alpha=" + mTransformation.getAlpha()); |
| 1184 | return; |
| 1185 | } |
| 1186 | |
| 1187 | mShownFrame.set(mFrame); |
| 1188 | if (mXOffset != 0 || mYOffset != 0) { |
| 1189 | mShownFrame.offset(mXOffset, mYOffset); |
| 1190 | } |
| 1191 | mShownAlpha = mAlpha; |
| 1192 | mHaveMatrix = false; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1193 | mDsDx = mGlobalScale; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1194 | mDtDx = 0; |
| 1195 | mDsDy = 0; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1196 | mDtDy = mGlobalScale; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | /** |
| 1200 | * Is this window visible? It is not visible if there is no |
| 1201 | * surface, or we are in the process of running an exit animation |
| 1202 | * that will remove the surface, or its app token has been hidden. |
| 1203 | */ |
| 1204 | public boolean isVisibleLw() { |
| 1205 | final AppWindowToken atoken = mAppToken; |
| 1206 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1207 | && (atoken == null || !atoken.hiddenRequested) |
| 1208 | && !mExiting && !mDestroying; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 1213 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 1214 | * things like window flags that impact the keyguard. |
| 1215 | * XXX I am starting to think we need to have ANOTHER visibility flag |
| 1216 | * for this "hidden behind keyguard" state rather than overloading |
| 1217 | * mPolicyVisibility. Ungh. |
| 1218 | */ |
| 1219 | public boolean isVisibleOrBehindKeyguardLw() { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1220 | if (mRootToken.waitingToShow && |
| 1221 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 1222 | return false; |
| 1223 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1224 | final AppWindowToken atoken = mAppToken; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1225 | final boolean animating = atoken != null |
| 1226 | ? (atoken.animation != null) : false; |
| 1227 | return mSurface != null && !mDestroying && !mExiting |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1228 | && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1229 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1230 | && !mRootToken.hidden) |
| 1231 | || mAnimation != null || animating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /** |
| 1235 | * Is this window visible, ignoring its app token? It is not visible |
| 1236 | * if there is no surface, or we are in the process of running an exit animation |
| 1237 | * that will remove the surface. |
| 1238 | */ |
| 1239 | public boolean isWinVisibleLw() { |
| 1240 | final AppWindowToken atoken = mAppToken; |
| 1241 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1242 | && (atoken == null || !atoken.hiddenRequested || atoken.animating) |
| 1243 | && !mExiting && !mDestroying; |
| 1244 | } |
| 1245 | |
| 1246 | /** |
| 1247 | * The same as isVisible(), but follows the current hidden state of |
| 1248 | * the associated app token, not the pending requested hidden state. |
| 1249 | */ |
| 1250 | boolean isVisibleNow() { |
| 1251 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1252 | && !mRootToken.hidden && !mExiting && !mDestroying; |
| 1253 | } |
| 1254 | |
| 1255 | /** |
| 1256 | * Can this window possibly be a drag/drop target? The test here is |
| 1257 | * a combination of the above "visible now" with the check that the |
| 1258 | * Input Manager uses when discarding windows from input consideration. |
| 1259 | */ |
| 1260 | boolean isPotentialDragTarget() { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1261 | return isVisibleNow() && !mRemoved |
| 1262 | && mInputChannel != null && mInputWindowHandle != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | /** |
| 1266 | * Same as isVisible(), but we also count it as visible between the |
| 1267 | * call to IWindowSession.add() and the first relayout(). |
| 1268 | */ |
| 1269 | boolean isVisibleOrAdding() { |
| 1270 | final AppWindowToken atoken = mAppToken; |
| 1271 | return ((mSurface != null && !mReportDestroySurface) |
| 1272 | || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) |
| 1273 | && mPolicyVisibility && !mAttachedHidden |
| 1274 | && (atoken == null || !atoken.hiddenRequested) |
| 1275 | && !mExiting && !mDestroying; |
| 1276 | } |
| 1277 | |
| 1278 | /** |
| 1279 | * Is this window currently on-screen? It is on-screen either if it |
| 1280 | * is visible or it is currently running an animation before no longer |
| 1281 | * being visible. |
| 1282 | */ |
| 1283 | boolean isOnScreen() { |
| 1284 | final AppWindowToken atoken = mAppToken; |
| 1285 | if (atoken != null) { |
| 1286 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1287 | && ((!mAttachedHidden && !atoken.hiddenRequested) |
| 1288 | || mAnimation != null || atoken.animation != null); |
| 1289 | } else { |
| 1290 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1291 | && (!mAttachedHidden || mAnimation != null); |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | /** |
| 1296 | * Like isOnScreen(), but we don't return true if the window is part |
| 1297 | * of a transition that has not yet been started. |
| 1298 | */ |
| 1299 | boolean isReadyForDisplay() { |
| 1300 | if (mRootToken.waitingToShow && |
| 1301 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 1302 | return false; |
| 1303 | } |
| 1304 | final AppWindowToken atoken = mAppToken; |
| 1305 | final boolean animating = atoken != null |
| 1306 | ? (atoken.animation != null) : false; |
| 1307 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1308 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1309 | && !mRootToken.hidden) |
| 1310 | || mAnimation != null || animating); |
| 1311 | } |
| 1312 | |
| 1313 | /** Is the window or its container currently animating? */ |
| 1314 | boolean isAnimating() { |
| 1315 | final WindowState attached = mAttachedWindow; |
| 1316 | final AppWindowToken atoken = mAppToken; |
| 1317 | return mAnimation != null |
| 1318 | || (attached != null && attached.mAnimation != null) |
| 1319 | || (atoken != null && |
| 1320 | (atoken.animation != null |
| 1321 | || atoken.inPendingTransaction)); |
| 1322 | } |
| 1323 | |
| 1324 | /** Is this window currently animating? */ |
| 1325 | boolean isWindowAnimating() { |
| 1326 | return mAnimation != null; |
| 1327 | } |
| 1328 | |
| 1329 | /** |
| 1330 | * Like isOnScreen, but returns false if the surface hasn't yet |
| 1331 | * been drawn. |
| 1332 | */ |
| 1333 | public boolean isDisplayedLw() { |
| 1334 | final AppWindowToken atoken = mAppToken; |
| 1335 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1336 | && !mDrawPending && !mCommitDrawPending |
| 1337 | && ((!mAttachedHidden && |
| 1338 | (atoken == null || !atoken.hiddenRequested)) |
| 1339 | || mAnimating); |
| 1340 | } |
| 1341 | |
| 1342 | /** |
| 1343 | * Returns true if the window has a surface that it has drawn a |
| 1344 | * complete UI in to. |
| 1345 | */ |
| 1346 | public boolean isDrawnLw() { |
| 1347 | final AppWindowToken atoken = mAppToken; |
| 1348 | return mSurface != null && !mDestroying |
| 1349 | && !mDrawPending && !mCommitDrawPending; |
| 1350 | } |
| 1351 | |
| 1352 | /** |
| 1353 | * Return true if the window is opaque and fully drawn. This indicates |
| 1354 | * it may obscure windows behind it. |
| 1355 | */ |
| 1356 | boolean isOpaqueDrawn() { |
| 1357 | return (mAttrs.format == PixelFormat.OPAQUE |
| 1358 | || mAttrs.type == TYPE_WALLPAPER) |
| 1359 | && mSurface != null && mAnimation == null |
| 1360 | && (mAppToken == null || mAppToken.animation == null) |
| 1361 | && !mDrawPending && !mCommitDrawPending; |
| 1362 | } |
| 1363 | |
| 1364 | /** |
| 1365 | * Return whether this window is wanting to have a translation |
| 1366 | * animation applied to it for an in-progress move. (Only makes |
| 1367 | * sense to call from performLayoutAndPlaceSurfacesLockedInner().) |
| 1368 | */ |
| 1369 | boolean shouldAnimateMove() { |
| 1370 | return mContentChanged && !mExiting && !mLastHidden && !mService.mDisplayFrozen |
| 1371 | && (mFrame.top != mLastFrame.top |
| 1372 | || mFrame.left != mLastFrame.left) |
| 1373 | && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove()) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1374 | && mService.mPolicy.isScreenOnFully(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1375 | } |
| 1376 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1377 | boolean isFullscreen(int screenWidth, int screenHeight) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1378 | return mFrame.left <= 0 && mFrame.top <= 0 && |
| 1379 | mFrame.right >= screenWidth && mFrame.bottom >= screenHeight; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | void removeLocked() { |
| 1383 | disposeInputChannel(); |
| 1384 | |
| 1385 | if (mAttachedWindow != null) { |
| 1386 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(WindowManagerService.TAG, "Removing " + this + " from " + mAttachedWindow); |
| 1387 | mAttachedWindow.mChildWindows.remove(this); |
| 1388 | } |
| 1389 | destroySurfaceLocked(); |
| 1390 | mSession.windowRemovedLocked(); |
| 1391 | try { |
| 1392 | mClient.asBinder().unlinkToDeath(mDeathRecipient, 0); |
| 1393 | } catch (RuntimeException e) { |
| 1394 | // Ignore if it has already been removed (usually because |
| 1395 | // we are doing this as part of processing a death note.) |
| 1396 | } |
| 1397 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1398 | |
| 1399 | void setInputChannel(InputChannel inputChannel) { |
| 1400 | if (mInputChannel != null) { |
| 1401 | throw new IllegalStateException("Window already has an input channel."); |
| 1402 | } |
| 1403 | |
| 1404 | mInputChannel = inputChannel; |
| 1405 | mInputWindowHandle.inputChannel = inputChannel; |
| 1406 | } |
| 1407 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1408 | void disposeInputChannel() { |
| 1409 | if (mInputChannel != null) { |
| 1410 | mService.mInputManager.unregisterInputChannel(mInputChannel); |
| 1411 | |
| 1412 | mInputChannel.dispose(); |
| 1413 | mInputChannel = null; |
| 1414 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1415 | |
| 1416 | mInputWindowHandle.inputChannel = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | private class DeathRecipient implements IBinder.DeathRecipient { |
| 1420 | public void binderDied() { |
| 1421 | try { |
| 1422 | synchronized(mService.mWindowMap) { |
| 1423 | WindowState win = mService.windowForClientLocked(mSession, mClient, false); |
| 1424 | Slog.i(WindowManagerService.TAG, "WIN DEATH: " + win); |
| 1425 | if (win != null) { |
| 1426 | mService.removeWindowLocked(mSession, win); |
| 1427 | } |
| 1428 | } |
| 1429 | } catch (IllegalArgumentException ex) { |
| 1430 | // This will happen if the window has already been |
| 1431 | // removed. |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | /** Returns true if this window desires key events. */ |
| 1437 | public final boolean canReceiveKeys() { |
| 1438 | return isVisibleOrAdding() |
| 1439 | && (mViewVisibility == View.VISIBLE) |
| 1440 | && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0); |
| 1441 | } |
| 1442 | |
| 1443 | public boolean hasDrawnLw() { |
| 1444 | return mHasDrawn; |
| 1445 | } |
| 1446 | |
| 1447 | public boolean showLw(boolean doAnimation) { |
| 1448 | return showLw(doAnimation, true); |
| 1449 | } |
| 1450 | |
| 1451 | boolean showLw(boolean doAnimation, boolean requestAnim) { |
| 1452 | if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { |
| 1453 | return false; |
| 1454 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1455 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility true: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1456 | if (doAnimation) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1457 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "doAnimation: mPolicyVisibility=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1458 | + mPolicyVisibility + " mAnimation=" + mAnimation); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1459 | if (mService.mDisplayFrozen || !mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1460 | doAnimation = false; |
| 1461 | } else if (mPolicyVisibility && mAnimation == null) { |
| 1462 | // Check for the case where we are currently visible and |
| 1463 | // not animating; we do not want to do animation at such a |
| 1464 | // point to become visible when we already are. |
| 1465 | doAnimation = false; |
| 1466 | } |
| 1467 | } |
| 1468 | mPolicyVisibility = true; |
| 1469 | mPolicyVisibilityAfterAnim = true; |
| 1470 | if (doAnimation) { |
| 1471 | mService.applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_ENTER, true); |
| 1472 | } |
| 1473 | if (requestAnim) { |
| 1474 | mService.requestAnimationLocked(0); |
| 1475 | } |
| 1476 | return true; |
| 1477 | } |
| 1478 | |
| 1479 | public boolean hideLw(boolean doAnimation) { |
| 1480 | return hideLw(doAnimation, true); |
| 1481 | } |
| 1482 | |
| 1483 | boolean hideLw(boolean doAnimation, boolean requestAnim) { |
| 1484 | if (doAnimation) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame^] | 1485 | if (mService.mDisplayFrozen || !mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1486 | doAnimation = false; |
| 1487 | } |
| 1488 | } |
| 1489 | boolean current = doAnimation ? mPolicyVisibilityAfterAnim |
| 1490 | : mPolicyVisibility; |
| 1491 | if (!current) { |
| 1492 | return false; |
| 1493 | } |
| 1494 | if (doAnimation) { |
| 1495 | mService.applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_EXIT, false); |
| 1496 | if (mAnimation == null) { |
| 1497 | doAnimation = false; |
| 1498 | } |
| 1499 | } |
| 1500 | if (doAnimation) { |
| 1501 | mPolicyVisibilityAfterAnim = false; |
| 1502 | } else { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1503 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility false: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1504 | mPolicyVisibilityAfterAnim = false; |
| 1505 | mPolicyVisibility = false; |
| 1506 | // Window is no longer visible -- make sure if we were waiting |
| 1507 | // for it to be displayed before enabling the display, that |
| 1508 | // we allow the display to be enabled now. |
| 1509 | mService.enableScreenIfNeededLocked(); |
| 1510 | if (mService.mCurrentFocus == this) { |
| 1511 | mService.mFocusMayChange = true; |
| 1512 | } |
| 1513 | } |
| 1514 | if (requestAnim) { |
| 1515 | mService.requestAnimationLocked(0); |
| 1516 | } |
| 1517 | return true; |
| 1518 | } |
| 1519 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1520 | private static void applyInsets(Region outRegion, Rect frame, Rect inset) { |
| 1521 | outRegion.set( |
| 1522 | frame.left + inset.left, frame.top + inset.top, |
| 1523 | frame.right - inset.right, frame.bottom - inset.bottom); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1524 | } |
| 1525 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1526 | public void getTouchableRegion(Region outRegion) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1527 | final Rect frame = mFrame; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1528 | switch (mTouchableInsets) { |
| 1529 | default: |
| 1530 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME: |
| 1531 | outRegion.set(frame); |
| 1532 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1533 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1534 | applyInsets(outRegion, frame, mGivenContentInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1535 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1536 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1537 | applyInsets(outRegion, frame, mGivenVisibleInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1538 | break; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1539 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: { |
| 1540 | final Region givenTouchableRegion = mGivenTouchableRegion; |
| 1541 | outRegion.set(givenTouchableRegion); |
| 1542 | outRegion.translate(frame.left, frame.top); |
| 1543 | break; |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1548 | void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1549 | pw.print(prefix); pw.print("mSession="); pw.print(mSession); |
| 1550 | pw.print(" mClient="); pw.println(mClient.asBinder()); |
| 1551 | pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1552 | pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); |
| 1553 | pw.print(" h="); pw.print(mRequestedHeight); |
| 1554 | pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1555 | if (mAttachedWindow != null || mLayoutAttached) { |
| 1556 | pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); |
| 1557 | pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); |
| 1558 | } |
| 1559 | if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) { |
| 1560 | pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow); |
| 1561 | pw.print(" mIsWallpaper="); pw.print(mIsWallpaper); |
| 1562 | pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer); |
| 1563 | pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible); |
| 1564 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1565 | if (dumpAll) { |
| 1566 | pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); |
| 1567 | pw.print(" mSubLayer="); pw.print(mSubLayer); |
| 1568 | pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); |
| 1569 | pw.print((mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment |
| 1570 | : (mAppToken != null ? mAppToken.animLayerAdjustment : 0))); |
| 1571 | pw.print("="); pw.print(mAnimLayer); |
| 1572 | pw.print(" mLastLayer="); pw.println(mLastLayer); |
| 1573 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1574 | if (mSurface != null) { |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1575 | if (dumpAll) { |
| 1576 | pw.print(prefix); pw.print("mSurface="); pw.println(mSurface); |
| 1577 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1578 | pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); |
| 1579 | pw.print(" layer="); pw.print(mSurfaceLayer); |
| 1580 | pw.print(" alpha="); pw.print(mSurfaceAlpha); |
| 1581 | pw.print(" rect=("); pw.print(mSurfaceX); |
| 1582 | pw.print(","); pw.print(mSurfaceY); |
| 1583 | pw.print(") "); pw.print(mSurfaceW); |
| 1584 | pw.print(" x "); pw.println(mSurfaceH); |
| 1585 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1586 | if (dumpAll) { |
| 1587 | pw.print(prefix); pw.print("mToken="); pw.println(mToken); |
| 1588 | pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); |
| 1589 | if (mAppToken != null) { |
| 1590 | pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); |
| 1591 | } |
| 1592 | if (mTargetAppToken != null) { |
| 1593 | pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); |
| 1594 | } |
| 1595 | pw.print(prefix); pw.print("mViewVisibility=0x"); |
| 1596 | pw.print(Integer.toHexString(mViewVisibility)); |
| 1597 | pw.print(" mLastHidden="); pw.print(mLastHidden); |
| 1598 | pw.print(" mHaveFrame="); pw.print(mHaveFrame); |
| 1599 | pw.print(" mObscured="); pw.println(mObscured); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1600 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1601 | if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { |
| 1602 | pw.print(prefix); pw.print("mPolicyVisibility="); |
| 1603 | pw.print(mPolicyVisibility); |
| 1604 | pw.print(" mPolicyVisibilityAfterAnim="); |
| 1605 | pw.print(mPolicyVisibilityAfterAnim); |
| 1606 | pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); |
| 1607 | } |
| 1608 | if (!mRelayoutCalled) { |
| 1609 | pw.print(prefix); pw.print("mRelayoutCalled="); pw.println(mRelayoutCalled); |
| 1610 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1611 | if (mXOffset != 0 || mYOffset != 0) { |
| 1612 | pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); |
| 1613 | pw.print(" y="); pw.println(mYOffset); |
| 1614 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1615 | if (dumpAll) { |
| 1616 | pw.print(prefix); pw.print("mGivenContentInsets="); |
| 1617 | mGivenContentInsets.printShortString(pw); |
| 1618 | pw.print(" mGivenVisibleInsets="); |
| 1619 | mGivenVisibleInsets.printShortString(pw); |
| 1620 | pw.println(); |
| 1621 | if (mTouchableInsets != 0 || mGivenInsetsPending) { |
| 1622 | pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); |
| 1623 | pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); |
| 1624 | } |
| 1625 | pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1626 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1627 | pw.print(prefix); pw.print("mShownFrame="); |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 1628 | mShownFrame.printShortString(pw); pw.println(); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1629 | if (dumpAll) { |
| 1630 | pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); |
| 1631 | pw.print(" last="); mLastFrame.printShortString(pw); |
| 1632 | pw.println(); |
| 1633 | } |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1634 | if (mEnforceSizeCompat) { |
| 1635 | pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1636 | pw.println(); |
| 1637 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1638 | if (dumpAll) { |
| 1639 | pw.print(prefix); pw.print("mContainingFrame="); |
| 1640 | mContainingFrame.printShortString(pw); |
| 1641 | pw.print(" mParentFrame="); |
| 1642 | mParentFrame.printShortString(pw); |
| 1643 | pw.print(" mDisplayFrame="); |
| 1644 | mDisplayFrame.printShortString(pw); |
| 1645 | pw.println(); |
| 1646 | pw.print(prefix); pw.print("mContentFrame="); mContentFrame.printShortString(pw); |
| 1647 | pw.print(" mVisibleFrame="); mVisibleFrame.printShortString(pw); |
| 1648 | pw.println(); |
| 1649 | pw.print(prefix); pw.print("mContentInsets="); mContentInsets.printShortString(pw); |
| 1650 | pw.print(" last="); mLastContentInsets.printShortString(pw); |
| 1651 | pw.print(" mVisibleInsets="); mVisibleInsets.printShortString(pw); |
| 1652 | pw.print(" last="); mLastVisibleInsets.printShortString(pw); |
| 1653 | pw.println(); |
| 1654 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1655 | if (mAnimating || mLocalAnimating || mAnimationIsEntrance |
| 1656 | || mAnimation != null) { |
| 1657 | pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); |
| 1658 | pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); |
| 1659 | pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); |
| 1660 | pw.print(" mAnimation="); pw.println(mAnimation); |
| 1661 | } |
| 1662 | if (mHasTransformation || mHasLocalTransformation) { |
| 1663 | pw.print(prefix); pw.print("XForm: has="); |
| 1664 | pw.print(mHasTransformation); |
| 1665 | pw.print(" hasLocal="); pw.print(mHasLocalTransformation); |
| 1666 | pw.print(" "); mTransformation.printShortString(pw); |
| 1667 | pw.println(); |
| 1668 | } |
| 1669 | if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { |
| 1670 | pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); |
| 1671 | pw.print(" mAlpha="); pw.print(mAlpha); |
| 1672 | pw.print(" mLastAlpha="); pw.println(mLastAlpha); |
| 1673 | } |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1674 | if (mHaveMatrix || mGlobalScale != 1) { |
| 1675 | pw.print(prefix); pw.print("mGlobalScale="); pw.print(mGlobalScale); |
| 1676 | pw.print(" mDsDx="); pw.print(mDsDx); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1677 | pw.print(" mDtDx="); pw.print(mDtDx); |
| 1678 | pw.print(" mDsDy="); pw.print(mDsDy); |
| 1679 | pw.print(" mDtDy="); pw.println(mDtDy); |
| 1680 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1681 | if (dumpAll) { |
| 1682 | pw.print(prefix); pw.print("mDrawPending="); pw.print(mDrawPending); |
| 1683 | pw.print(" mCommitDrawPending="); pw.print(mCommitDrawPending); |
| 1684 | pw.print(" mReadyToShow="); pw.print(mReadyToShow); |
| 1685 | pw.print(" mHasDrawn="); pw.println(mHasDrawn); |
| 1686 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1687 | if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { |
| 1688 | pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); |
| 1689 | pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); |
| 1690 | pw.print(" mDestroying="); pw.print(mDestroying); |
| 1691 | pw.print(" mRemoved="); pw.println(mRemoved); |
| 1692 | } |
| 1693 | if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { |
| 1694 | pw.print(prefix); pw.print("mOrientationChanging="); |
| 1695 | pw.print(mOrientationChanging); |
| 1696 | pw.print(" mAppFreezing="); pw.print(mAppFreezing); |
| 1697 | pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); |
| 1698 | } |
| 1699 | if (mHScale != 1 || mVScale != 1) { |
| 1700 | pw.print(prefix); pw.print("mHScale="); pw.print(mHScale); |
| 1701 | pw.print(" mVScale="); pw.println(mVScale); |
| 1702 | } |
| 1703 | if (mWallpaperX != -1 || mWallpaperY != -1) { |
| 1704 | pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); |
| 1705 | pw.print(" mWallpaperY="); pw.println(mWallpaperY); |
| 1706 | } |
| 1707 | if (mWallpaperXStep != -1 || mWallpaperYStep != -1) { |
| 1708 | pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep); |
| 1709 | pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep); |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | String makeInputChannelName() { |
| 1714 | return Integer.toHexString(System.identityHashCode(this)) |
| 1715 | + " " + mAttrs.getTitle(); |
| 1716 | } |
| 1717 | |
| 1718 | @Override |
| 1719 | public String toString() { |
| 1720 | if (mStringNameCache == null || mLastTitle != mAttrs.getTitle() |
| 1721 | || mWasPaused != mToken.paused) { |
| 1722 | mLastTitle = mAttrs.getTitle(); |
| 1723 | mWasPaused = mToken.paused; |
| 1724 | mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this)) |
| 1725 | + " " + mLastTitle + " paused=" + mWasPaused + "}"; |
| 1726 | } |
| 1727 | return mStringNameCache; |
| 1728 | } |
| 1729 | } |