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