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