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; |
Dianne Hackborn | 3ec891a | 2011-10-25 13:58:30 -0700 | [diff] [blame] | 615 | Slog.i(WindowManagerService.TAG, "createSurface " + this + ": DRAW NOW PENDING"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 616 | mDrawPending = true; |
| 617 | mCommitDrawPending = false; |
| 618 | mReadyToShow = false; |
| 619 | if (mAppToken != null) { |
| 620 | mAppToken.allDrawn = false; |
| 621 | } |
| 622 | |
Dianne Hackborn | 3ec891a | 2011-10-25 13:58:30 -0700 | [diff] [blame] | 623 | mService.makeWindowFreezingScreenIfNeededLocked(this); |
| 624 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 625 | int flags = 0; |
| 626 | |
| 627 | if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) { |
| 628 | flags |= Surface.SECURE; |
| 629 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 630 | if (DEBUG_VISIBILITY) Slog.v( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 631 | WindowManagerService.TAG, "Creating surface in session " |
| 632 | + mSession.mSurfaceSession + " window " + this |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 633 | + " w=" + mCompatFrame.width() |
| 634 | + " h=" + mCompatFrame.height() + " format=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 635 | + mAttrs.format + " flags=" + flags); |
| 636 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 637 | int w = mCompatFrame.width(); |
| 638 | int h = mCompatFrame.height(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 639 | if ((mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { |
| 640 | // for a scaled surface, we always want the requested |
| 641 | // size. |
| 642 | w = mRequestedWidth; |
| 643 | h = mRequestedHeight; |
| 644 | } |
| 645 | |
| 646 | // Something is wrong and SurfaceFlinger will not like this, |
| 647 | // try to revert to sane values |
| 648 | if (w <= 0) w = 1; |
| 649 | if (h <= 0) h = 1; |
| 650 | |
| 651 | mSurfaceShown = false; |
| 652 | mSurfaceLayer = 0; |
| 653 | mSurfaceAlpha = 1; |
| 654 | mSurfaceX = 0; |
| 655 | mSurfaceY = 0; |
| 656 | mSurfaceW = w; |
| 657 | mSurfaceH = h; |
| 658 | try { |
| 659 | final boolean isHwAccelerated = (mAttrs.flags & |
| 660 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; |
| 661 | final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : mAttrs.format; |
Romain Guy | 4941dea | 2011-09-26 16:08:14 -0700 | [diff] [blame] | 662 | if (!PixelFormat.formatHasAlpha(mAttrs.format)) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 663 | flags |= Surface.OPAQUE; |
| 664 | } |
| 665 | mSurface = new Surface( |
| 666 | mSession.mSurfaceSession, mSession.mPid, |
| 667 | mAttrs.getTitle().toString(), |
| 668 | 0, w, h, format, flags); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 669 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG, |
| 670 | " CREATE SURFACE " |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 671 | + mSurface + " IN SESSION " |
| 672 | + mSession.mSurfaceSession |
| 673 | + ": pid=" + mSession.mPid + " format=" |
| 674 | + mAttrs.format + " flags=0x" |
| 675 | + Integer.toHexString(flags) |
| 676 | + " / " + this); |
| 677 | } catch (Surface.OutOfResourcesException e) { |
| 678 | Slog.w(WindowManagerService.TAG, "OutOfResourcesException creating surface"); |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 679 | mService.reclaimSomeSurfaceMemoryLocked(this, "create", true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 680 | return null; |
| 681 | } catch (Exception e) { |
| 682 | Slog.e(WindowManagerService.TAG, "Exception creating surface", e); |
| 683 | return null; |
| 684 | } |
| 685 | |
| 686 | if (WindowManagerService.localLOGV) Slog.v( |
| 687 | WindowManagerService.TAG, "Got surface: " + mSurface |
| 688 | + ", set left=" + mFrame.left + " top=" + mFrame.top |
| 689 | + ", animLayer=" + mAnimLayer); |
Dianne Hackborn | 3699174 | 2011-10-11 21:35:26 -0700 | [diff] [blame] | 690 | if (SHOW_LIGHT_TRANSACTIONS) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 691 | Slog.i(WindowManagerService.TAG, ">>> OPEN TRANSACTION createSurfaceLocked"); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 692 | WindowManagerService.logSurface(this, "CREATE pos=(" + mFrame.left |
| 693 | + "," + mFrame.top + ") (" + |
| 694 | mCompatFrame.width() + "x" + mCompatFrame.height() + "), layer=" + |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 695 | mAnimLayer + " HIDE", null); |
| 696 | } |
| 697 | Surface.openTransaction(); |
| 698 | try { |
| 699 | try { |
| 700 | mSurfaceX = mFrame.left + mXOffset; |
| 701 | mSurfaceY = mFrame.top + mYOffset; |
| 702 | mSurface.setPosition(mSurfaceX, mSurfaceY); |
| 703 | mSurfaceLayer = mAnimLayer; |
| 704 | mSurface.setLayer(mAnimLayer); |
| 705 | mSurfaceShown = false; |
| 706 | mSurface.hide(); |
| 707 | if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 708 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "DITHER", null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 709 | mSurface.setFlags(Surface.SURFACE_DITHER, |
| 710 | Surface.SURFACE_DITHER); |
| 711 | } |
| 712 | } catch (RuntimeException e) { |
| 713 | Slog.w(WindowManagerService.TAG, "Error creating surface in " + w, e); |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 714 | mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 715 | } |
| 716 | mLastHidden = true; |
| 717 | } finally { |
| 718 | Surface.closeTransaction(); |
Dianne Hackborn | 3699174 | 2011-10-11 21:35:26 -0700 | [diff] [blame] | 719 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(WindowManagerService.TAG, |
| 720 | "<<< CLOSE TRANSACTION createSurfaceLocked"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 721 | } |
| 722 | if (WindowManagerService.localLOGV) Slog.v( |
| 723 | WindowManagerService.TAG, "Created surface " + this); |
| 724 | } |
| 725 | return mSurface; |
| 726 | } |
| 727 | |
| 728 | void destroySurfaceLocked() { |
| 729 | if (mAppToken != null && this == mAppToken.startingWindow) { |
| 730 | mAppToken.startingDisplayed = false; |
| 731 | } |
| 732 | |
| 733 | if (mSurface != null) { |
| 734 | mDrawPending = false; |
| 735 | mCommitDrawPending = false; |
| 736 | mReadyToShow = false; |
| 737 | |
| 738 | int i = mChildWindows.size(); |
| 739 | while (i > 0) { |
| 740 | i--; |
| 741 | WindowState c = mChildWindows.get(i); |
| 742 | c.mAttachedHidden = true; |
| 743 | } |
| 744 | |
| 745 | if (mReportDestroySurface) { |
| 746 | mReportDestroySurface = false; |
| 747 | mSurfacePendingDestroy = true; |
| 748 | try { |
| 749 | mClient.dispatchGetNewSurface(); |
| 750 | // We'll really destroy on the next time around. |
| 751 | return; |
| 752 | } catch (RemoteException e) { |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | try { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 757 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 758 | RuntimeException e = null; |
| 759 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 760 | e = new RuntimeException(); |
| 761 | e.fillInStackTrace(); |
| 762 | } |
| 763 | Slog.w(WindowManagerService.TAG, "Window " + this + " destroying surface " |
| 764 | + mSurface + ", session " + mSession, e); |
| 765 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 766 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 767 | RuntimeException e = null; |
| 768 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 769 | e = new RuntimeException(); |
| 770 | e.fillInStackTrace(); |
| 771 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 772 | WindowManagerService.logSurface(this, "DESTROY", e); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 773 | } |
| 774 | mSurface.destroy(); |
| 775 | } catch (RuntimeException e) { |
| 776 | Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window " + this |
| 777 | + " surface " + mSurface + " session " + mSession |
| 778 | + ": " + e.toString()); |
| 779 | } |
| 780 | |
| 781 | mSurfaceShown = false; |
| 782 | mSurface = null; |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | boolean finishDrawingLocked() { |
| 787 | if (mDrawPending) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 788 | if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v( |
Dianne Hackborn | 3ec891a | 2011-10-25 13:58:30 -0700 | [diff] [blame] | 789 | WindowManagerService.TAG, "finishDrawingLocked: " + this + " in " + mSurface); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 790 | mCommitDrawPending = true; |
| 791 | mDrawPending = false; |
| 792 | return true; |
| 793 | } |
| 794 | return false; |
| 795 | } |
| 796 | |
| 797 | // This must be called while inside a transaction. |
| 798 | boolean commitFinishDrawingLocked(long currentTime) { |
| 799 | //Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface); |
| 800 | if (!mCommitDrawPending) { |
| 801 | return false; |
| 802 | } |
| 803 | mCommitDrawPending = false; |
| 804 | mReadyToShow = true; |
| 805 | final boolean starting = mAttrs.type == TYPE_APPLICATION_STARTING; |
| 806 | final AppWindowToken atoken = mAppToken; |
| 807 | if (atoken == null || atoken.allDrawn || starting) { |
| 808 | performShowLocked(); |
| 809 | } |
| 810 | return true; |
| 811 | } |
| 812 | |
| 813 | // This must be called while inside a transaction. |
| 814 | boolean performShowLocked() { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 815 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 816 | RuntimeException e = null; |
| 817 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 818 | e = new RuntimeException(); |
| 819 | e.fillInStackTrace(); |
| 820 | } |
| 821 | Slog.v(WindowManagerService.TAG, "performShow on " + this |
| 822 | + ": readyToShow=" + mReadyToShow + " readyForDisplay=" + isReadyForDisplay() |
| 823 | + " starting=" + (mAttrs.type == TYPE_APPLICATION_STARTING), e); |
| 824 | } |
| 825 | if (mReadyToShow && isReadyForDisplay()) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 826 | if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) WindowManagerService.logSurface(this, |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 827 | "SHOW (performShowLocked)", null); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 828 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Showing " + this |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 829 | + " during animation: policyVis=" + mPolicyVisibility |
| 830 | + " attHidden=" + mAttachedHidden |
| 831 | + " tok.hiddenRequested=" |
| 832 | + (mAppToken != null ? mAppToken.hiddenRequested : false) |
| 833 | + " tok.hidden=" |
| 834 | + (mAppToken != null ? mAppToken.hidden : false) |
| 835 | + " animating=" + mAnimating |
| 836 | + " tok animating=" |
| 837 | + (mAppToken != null ? mAppToken.animating : false)); |
| 838 | if (!mService.showSurfaceRobustlyLocked(this)) { |
| 839 | return false; |
| 840 | } |
| 841 | mLastAlpha = -1; |
| 842 | mHasDrawn = true; |
| 843 | mLastHidden = false; |
| 844 | mReadyToShow = false; |
| 845 | mService.enableScreenIfNeededLocked(); |
| 846 | |
| 847 | mService.applyEnterAnimationLocked(this); |
| 848 | |
| 849 | int i = mChildWindows.size(); |
| 850 | while (i > 0) { |
| 851 | i--; |
| 852 | WindowState c = mChildWindows.get(i); |
| 853 | if (c.mAttachedHidden) { |
| 854 | c.mAttachedHidden = false; |
| 855 | if (c.mSurface != null) { |
| 856 | c.performShowLocked(); |
| 857 | // It hadn't been shown, which means layout not |
| 858 | // performed on it, so now we want to make sure to |
| 859 | // do a layout. If called from within the transaction |
| 860 | // loop, this will cause it to restart with a new |
| 861 | // layout. |
| 862 | mService.mLayoutNeeded = true; |
| 863 | } |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | if (mAttrs.type != TYPE_APPLICATION_STARTING |
| 868 | && mAppToken != null) { |
| 869 | mAppToken.firstWindowDrawn = true; |
| 870 | |
| 871 | if (mAppToken.startingData != null) { |
| 872 | if (WindowManagerService.DEBUG_STARTING_WINDOW || WindowManagerService.DEBUG_ANIM) Slog.v(WindowManagerService.TAG, |
| 873 | "Finish starting " + mToken |
| 874 | + ": first real window is shown, no animation"); |
| 875 | // If this initial window is animating, stop it -- we |
| 876 | // will do an animation to reveal it from behind the |
| 877 | // starting window, so there is no need for it to also |
| 878 | // be doing its own stuff. |
| 879 | if (mAnimation != null) { |
| 880 | mAnimation.cancel(); |
| 881 | mAnimation = null; |
| 882 | // Make sure we clean up the animation. |
| 883 | mAnimating = true; |
| 884 | } |
| 885 | mService.mFinishedStarting.add(mAppToken); |
| 886 | mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 887 | } |
| 888 | mAppToken.updateReportedVisibilityLocked(); |
| 889 | } |
| 890 | } |
| 891 | return true; |
| 892 | } |
| 893 | |
| 894 | // This must be called while inside a transaction. Returns true if |
| 895 | // there is more animation to run. |
| 896 | boolean stepAnimationLocked(long currentTime, int dw, int dh) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 897 | if (!mService.mDisplayFrozen && mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 898 | // We will run animations as long as the display isn't frozen. |
| 899 | |
| 900 | if (!mDrawPending && !mCommitDrawPending && mAnimation != null) { |
| 901 | mHasTransformation = true; |
| 902 | mHasLocalTransformation = true; |
| 903 | if (!mLocalAnimating) { |
| 904 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 905 | WindowManagerService.TAG, "Starting animation in " + this + |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 906 | " @ " + currentTime + ": ww=" + mFrame.width() + |
| 907 | " wh=" + mFrame.height() + |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 908 | " dw=" + dw + " dh=" + dh + " scale=" + mService.mWindowAnimationScale); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 909 | mAnimation.initialize(mFrame.width(), mFrame.height(), dw, dh); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 910 | mAnimation.setStartTime(currentTime); |
| 911 | mLocalAnimating = true; |
| 912 | mAnimating = true; |
| 913 | } |
| 914 | mTransformation.clear(); |
| 915 | final boolean more = mAnimation.getTransformation( |
| 916 | currentTime, mTransformation); |
| 917 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 918 | WindowManagerService.TAG, "Stepped animation in " + this + |
| 919 | ": more=" + more + ", xform=" + mTransformation); |
| 920 | if (more) { |
| 921 | // we're not done! |
| 922 | return true; |
| 923 | } |
| 924 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 925 | WindowManagerService.TAG, "Finished animation in " + this + |
| 926 | " @ " + currentTime); |
| 927 | |
| 928 | if (mAnimation != null) { |
| 929 | mAnimation.cancel(); |
| 930 | mAnimation = null; |
| 931 | } |
| 932 | //WindowManagerService.this.dump(); |
| 933 | } |
| 934 | mHasLocalTransformation = false; |
| 935 | if ((!mLocalAnimating || mAnimationIsEntrance) && mAppToken != null |
| 936 | && mAppToken.animation != null) { |
| 937 | // When our app token is animating, we kind-of pretend like |
| 938 | // we are as well. Note the mLocalAnimating mAnimationIsEntrance |
| 939 | // part of this check means that we will only do this if |
| 940 | // our window is not currently exiting, or it is not |
| 941 | // locally animating itself. The idea being that one that |
| 942 | // is exiting and doing a local animation should be removed |
| 943 | // once that animation is done. |
| 944 | mAnimating = true; |
| 945 | mHasTransformation = true; |
| 946 | mTransformation.clear(); |
| 947 | return false; |
| 948 | } else if (mHasTransformation) { |
| 949 | // Little trick to get through the path below to act like |
| 950 | // we have finished an animation. |
| 951 | mAnimating = true; |
| 952 | } else if (isAnimating()) { |
| 953 | mAnimating = true; |
| 954 | } |
| 955 | } else if (mAnimation != null) { |
| 956 | // If the display is frozen, and there is a pending animation, |
| 957 | // clear it and make sure we run the cleanup code. |
| 958 | mAnimating = true; |
| 959 | mLocalAnimating = true; |
| 960 | mAnimation.cancel(); |
| 961 | mAnimation = null; |
| 962 | } |
| 963 | |
| 964 | if (!mAnimating && !mLocalAnimating) { |
| 965 | return false; |
| 966 | } |
| 967 | |
| 968 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 969 | WindowManagerService.TAG, "Animation done in " + this + ": exiting=" + mExiting |
| 970 | + ", reportedVisible=" |
| 971 | + (mAppToken != null ? mAppToken.reportedVisible : false)); |
| 972 | |
| 973 | mAnimating = false; |
| 974 | mLocalAnimating = false; |
| 975 | if (mAnimation != null) { |
| 976 | mAnimation.cancel(); |
| 977 | mAnimation = null; |
| 978 | } |
| 979 | mAnimLayer = mLayer; |
| 980 | if (mIsImWindow) { |
| 981 | mAnimLayer += mService.mInputMethodAnimLayerAdjustment; |
| 982 | } else if (mIsWallpaper) { |
| 983 | mAnimLayer += mService.mWallpaperAnimLayerAdjustment; |
| 984 | } |
| 985 | if (WindowManagerService.DEBUG_LAYERS) Slog.v(WindowManagerService.TAG, "Stepping win " + this |
| 986 | + " anim layer: " + mAnimLayer); |
| 987 | mHasTransformation = false; |
| 988 | mHasLocalTransformation = false; |
| 989 | if (mPolicyVisibility != mPolicyVisibilityAfterAnim) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 990 | if (DEBUG_VISIBILITY) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 991 | Slog.v(WindowManagerService.TAG, "Policy visibility changing after anim in " + this + ": " |
| 992 | + mPolicyVisibilityAfterAnim); |
| 993 | } |
| 994 | mPolicyVisibility = mPolicyVisibilityAfterAnim; |
Dianne Hackborn | f809870 | 2011-09-13 13:26:38 -0700 | [diff] [blame] | 995 | mService.mLayoutNeeded = true; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 996 | if (!mPolicyVisibility) { |
| 997 | if (mService.mCurrentFocus == this) { |
| 998 | mService.mFocusMayChange = true; |
| 999 | } |
| 1000 | // Window is no longer visible -- make sure if we were waiting |
| 1001 | // for it to be displayed before enabling the display, that |
| 1002 | // we allow the display to be enabled now. |
| 1003 | mService.enableScreenIfNeededLocked(); |
| 1004 | } |
| 1005 | } |
| 1006 | mTransformation.clear(); |
| 1007 | if (mHasDrawn |
| 1008 | && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING |
| 1009 | && mAppToken != null |
| 1010 | && mAppToken.firstWindowDrawn |
| 1011 | && mAppToken.startingData != null) { |
| 1012 | if (WindowManagerService.DEBUG_STARTING_WINDOW) Slog.v(WindowManagerService.TAG, "Finish starting " |
| 1013 | + mToken + ": first real window done animating"); |
| 1014 | mService.mFinishedStarting.add(mAppToken); |
| 1015 | mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 1016 | } |
| 1017 | |
| 1018 | finishExit(); |
| 1019 | |
| 1020 | if (mAppToken != null) { |
| 1021 | mAppToken.updateReportedVisibilityLocked(); |
| 1022 | } |
| 1023 | |
| 1024 | return false; |
| 1025 | } |
| 1026 | |
| 1027 | void finishExit() { |
| 1028 | if (WindowManagerService.DEBUG_ANIM) Slog.v( |
| 1029 | WindowManagerService.TAG, "finishExit in " + this |
| 1030 | + ": exiting=" + mExiting |
| 1031 | + " remove=" + mRemoveOnExit |
| 1032 | + " windowAnimating=" + isWindowAnimating()); |
| 1033 | |
| 1034 | final int N = mChildWindows.size(); |
| 1035 | for (int i=0; i<N; i++) { |
| 1036 | mChildWindows.get(i).finishExit(); |
| 1037 | } |
| 1038 | |
| 1039 | if (!mExiting) { |
| 1040 | return; |
| 1041 | } |
| 1042 | |
| 1043 | if (isWindowAnimating()) { |
| 1044 | return; |
| 1045 | } |
| 1046 | |
| 1047 | if (WindowManagerService.localLOGV) Slog.v( |
| 1048 | WindowManagerService.TAG, "Exit animation finished in " + this |
| 1049 | + ": remove=" + mRemoveOnExit); |
| 1050 | if (mSurface != null) { |
| 1051 | mService.mDestroySurface.add(this); |
| 1052 | mDestroying = true; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1053 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "HIDE (finishExit)", null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1054 | mSurfaceShown = false; |
| 1055 | try { |
| 1056 | mSurface.hide(); |
| 1057 | } catch (RuntimeException e) { |
| 1058 | Slog.w(WindowManagerService.TAG, "Error hiding surface in " + this, e); |
| 1059 | } |
| 1060 | mLastHidden = true; |
| 1061 | } |
| 1062 | mExiting = false; |
| 1063 | if (mRemoveOnExit) { |
| 1064 | mService.mPendingRemove.add(this); |
| 1065 | mRemoveOnExit = false; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { |
| 1070 | if (dsdx < .99999f || dsdx > 1.00001f) return false; |
| 1071 | if (dtdy < .99999f || dtdy > 1.00001f) return false; |
| 1072 | if (dtdx < -.000001f || dtdx > .000001f) return false; |
| 1073 | if (dsdy < -.000001f || dsdy > .000001f) return false; |
| 1074 | return true; |
| 1075 | } |
| 1076 | |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1077 | void prelayout() { |
| 1078 | if (mEnforceSizeCompat) { |
| 1079 | mGlobalScale = mService.mCompatibleScreenScale; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1080 | mInvGlobalScale = 1/mGlobalScale; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1081 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1082 | mGlobalScale = mInvGlobalScale = 1; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1083 | } |
| 1084 | } |
| 1085 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1086 | void computeShownFrameLocked() { |
| 1087 | final boolean selfTransformation = mHasLocalTransformation; |
| 1088 | Transformation attachedTransformation = |
| 1089 | (mAttachedWindow != null && mAttachedWindow.mHasLocalTransformation) |
| 1090 | ? mAttachedWindow.mTransformation : null; |
| 1091 | Transformation appTransformation = |
| 1092 | (mAppToken != null && mAppToken.hasTransformation) |
| 1093 | ? mAppToken.transformation : null; |
| 1094 | |
| 1095 | // Wallpapers are animated based on the "real" window they |
| 1096 | // are currently targeting. |
| 1097 | if (mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null |
| 1098 | && mService.mWallpaperTarget != null) { |
| 1099 | if (mService.mWallpaperTarget.mHasLocalTransformation && |
| 1100 | mService.mWallpaperTarget.mAnimation != null && |
| 1101 | !mService.mWallpaperTarget.mAnimation.getDetachWallpaper()) { |
| 1102 | attachedTransformation = mService.mWallpaperTarget.mTransformation; |
| 1103 | if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) { |
| 1104 | Slog.v(WindowManagerService.TAG, "WP target attached xform: " + attachedTransformation); |
| 1105 | } |
| 1106 | } |
| 1107 | if (mService.mWallpaperTarget.mAppToken != null && |
| 1108 | mService.mWallpaperTarget.mAppToken.hasTransformation && |
| 1109 | mService.mWallpaperTarget.mAppToken.animation != null && |
| 1110 | !mService.mWallpaperTarget.mAppToken.animation.getDetachWallpaper()) { |
| 1111 | appTransformation = mService.mWallpaperTarget.mAppToken.transformation; |
| 1112 | if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) { |
| 1113 | Slog.v(WindowManagerService.TAG, "WP target app xform: " + appTransformation); |
| 1114 | } |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | final boolean screenAnimation = mService.mScreenRotationAnimation != null |
| 1119 | && mService.mScreenRotationAnimation.isAnimating(); |
| 1120 | if (selfTransformation || attachedTransformation != null |
| 1121 | || appTransformation != null || screenAnimation) { |
| 1122 | // cache often used attributes locally |
| 1123 | final Rect frame = mFrame; |
| 1124 | final float tmpFloats[] = mService.mTmpFloats; |
| 1125 | final Matrix tmpMatrix = mTmpMatrix; |
| 1126 | |
| 1127 | // Compute the desired transformation. |
Dianne Hackborn | 73db0d8 | 2011-09-16 01:09:40 -0700 | [diff] [blame] | 1128 | if (screenAnimation) { |
| 1129 | // If we are doing a screen animation, the global rotation |
| 1130 | // applied to windows can result in windows that are carefully |
| 1131 | // aligned with each other to slightly separate, allowing you |
| 1132 | // to see what is behind them. An unsightly mess. This... |
| 1133 | // thing... magically makes it call good: scale each window |
| 1134 | // slightly (two pixels larger in each dimension, from the |
| 1135 | // window's center). |
| 1136 | final float w = frame.width(); |
| 1137 | final float h = frame.height(); |
Mathias Agopian | 526f0a0 | 2011-10-18 20:19:59 -0700 | [diff] [blame] | 1138 | if (w>=1 && h>=1) { |
| 1139 | tmpMatrix.setScale(1 + 2/w, 1 + 2/h, w/2, h/2); |
| 1140 | } else { |
| 1141 | tmpMatrix.reset(); |
| 1142 | } |
Dianne Hackborn | 73db0d8 | 2011-09-16 01:09:40 -0700 | [diff] [blame] | 1143 | } else { |
| 1144 | tmpMatrix.reset(); |
| 1145 | } |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1146 | tmpMatrix.postScale(mGlobalScale, mGlobalScale); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1147 | if (selfTransformation) { |
| 1148 | tmpMatrix.postConcat(mTransformation.getMatrix()); |
| 1149 | } |
| 1150 | tmpMatrix.postTranslate(frame.left + mXOffset, frame.top + mYOffset); |
| 1151 | if (attachedTransformation != null) { |
| 1152 | tmpMatrix.postConcat(attachedTransformation.getMatrix()); |
| 1153 | } |
| 1154 | if (appTransformation != null) { |
| 1155 | tmpMatrix.postConcat(appTransformation.getMatrix()); |
| 1156 | } |
| 1157 | if (screenAnimation) { |
| 1158 | tmpMatrix.postConcat( |
| 1159 | mService.mScreenRotationAnimation.getEnterTransformation().getMatrix()); |
| 1160 | } |
| 1161 | |
| 1162 | // "convert" it into SurfaceFlinger's format |
| 1163 | // (a 2x2 matrix + an offset) |
| 1164 | // Here we must not transform the position of the surface |
| 1165 | // since it is already included in the transformation. |
| 1166 | //Slog.i(TAG, "Transform: " + matrix); |
| 1167 | |
| 1168 | mHaveMatrix = true; |
| 1169 | tmpMatrix.getValues(tmpFloats); |
| 1170 | mDsDx = tmpFloats[Matrix.MSCALE_X]; |
| 1171 | mDtDx = tmpFloats[Matrix.MSKEW_Y]; |
| 1172 | mDsDy = tmpFloats[Matrix.MSKEW_X]; |
| 1173 | mDtDy = tmpFloats[Matrix.MSCALE_Y]; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 1174 | float x = tmpFloats[Matrix.MTRANS_X]; |
| 1175 | float y = tmpFloats[Matrix.MTRANS_Y]; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1176 | int w = frame.width(); |
| 1177 | int h = frame.height(); |
| 1178 | mShownFrame.set(x, y, x+w, y+h); |
| 1179 | |
| 1180 | // Now set the alpha... but because our current hardware |
| 1181 | // can't do alpha transformation on a non-opaque surface, |
| 1182 | // turn it off if we are running an animation that is also |
| 1183 | // transforming since it is more important to have that |
| 1184 | // animation be smooth. |
| 1185 | mShownAlpha = mAlpha; |
| 1186 | if (!mService.mLimitedAlphaCompositing |
| 1187 | || (!PixelFormat.formatHasAlpha(mAttrs.format) |
| 1188 | || (isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy) |
| 1189 | && x == frame.left && y == frame.top))) { |
| 1190 | //Slog.i(TAG, "Applying alpha transform"); |
| 1191 | if (selfTransformation) { |
| 1192 | mShownAlpha *= mTransformation.getAlpha(); |
| 1193 | } |
| 1194 | if (attachedTransformation != null) { |
| 1195 | mShownAlpha *= attachedTransformation.getAlpha(); |
| 1196 | } |
| 1197 | if (appTransformation != null) { |
| 1198 | mShownAlpha *= appTransformation.getAlpha(); |
| 1199 | } |
| 1200 | if (screenAnimation) { |
| 1201 | mShownAlpha *= |
| 1202 | mService.mScreenRotationAnimation.getEnterTransformation().getAlpha(); |
| 1203 | } |
| 1204 | } else { |
| 1205 | //Slog.i(TAG, "Not applying alpha transform"); |
| 1206 | } |
| 1207 | |
| 1208 | if (WindowManagerService.localLOGV) Slog.v( |
| 1209 | WindowManagerService.TAG, "Continuing animation in " + this + |
| 1210 | ": " + mShownFrame + |
| 1211 | ", alpha=" + mTransformation.getAlpha()); |
| 1212 | return; |
| 1213 | } |
| 1214 | |
| 1215 | mShownFrame.set(mFrame); |
| 1216 | if (mXOffset != 0 || mYOffset != 0) { |
| 1217 | mShownFrame.offset(mXOffset, mYOffset); |
| 1218 | } |
| 1219 | mShownAlpha = mAlpha; |
| 1220 | mHaveMatrix = false; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1221 | mDsDx = mGlobalScale; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1222 | mDtDx = 0; |
| 1223 | mDsDy = 0; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1224 | mDtDy = mGlobalScale; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Is this window visible? It is not visible if there is no |
| 1229 | * surface, or we are in the process of running an exit animation |
| 1230 | * that will remove the surface, or its app token has been hidden. |
| 1231 | */ |
| 1232 | public boolean isVisibleLw() { |
| 1233 | final AppWindowToken atoken = mAppToken; |
| 1234 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1235 | && (atoken == null || !atoken.hiddenRequested) |
| 1236 | && !mExiting && !mDestroying; |
| 1237 | } |
| 1238 | |
| 1239 | /** |
| 1240 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 1241 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 1242 | * things like window flags that impact the keyguard. |
| 1243 | * XXX I am starting to think we need to have ANOTHER visibility flag |
| 1244 | * for this "hidden behind keyguard" state rather than overloading |
| 1245 | * mPolicyVisibility. Ungh. |
| 1246 | */ |
| 1247 | public boolean isVisibleOrBehindKeyguardLw() { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1248 | if (mRootToken.waitingToShow && |
| 1249 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 1250 | return false; |
| 1251 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1252 | final AppWindowToken atoken = mAppToken; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1253 | final boolean animating = atoken != null |
| 1254 | ? (atoken.animation != null) : false; |
| 1255 | return mSurface != null && !mDestroying && !mExiting |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1256 | && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1257 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1258 | && !mRootToken.hidden) |
| 1259 | || mAnimation != null || animating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | /** |
| 1263 | * Is this window visible, ignoring its app token? It is not visible |
| 1264 | * if there is no surface, or we are in the process of running an exit animation |
| 1265 | * that will remove the surface. |
| 1266 | */ |
| 1267 | public boolean isWinVisibleLw() { |
| 1268 | final AppWindowToken atoken = mAppToken; |
| 1269 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1270 | && (atoken == null || !atoken.hiddenRequested || atoken.animating) |
| 1271 | && !mExiting && !mDestroying; |
| 1272 | } |
| 1273 | |
| 1274 | /** |
| 1275 | * The same as isVisible(), but follows the current hidden state of |
| 1276 | * the associated app token, not the pending requested hidden state. |
| 1277 | */ |
| 1278 | boolean isVisibleNow() { |
| 1279 | return mSurface != null && mPolicyVisibility && !mAttachedHidden |
| 1280 | && !mRootToken.hidden && !mExiting && !mDestroying; |
| 1281 | } |
| 1282 | |
| 1283 | /** |
| 1284 | * Can this window possibly be a drag/drop target? The test here is |
| 1285 | * a combination of the above "visible now" with the check that the |
| 1286 | * Input Manager uses when discarding windows from input consideration. |
| 1287 | */ |
| 1288 | boolean isPotentialDragTarget() { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1289 | return isVisibleNow() && !mRemoved |
| 1290 | && mInputChannel != null && mInputWindowHandle != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | /** |
| 1294 | * Same as isVisible(), but we also count it as visible between the |
| 1295 | * call to IWindowSession.add() and the first relayout(). |
| 1296 | */ |
| 1297 | boolean isVisibleOrAdding() { |
| 1298 | final AppWindowToken atoken = mAppToken; |
| 1299 | return ((mSurface != null && !mReportDestroySurface) |
| 1300 | || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) |
| 1301 | && mPolicyVisibility && !mAttachedHidden |
| 1302 | && (atoken == null || !atoken.hiddenRequested) |
| 1303 | && !mExiting && !mDestroying; |
| 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * Is this window currently on-screen? It is on-screen either if it |
| 1308 | * is visible or it is currently running an animation before no longer |
| 1309 | * being visible. |
| 1310 | */ |
| 1311 | boolean isOnScreen() { |
| 1312 | final AppWindowToken atoken = mAppToken; |
| 1313 | if (atoken != null) { |
| 1314 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1315 | && ((!mAttachedHidden && !atoken.hiddenRequested) |
| 1316 | || mAnimation != null || atoken.animation != null); |
| 1317 | } else { |
| 1318 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1319 | && (!mAttachedHidden || mAnimation != null); |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | /** |
| 1324 | * Like isOnScreen(), but we don't return true if the window is part |
| 1325 | * of a transition that has not yet been started. |
| 1326 | */ |
| 1327 | boolean isReadyForDisplay() { |
| 1328 | if (mRootToken.waitingToShow && |
| 1329 | mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { |
| 1330 | return false; |
| 1331 | } |
| 1332 | final AppWindowToken atoken = mAppToken; |
| 1333 | final boolean animating = atoken != null |
| 1334 | ? (atoken.animation != null) : false; |
| 1335 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1336 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1337 | && !mRootToken.hidden) |
| 1338 | || mAnimation != null || animating); |
| 1339 | } |
| 1340 | |
| 1341 | /** Is the window or its container currently animating? */ |
| 1342 | boolean isAnimating() { |
| 1343 | final WindowState attached = mAttachedWindow; |
| 1344 | final AppWindowToken atoken = mAppToken; |
| 1345 | return mAnimation != null |
| 1346 | || (attached != null && attached.mAnimation != null) |
| 1347 | || (atoken != null && |
| 1348 | (atoken.animation != null |
| 1349 | || atoken.inPendingTransaction)); |
| 1350 | } |
| 1351 | |
| 1352 | /** Is this window currently animating? */ |
| 1353 | boolean isWindowAnimating() { |
| 1354 | return mAnimation != null; |
| 1355 | } |
| 1356 | |
| 1357 | /** |
| 1358 | * Like isOnScreen, but returns false if the surface hasn't yet |
| 1359 | * been drawn. |
| 1360 | */ |
| 1361 | public boolean isDisplayedLw() { |
| 1362 | final AppWindowToken atoken = mAppToken; |
| 1363 | return mSurface != null && mPolicyVisibility && !mDestroying |
| 1364 | && !mDrawPending && !mCommitDrawPending |
| 1365 | && ((!mAttachedHidden && |
| 1366 | (atoken == null || !atoken.hiddenRequested)) |
| 1367 | || mAnimating); |
| 1368 | } |
| 1369 | |
| 1370 | /** |
| 1371 | * Returns true if the window has a surface that it has drawn a |
| 1372 | * complete UI in to. |
| 1373 | */ |
| 1374 | public boolean isDrawnLw() { |
| 1375 | final AppWindowToken atoken = mAppToken; |
| 1376 | return mSurface != null && !mDestroying |
| 1377 | && !mDrawPending && !mCommitDrawPending; |
| 1378 | } |
| 1379 | |
| 1380 | /** |
| 1381 | * Return true if the window is opaque and fully drawn. This indicates |
| 1382 | * it may obscure windows behind it. |
| 1383 | */ |
| 1384 | boolean isOpaqueDrawn() { |
| 1385 | return (mAttrs.format == PixelFormat.OPAQUE |
| 1386 | || mAttrs.type == TYPE_WALLPAPER) |
| 1387 | && mSurface != null && mAnimation == null |
| 1388 | && (mAppToken == null || mAppToken.animation == null) |
| 1389 | && !mDrawPending && !mCommitDrawPending; |
| 1390 | } |
| 1391 | |
| 1392 | /** |
| 1393 | * Return whether this window is wanting to have a translation |
| 1394 | * animation applied to it for an in-progress move. (Only makes |
| 1395 | * sense to call from performLayoutAndPlaceSurfacesLockedInner().) |
| 1396 | */ |
| 1397 | boolean shouldAnimateMove() { |
| 1398 | return mContentChanged && !mExiting && !mLastHidden && !mService.mDisplayFrozen |
| 1399 | && (mFrame.top != mLastFrame.top |
| 1400 | || mFrame.left != mLastFrame.left) |
| 1401 | && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove()) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1402 | && mService.mPolicy.isScreenOnFully(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1403 | } |
| 1404 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1405 | boolean isFullscreen(int screenWidth, int screenHeight) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1406 | return mFrame.left <= 0 && mFrame.top <= 0 && |
| 1407 | mFrame.right >= screenWidth && mFrame.bottom >= screenHeight; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | void removeLocked() { |
| 1411 | disposeInputChannel(); |
| 1412 | |
| 1413 | if (mAttachedWindow != null) { |
| 1414 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(WindowManagerService.TAG, "Removing " + this + " from " + mAttachedWindow); |
| 1415 | mAttachedWindow.mChildWindows.remove(this); |
| 1416 | } |
| 1417 | destroySurfaceLocked(); |
| 1418 | mSession.windowRemovedLocked(); |
| 1419 | try { |
| 1420 | mClient.asBinder().unlinkToDeath(mDeathRecipient, 0); |
| 1421 | } catch (RuntimeException e) { |
| 1422 | // Ignore if it has already been removed (usually because |
| 1423 | // we are doing this as part of processing a death note.) |
| 1424 | } |
| 1425 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1426 | |
| 1427 | void setInputChannel(InputChannel inputChannel) { |
| 1428 | if (mInputChannel != null) { |
| 1429 | throw new IllegalStateException("Window already has an input channel."); |
| 1430 | } |
| 1431 | |
| 1432 | mInputChannel = inputChannel; |
| 1433 | mInputWindowHandle.inputChannel = inputChannel; |
| 1434 | } |
| 1435 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1436 | void disposeInputChannel() { |
| 1437 | if (mInputChannel != null) { |
| 1438 | mService.mInputManager.unregisterInputChannel(mInputChannel); |
| 1439 | |
| 1440 | mInputChannel.dispose(); |
| 1441 | mInputChannel = null; |
| 1442 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1443 | |
| 1444 | mInputWindowHandle.inputChannel = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | private class DeathRecipient implements IBinder.DeathRecipient { |
| 1448 | public void binderDied() { |
| 1449 | try { |
| 1450 | synchronized(mService.mWindowMap) { |
| 1451 | WindowState win = mService.windowForClientLocked(mSession, mClient, false); |
| 1452 | Slog.i(WindowManagerService.TAG, "WIN DEATH: " + win); |
| 1453 | if (win != null) { |
| 1454 | mService.removeWindowLocked(mSession, win); |
| 1455 | } |
| 1456 | } |
| 1457 | } catch (IllegalArgumentException ex) { |
| 1458 | // This will happen if the window has already been |
| 1459 | // removed. |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | |
| 1464 | /** Returns true if this window desires key events. */ |
| 1465 | public final boolean canReceiveKeys() { |
| 1466 | return isVisibleOrAdding() |
| 1467 | && (mViewVisibility == View.VISIBLE) |
| 1468 | && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0); |
| 1469 | } |
| 1470 | |
| 1471 | public boolean hasDrawnLw() { |
| 1472 | return mHasDrawn; |
| 1473 | } |
| 1474 | |
| 1475 | public boolean showLw(boolean doAnimation) { |
| 1476 | return showLw(doAnimation, true); |
| 1477 | } |
| 1478 | |
| 1479 | boolean showLw(boolean doAnimation, boolean requestAnim) { |
| 1480 | if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { |
| 1481 | return false; |
| 1482 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1483 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility true: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1484 | if (doAnimation) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1485 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "doAnimation: mPolicyVisibility=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1486 | + mPolicyVisibility + " mAnimation=" + mAnimation); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1487 | if (mService.mDisplayFrozen || !mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1488 | doAnimation = false; |
| 1489 | } else if (mPolicyVisibility && mAnimation == null) { |
| 1490 | // Check for the case where we are currently visible and |
| 1491 | // not animating; we do not want to do animation at such a |
| 1492 | // point to become visible when we already are. |
| 1493 | doAnimation = false; |
| 1494 | } |
| 1495 | } |
| 1496 | mPolicyVisibility = true; |
| 1497 | mPolicyVisibilityAfterAnim = true; |
| 1498 | if (doAnimation) { |
| 1499 | mService.applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_ENTER, true); |
| 1500 | } |
| 1501 | if (requestAnim) { |
| 1502 | mService.requestAnimationLocked(0); |
| 1503 | } |
| 1504 | return true; |
| 1505 | } |
| 1506 | |
| 1507 | public boolean hideLw(boolean doAnimation) { |
| 1508 | return hideLw(doAnimation, true); |
| 1509 | } |
| 1510 | |
| 1511 | boolean hideLw(boolean doAnimation, boolean requestAnim) { |
| 1512 | if (doAnimation) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1513 | if (mService.mDisplayFrozen || !mService.mPolicy.isScreenOnFully()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1514 | doAnimation = false; |
| 1515 | } |
| 1516 | } |
| 1517 | boolean current = doAnimation ? mPolicyVisibilityAfterAnim |
| 1518 | : mPolicyVisibility; |
| 1519 | if (!current) { |
| 1520 | return false; |
| 1521 | } |
| 1522 | if (doAnimation) { |
| 1523 | mService.applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_EXIT, false); |
| 1524 | if (mAnimation == null) { |
| 1525 | doAnimation = false; |
| 1526 | } |
| 1527 | } |
| 1528 | if (doAnimation) { |
| 1529 | mPolicyVisibilityAfterAnim = false; |
| 1530 | } else { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1531 | if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility false: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1532 | mPolicyVisibilityAfterAnim = false; |
| 1533 | mPolicyVisibility = false; |
| 1534 | // Window is no longer visible -- make sure if we were waiting |
| 1535 | // for it to be displayed before enabling the display, that |
| 1536 | // we allow the display to be enabled now. |
| 1537 | mService.enableScreenIfNeededLocked(); |
| 1538 | if (mService.mCurrentFocus == this) { |
| 1539 | mService.mFocusMayChange = true; |
| 1540 | } |
| 1541 | } |
| 1542 | if (requestAnim) { |
| 1543 | mService.requestAnimationLocked(0); |
| 1544 | } |
| 1545 | return true; |
| 1546 | } |
| 1547 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1548 | private static void applyInsets(Region outRegion, Rect frame, Rect inset) { |
| 1549 | outRegion.set( |
| 1550 | frame.left + inset.left, frame.top + inset.top, |
| 1551 | frame.right - inset.right, frame.bottom - inset.bottom); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1552 | } |
| 1553 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1554 | public void getTouchableRegion(Region outRegion) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1555 | final Rect frame = mFrame; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1556 | switch (mTouchableInsets) { |
| 1557 | default: |
| 1558 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME: |
| 1559 | outRegion.set(frame); |
| 1560 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1561 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1562 | applyInsets(outRegion, frame, mGivenContentInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1563 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1564 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1565 | applyInsets(outRegion, frame, mGivenVisibleInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1566 | break; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1567 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: { |
| 1568 | final Region givenTouchableRegion = mGivenTouchableRegion; |
| 1569 | outRegion.set(givenTouchableRegion); |
| 1570 | outRegion.translate(frame.left, frame.top); |
| 1571 | break; |
| 1572 | } |
| 1573 | } |
| 1574 | } |
| 1575 | |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1576 | void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1577 | pw.print(prefix); pw.print("mSession="); pw.print(mSession); |
| 1578 | pw.print(" mClient="); pw.println(mClient.asBinder()); |
| 1579 | pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1580 | pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); |
| 1581 | pw.print(" h="); pw.print(mRequestedHeight); |
| 1582 | pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1583 | if (mAttachedWindow != null || mLayoutAttached) { |
| 1584 | pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); |
| 1585 | pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); |
| 1586 | } |
| 1587 | if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) { |
| 1588 | pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow); |
| 1589 | pw.print(" mIsWallpaper="); pw.print(mIsWallpaper); |
| 1590 | pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer); |
| 1591 | pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible); |
| 1592 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1593 | if (dumpAll) { |
| 1594 | pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); |
| 1595 | pw.print(" mSubLayer="); pw.print(mSubLayer); |
| 1596 | pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); |
| 1597 | pw.print((mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment |
| 1598 | : (mAppToken != null ? mAppToken.animLayerAdjustment : 0))); |
| 1599 | pw.print("="); pw.print(mAnimLayer); |
| 1600 | pw.print(" mLastLayer="); pw.println(mLastLayer); |
| 1601 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1602 | if (mSurface != null) { |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1603 | if (dumpAll) { |
| 1604 | pw.print(prefix); pw.print("mSurface="); pw.println(mSurface); |
| 1605 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1606 | pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); |
| 1607 | pw.print(" layer="); pw.print(mSurfaceLayer); |
| 1608 | pw.print(" alpha="); pw.print(mSurfaceAlpha); |
| 1609 | pw.print(" rect=("); pw.print(mSurfaceX); |
| 1610 | pw.print(","); pw.print(mSurfaceY); |
| 1611 | pw.print(") "); pw.print(mSurfaceW); |
| 1612 | pw.print(" x "); pw.println(mSurfaceH); |
| 1613 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1614 | if (dumpAll) { |
| 1615 | pw.print(prefix); pw.print("mToken="); pw.println(mToken); |
| 1616 | pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); |
| 1617 | if (mAppToken != null) { |
| 1618 | pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); |
| 1619 | } |
| 1620 | if (mTargetAppToken != null) { |
| 1621 | pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); |
| 1622 | } |
| 1623 | pw.print(prefix); pw.print("mViewVisibility=0x"); |
| 1624 | pw.print(Integer.toHexString(mViewVisibility)); |
| 1625 | pw.print(" mLastHidden="); pw.print(mLastHidden); |
| 1626 | pw.print(" mHaveFrame="); pw.print(mHaveFrame); |
| 1627 | pw.print(" mObscured="); pw.println(mObscured); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 1628 | pw.print(prefix); pw.print("mSeq="); pw.print(mSeq); |
| 1629 | pw.print(" mSystemUiVisibility=0x"); |
| 1630 | pw.println(Integer.toHexString(mSystemUiVisibility)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1631 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1632 | if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { |
| 1633 | pw.print(prefix); pw.print("mPolicyVisibility="); |
| 1634 | pw.print(mPolicyVisibility); |
| 1635 | pw.print(" mPolicyVisibilityAfterAnim="); |
| 1636 | pw.print(mPolicyVisibilityAfterAnim); |
| 1637 | pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); |
| 1638 | } |
| 1639 | if (!mRelayoutCalled) { |
| 1640 | pw.print(prefix); pw.print("mRelayoutCalled="); pw.println(mRelayoutCalled); |
| 1641 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1642 | if (mXOffset != 0 || mYOffset != 0) { |
| 1643 | pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); |
| 1644 | pw.print(" y="); pw.println(mYOffset); |
| 1645 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1646 | if (dumpAll) { |
| 1647 | pw.print(prefix); pw.print("mGivenContentInsets="); |
| 1648 | mGivenContentInsets.printShortString(pw); |
| 1649 | pw.print(" mGivenVisibleInsets="); |
| 1650 | mGivenVisibleInsets.printShortString(pw); |
| 1651 | pw.println(); |
| 1652 | if (mTouchableInsets != 0 || mGivenInsetsPending) { |
| 1653 | pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); |
| 1654 | pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); |
| 1655 | } |
| 1656 | pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1657 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1658 | pw.print(prefix); pw.print("mShownFrame="); |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 1659 | mShownFrame.printShortString(pw); pw.println(); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1660 | if (dumpAll) { |
| 1661 | pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); |
| 1662 | pw.print(" last="); mLastFrame.printShortString(pw); |
| 1663 | pw.println(); |
| 1664 | } |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1665 | if (mEnforceSizeCompat) { |
| 1666 | pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1667 | pw.println(); |
| 1668 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1669 | if (dumpAll) { |
| 1670 | pw.print(prefix); pw.print("mContainingFrame="); |
| 1671 | mContainingFrame.printShortString(pw); |
| 1672 | pw.print(" mParentFrame="); |
| 1673 | mParentFrame.printShortString(pw); |
| 1674 | pw.print(" mDisplayFrame="); |
| 1675 | mDisplayFrame.printShortString(pw); |
| 1676 | pw.println(); |
| 1677 | pw.print(prefix); pw.print("mContentFrame="); mContentFrame.printShortString(pw); |
| 1678 | pw.print(" mVisibleFrame="); mVisibleFrame.printShortString(pw); |
| 1679 | pw.println(); |
| 1680 | pw.print(prefix); pw.print("mContentInsets="); mContentInsets.printShortString(pw); |
| 1681 | pw.print(" last="); mLastContentInsets.printShortString(pw); |
| 1682 | pw.print(" mVisibleInsets="); mVisibleInsets.printShortString(pw); |
| 1683 | pw.print(" last="); mLastVisibleInsets.printShortString(pw); |
| 1684 | pw.println(); |
| 1685 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1686 | if (mAnimating || mLocalAnimating || mAnimationIsEntrance |
| 1687 | || mAnimation != null) { |
| 1688 | pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); |
| 1689 | pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); |
| 1690 | pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); |
| 1691 | pw.print(" mAnimation="); pw.println(mAnimation); |
| 1692 | } |
| 1693 | if (mHasTransformation || mHasLocalTransformation) { |
| 1694 | pw.print(prefix); pw.print("XForm: has="); |
| 1695 | pw.print(mHasTransformation); |
| 1696 | pw.print(" hasLocal="); pw.print(mHasLocalTransformation); |
| 1697 | pw.print(" "); mTransformation.printShortString(pw); |
| 1698 | pw.println(); |
| 1699 | } |
| 1700 | if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { |
| 1701 | pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); |
| 1702 | pw.print(" mAlpha="); pw.print(mAlpha); |
| 1703 | pw.print(" mLastAlpha="); pw.println(mLastAlpha); |
| 1704 | } |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1705 | if (mHaveMatrix || mGlobalScale != 1) { |
| 1706 | pw.print(prefix); pw.print("mGlobalScale="); pw.print(mGlobalScale); |
| 1707 | pw.print(" mDsDx="); pw.print(mDsDx); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1708 | pw.print(" mDtDx="); pw.print(mDtDx); |
| 1709 | pw.print(" mDsDy="); pw.print(mDsDy); |
| 1710 | pw.print(" mDtDy="); pw.println(mDtDy); |
| 1711 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1712 | if (dumpAll) { |
| 1713 | pw.print(prefix); pw.print("mDrawPending="); pw.print(mDrawPending); |
| 1714 | pw.print(" mCommitDrawPending="); pw.print(mCommitDrawPending); |
| 1715 | pw.print(" mReadyToShow="); pw.print(mReadyToShow); |
| 1716 | pw.print(" mHasDrawn="); pw.println(mHasDrawn); |
| 1717 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1718 | if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { |
| 1719 | pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); |
| 1720 | pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); |
| 1721 | pw.print(" mDestroying="); pw.print(mDestroying); |
| 1722 | pw.print(" mRemoved="); pw.println(mRemoved); |
| 1723 | } |
| 1724 | if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { |
| 1725 | pw.print(prefix); pw.print("mOrientationChanging="); |
| 1726 | pw.print(mOrientationChanging); |
| 1727 | pw.print(" mAppFreezing="); pw.print(mAppFreezing); |
| 1728 | pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); |
| 1729 | } |
| 1730 | if (mHScale != 1 || mVScale != 1) { |
| 1731 | pw.print(prefix); pw.print("mHScale="); pw.print(mHScale); |
| 1732 | pw.print(" mVScale="); pw.println(mVScale); |
| 1733 | } |
| 1734 | if (mWallpaperX != -1 || mWallpaperY != -1) { |
| 1735 | pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); |
| 1736 | pw.print(" mWallpaperY="); pw.println(mWallpaperY); |
| 1737 | } |
| 1738 | if (mWallpaperXStep != -1 || mWallpaperYStep != -1) { |
| 1739 | pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep); |
| 1740 | pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep); |
| 1741 | } |
| 1742 | } |
| 1743 | |
| 1744 | String makeInputChannelName() { |
| 1745 | return Integer.toHexString(System.identityHashCode(this)) |
| 1746 | + " " + mAttrs.getTitle(); |
| 1747 | } |
| 1748 | |
| 1749 | @Override |
| 1750 | public String toString() { |
| 1751 | if (mStringNameCache == null || mLastTitle != mAttrs.getTitle() |
| 1752 | || mWasPaused != mToken.paused) { |
| 1753 | mLastTitle = mAttrs.getTitle(); |
| 1754 | mWasPaused = mToken.paused; |
| 1755 | mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this)) |
| 1756 | + " " + mLastTitle + " paused=" + mWasPaused + "}"; |
| 1757 | } |
| 1758 | return mStringNameCache; |
| 1759 | } |
satok | cef37fb | 2011-10-24 21:49:38 +0900 | [diff] [blame] | 1760 | } |