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