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