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