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 | |
Wale Ogunwale | f9c8149 | 2015-02-25 18:06:17 -0800 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 20 | import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 21 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; |
Wale Ogunwale | f9c8149 | 2015-02-25 18:06:17 -0800 | [diff] [blame] | 22 | import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; |
| 23 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
Wale Ogunwale | f9c8149 | 2015-02-25 18:06:17 -0800 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 25 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
| 26 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 27 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 28 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 29 | import static com.android.server.wm.WindowManagerService.DEBUG_CONFIGURATION; |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 30 | import static com.android.server.wm.WindowManagerService.DEBUG_LAYOUT; |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 31 | import static com.android.server.wm.WindowManagerService.DEBUG_ORIENTATION; |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 32 | import static com.android.server.wm.WindowManagerService.DEBUG_POWER; |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 33 | import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE; |
| 34 | import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 36 | import android.app.AppOpsManager; |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 37 | import android.os.PowerManager; |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 38 | import android.os.RemoteCallbackList; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 39 | import android.os.SystemClock; |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 40 | import android.os.WorkSource; |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 41 | import android.util.DisplayMetrics; |
Dianne Hackborn | a57c695 | 2013-03-29 14:46:40 -0700 | [diff] [blame] | 42 | import android.util.TimeUtils; |
Svetoslav | 4604abc | 2014-06-10 18:59:30 -0700 | [diff] [blame] | 43 | import android.view.Display; |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 44 | import android.view.IWindowFocusObserver; |
| 45 | import android.view.IWindowId; |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 46 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 47 | import com.android.server.input.InputWindowHandle; |
| 48 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 49 | import android.content.Context; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 50 | import android.content.res.Configuration; |
| 51 | import android.graphics.Matrix; |
| 52 | import android.graphics.PixelFormat; |
| 53 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 54 | import android.graphics.RectF; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 55 | import android.graphics.Region; |
| 56 | import android.os.IBinder; |
| 57 | import android.os.RemoteException; |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 58 | import android.os.UserHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 59 | import android.util.Slog; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 60 | import android.view.DisplayInfo; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 61 | import android.view.Gravity; |
| 62 | import android.view.IApplicationToken; |
| 63 | import android.view.IWindow; |
| 64 | import android.view.InputChannel; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 65 | import android.view.View; |
| 66 | import android.view.ViewTreeObserver; |
| 67 | import android.view.WindowManager; |
| 68 | import android.view.WindowManagerPolicy; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 69 | |
| 70 | import java.io.PrintWriter; |
| 71 | import java.util.ArrayList; |
| 72 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 73 | class WindowList extends ArrayList<WindowState> { |
| 74 | } |
| 75 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 76 | /** |
| 77 | * A window in the window manager. |
| 78 | */ |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 79 | final class WindowState implements WindowManagerPolicy.WindowState { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 80 | static final String TAG = "WindowState"; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 81 | |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 82 | // The minimal size of a window within the usable area of the freeform stack. |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 83 | // TODO(multi-window): fix the min sizes when we have mininum width/height support, |
| 84 | // use hard-coded min sizes for now. |
| 85 | static final int MINIMUM_VISIBLE_WIDTH_IN_DP = 48; |
| 86 | static final int MINIMUM_VISIBLE_HEIGHT_IN_DP = 32; |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 87 | |
| 88 | // The thickness of a window resize handle outside the window bounds on the free form workspace |
| 89 | // to capture touch events in that area. |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 90 | static final int RESIZE_HANDLE_WIDTH_IN_DP = 30; |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 91 | |
| 92 | static final boolean BOUNDS_FOR_TOUCH = true; |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 93 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 94 | final WindowManagerService mService; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 95 | final WindowManagerPolicy mPolicy; |
| 96 | final Context mContext; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 97 | final Session mSession; |
| 98 | final IWindow mClient; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 99 | final int mAppOp; |
| 100 | // UserId and appId of the owner. Don't display windows of non-current user. |
| 101 | final int mOwnerUid; |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 102 | final IWindowId mWindowId; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 103 | WindowToken mToken; |
| 104 | WindowToken mRootToken; |
| 105 | AppWindowToken mAppToken; |
| 106 | AppWindowToken mTargetAppToken; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 107 | |
| 108 | // mAttrs.flags is tested in animation without being locked. If the bits tested are ever |
| 109 | // modified they will need to be locked. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 110 | final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams(); |
| 111 | final DeathRecipient mDeathRecipient; |
| 112 | final WindowState mAttachedWindow; |
Craig Mautner | 7b1aa77 | 2012-11-30 16:14:45 -0800 | [diff] [blame] | 113 | final WindowList mChildWindows = new WindowList(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 114 | final int mBaseLayer; |
| 115 | final int mSubLayer; |
| 116 | final boolean mLayoutAttached; |
| 117 | final boolean mIsImWindow; |
| 118 | final boolean mIsWallpaper; |
| 119 | final boolean mIsFloatingLayer; |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 120 | int mSeq; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 121 | boolean mEnforceSizeCompat; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 122 | int mViewVisibility; |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 123 | int mSystemUiVisibility; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 124 | boolean mPolicyVisibility = true; |
| 125 | boolean mPolicyVisibilityAfterAnim = true; |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 126 | boolean mAppOpVisibility = true; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 127 | boolean mAppFreezing; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 128 | boolean mAttachedHidden; // is our parent window hidden? |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 129 | boolean mWallpaperVisible; // for wallpaper, what was last vis report? |
Chong Zhang | 0275e39 | 2015-09-17 10:41:44 -0700 | [diff] [blame^] | 130 | boolean mDragResizing; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 131 | |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 132 | RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks; |
| 133 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 134 | /** |
| 135 | * The window size that was requested by the application. These are in |
| 136 | * the application's coordinate space (without compatibility scale applied). |
| 137 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 138 | int mRequestedWidth; |
| 139 | int mRequestedHeight; |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 140 | int mLastRequestedWidth; |
| 141 | int mLastRequestedHeight; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 142 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 143 | int mLayer; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 144 | boolean mHaveFrame; |
| 145 | boolean mObscured; |
| 146 | boolean mTurnOnScreen; |
| 147 | |
| 148 | int mLayoutSeq = -1; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 149 | |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 150 | private Configuration mConfiguration = Configuration.EMPTY; |
| 151 | private Configuration mOverrideConfig = Configuration.EMPTY; |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 152 | // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned. |
| 153 | // Used only on {@link #TYPE_KEYGUARD}. |
| 154 | private boolean mConfigHasChanged; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 155 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Actual frame shown on-screen (may be modified by animation). These |
| 158 | * are in the screen's coordinate space (WITH the compatibility scale |
| 159 | * applied). |
| 160 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 161 | final RectF mShownFrame = new RectF(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 162 | |
| 163 | /** |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 164 | * Insets that determine the actually visible area. These are in the application's |
| 165 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 166 | */ |
| 167 | final Rect mVisibleInsets = new Rect(); |
| 168 | final Rect mLastVisibleInsets = new Rect(); |
| 169 | boolean mVisibleInsetsChanged; |
| 170 | |
| 171 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 172 | * Insets that are covered by system windows (such as the status bar) and |
| 173 | * 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] | 174 | * coordinate space (without compatibility scale applied). |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 175 | */ |
| 176 | final Rect mContentInsets = new Rect(); |
| 177 | final Rect mLastContentInsets = new Rect(); |
| 178 | boolean mContentInsetsChanged; |
| 179 | |
| 180 | /** |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 181 | * Insets that determine the area covered by the display overscan region. These are in the |
| 182 | * application's coordinate space (without compatibility scale applied). |
| 183 | */ |
| 184 | final Rect mOverscanInsets = new Rect(); |
| 185 | final Rect mLastOverscanInsets = new Rect(); |
| 186 | boolean mOverscanInsetsChanged; |
| 187 | |
| 188 | /** |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 189 | * Insets that determine the area covered by the stable system windows. These are in the |
| 190 | * application's coordinate space (without compatibility scale applied). |
| 191 | */ |
| 192 | final Rect mStableInsets = new Rect(); |
| 193 | final Rect mLastStableInsets = new Rect(); |
| 194 | boolean mStableInsetsChanged; |
| 195 | |
| 196 | /** |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 197 | * Outsets determine the area outside of the surface where we want to pretend that it's possible |
| 198 | * to draw anyway. |
| 199 | */ |
| 200 | final Rect mOutsets = new Rect(); |
| 201 | final Rect mLastOutsets = new Rect(); |
| 202 | boolean mOutsetsChanged = false; |
| 203 | |
| 204 | /** |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 205 | * Set to true if we are waiting for this window to receive its |
| 206 | * given internal insets before laying out other windows based on it. |
| 207 | */ |
| 208 | boolean mGivenInsetsPending; |
| 209 | |
| 210 | /** |
| 211 | * These are the content insets that were given during layout for |
| 212 | * this window, to be applied to windows behind it. |
| 213 | */ |
| 214 | final Rect mGivenContentInsets = new Rect(); |
| 215 | |
| 216 | /** |
| 217 | * These are the visible insets that were given during layout for |
| 218 | * this window, to be applied to windows behind it. |
| 219 | */ |
| 220 | final Rect mGivenVisibleInsets = new Rect(); |
| 221 | |
| 222 | /** |
| 223 | * This is the given touchable area relative to the window frame, or null if none. |
| 224 | */ |
| 225 | final Region mGivenTouchableRegion = new Region(); |
| 226 | |
| 227 | /** |
| 228 | * Flag indicating whether the touchable region should be adjusted by |
| 229 | * the visible insets; if false the area outside the visible insets is |
| 230 | * NOT touchable, so we must use those to adjust the frame during hit |
| 231 | * tests. |
| 232 | */ |
| 233 | int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; |
| 234 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 235 | /** |
| 236 | * This is rectangle of the window's surface that is not covered by |
| 237 | * system decorations. |
| 238 | */ |
| 239 | final Rect mSystemDecorRect = new Rect(); |
| 240 | final Rect mLastSystemDecorRect = new Rect(); |
| 241 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 242 | // Current transformation being applied. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 243 | float mGlobalScale=1; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 244 | float mInvGlobalScale=1; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 245 | float mHScale=1, mVScale=1; |
| 246 | float mLastHScale=1, mLastVScale=1; |
| 247 | final Matrix mTmpMatrix = new Matrix(); |
| 248 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 249 | // "Real" frame that the application sees, in display coordinate space. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 250 | final Rect mFrame = new Rect(); |
| 251 | final Rect mLastFrame = new Rect(); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 252 | // Frame that is scaled to the application's coordinate space when in |
| 253 | // screen size compatibility mode. |
| 254 | final Rect mCompatFrame = new Rect(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 255 | |
| 256 | final Rect mContainingFrame = new Rect(); |
Wale Ogunwale | c6061fa | 2014-10-21 13:15:11 -0700 | [diff] [blame] | 257 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 258 | final Rect mParentFrame = new Rect(); |
Wale Ogunwale | c6061fa | 2014-10-21 13:15:11 -0700 | [diff] [blame] | 259 | |
Wale Ogunwale | 9459665 | 2015-02-06 19:27:34 -0800 | [diff] [blame] | 260 | // The entire screen area of the {@link TaskStack} this window is in. Usually equal to the |
| 261 | // screen area of the device. |
Wale Ogunwale | c6061fa | 2014-10-21 13:15:11 -0700 | [diff] [blame] | 262 | final Rect mDisplayFrame = new Rect(); |
| 263 | |
| 264 | // The region of the display frame that the display type supports displaying content on. This |
| 265 | // is mostly a special case for TV where some displays don’t have the entire display usable. |
| 266 | // {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_OVERSCAN} flag can be used to allow |
| 267 | // window display contents to extend into the overscan region. |
| 268 | final Rect mOverscanFrame = new Rect(); |
| 269 | |
| 270 | // The display frame minus the stable insets. This value is always constant regardless of if |
| 271 | // the status bar or navigation bar is visible. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 272 | final Rect mStableFrame = new Rect(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 273 | |
Wale Ogunwale | c6061fa | 2014-10-21 13:15:11 -0700 | [diff] [blame] | 274 | // The area not occupied by the status and navigation bars. So, if both status and navigation |
| 275 | // bars are visible, the decor frame is equal to the stable frame. |
| 276 | final Rect mDecorFrame = new Rect(); |
| 277 | |
| 278 | // Equal to the decor frame if the IME (e.g. keyboard) is not present. Equal to the decor frame |
| 279 | // minus the area occupied by the IME if the IME is present. |
| 280 | final Rect mContentFrame = new Rect(); |
| 281 | |
| 282 | // Legacy stuff. Generally equal to the content frame expect when the IME for older apps |
| 283 | // displays hint text. |
| 284 | final Rect mVisibleFrame = new Rect(); |
| 285 | |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 286 | // Frame that includes dead area outside of the surface but where we want to pretend that it's |
| 287 | // possible to draw. |
| 288 | final Rect mOutsetFrame = new Rect(); |
| 289 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 290 | boolean mContentChanged; |
| 291 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 292 | // If a window showing a wallpaper: the requested offset for the |
| 293 | // wallpaper; if a wallpaper window: the currently applied offset. |
| 294 | float mWallpaperX = -1; |
| 295 | float mWallpaperY = -1; |
| 296 | |
| 297 | // If a window showing a wallpaper: what fraction of the offset |
| 298 | // range corresponds to a full virtual screen. |
| 299 | float mWallpaperXStep = -1; |
| 300 | float mWallpaperYStep = -1; |
| 301 | |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 302 | // If a window showing a wallpaper: a raw pixel offset to forcibly apply |
| 303 | // to its window; if a wallpaper window: not used. |
| 304 | int mWallpaperDisplayOffsetX = Integer.MIN_VALUE; |
| 305 | int mWallpaperDisplayOffsetY = Integer.MIN_VALUE; |
| 306 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 307 | // Wallpaper windows: pixels offset based on above variables. |
| 308 | int mXOffset; |
| 309 | int mYOffset; |
| 310 | |
Craig Mautner | 2268e7e | 2012-12-13 15:40:00 -0800 | [diff] [blame] | 311 | /** |
| 312 | * This is set after IWindowSession.relayout() has been called at |
| 313 | * least once for the window. It allows us to detect the situation |
| 314 | * where we don't yet have a surface, but should have one soon, so |
| 315 | * we can give the window focus before waiting for the relayout. |
| 316 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 317 | boolean mRelayoutCalled; |
| 318 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 319 | /** |
| 320 | * If the application has called relayout() with changes that can |
| 321 | * impact its window's size, we need to perform a layout pass on it |
| 322 | * even if it is not currently visible for layout. This is set |
| 323 | * when in that case until the layout is done. |
| 324 | */ |
Dianne Hackborn | b7ff51b | 2012-01-23 19:15:27 -0800 | [diff] [blame] | 325 | boolean mLayoutNeeded; |
| 326 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 327 | /** Currently running an exit animation? */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 328 | boolean mExiting; |
| 329 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 330 | /** Currently on the mDestroySurface list? */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 331 | boolean mDestroying; |
| 332 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 333 | /** Completely remove from window manager after exit animation? */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 334 | boolean mRemoveOnExit; |
| 335 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 336 | /** |
| 337 | * Set when the orientation is changing and this window has not yet |
| 338 | * been updated for the new orientation. |
| 339 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 340 | boolean mOrientationChanging; |
| 341 | |
Dianne Hackborn | a57c695 | 2013-03-29 14:46:40 -0700 | [diff] [blame] | 342 | /** |
| 343 | * How long we last kept the screen frozen. |
| 344 | */ |
| 345 | int mLastFreezeDuration; |
| 346 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 347 | /** Is this window now (or just being) removed? */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 348 | boolean mRemoved; |
| 349 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 350 | /** |
| 351 | * Temp for keeping track of windows that have been removed when |
| 352 | * rebuilding window list. |
| 353 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 354 | boolean mRebuilding; |
| 355 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 356 | // Input channel and input window handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 357 | final InputWindowHandle mInputWindowHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 358 | InputChannel mInputChannel; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 359 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 360 | // Used to improve performance of toString() |
| 361 | String mStringNameCache; |
| 362 | CharSequence mLastTitle; |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 363 | boolean mWasExiting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 364 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 365 | final WindowStateAnimator mWinAnimator; |
| 366 | |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 367 | boolean mHasSurface = false; |
| 368 | |
Craig Mautner | 19ab828 | 2014-05-07 10:35:34 -0700 | [diff] [blame] | 369 | boolean mNotOnAppsDisplay = false; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 370 | DisplayContent mDisplayContent; |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 371 | |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 372 | /** When true this window can be displayed on screens owther than mOwnerUid's */ |
| 373 | private boolean mShowToOwnerOnly; |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 374 | |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 375 | /** |
| 376 | * Wake lock for drawing. |
| 377 | * Even though it's slightly more expensive to do so, we will use a separate wake lock |
| 378 | * for each app that is requesting to draw while dozing so that we can accurately track |
| 379 | * who is preventing the system from suspending. |
| 380 | * This lock is only acquired on first use. |
| 381 | */ |
| 382 | PowerManager.WakeLock mDrawLock; |
| 383 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 384 | WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 385 | WindowState attachedWindow, int appOp, int seq, WindowManager.LayoutParams a, |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 386 | int viewVisibility, final DisplayContent displayContent) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 387 | mService = service; |
| 388 | mSession = s; |
| 389 | mClient = c; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 390 | mAppOp = appOp; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 391 | mToken = token; |
Craig Mautner | a2d7b11 | 2012-08-21 15:12:20 -0700 | [diff] [blame] | 392 | mOwnerUid = s.mUid; |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 393 | mWindowId = new IWindowId.Stub() { |
| 394 | @Override |
| 395 | public void registerFocusObserver(IWindowFocusObserver observer) { |
| 396 | WindowState.this.registerFocusObserver(observer); |
| 397 | } |
| 398 | @Override |
| 399 | public void unregisterFocusObserver(IWindowFocusObserver observer) { |
| 400 | WindowState.this.unregisterFocusObserver(observer); |
| 401 | } |
| 402 | @Override |
| 403 | public boolean isFocused() { |
| 404 | return WindowState.this.isFocused(); |
| 405 | } |
| 406 | }; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 407 | mAttrs.copyFrom(a); |
| 408 | mViewVisibility = viewVisibility; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 409 | mDisplayContent = displayContent; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 410 | mPolicy = mService.mPolicy; |
| 411 | mContext = mService.mContext; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 412 | DeathRecipient deathRecipient = new DeathRecipient(); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 413 | mSeq = seq; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 414 | mEnforceSizeCompat = (mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 415 | if (WindowManagerService.localLOGV) Slog.v( |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 416 | TAG, "Window " + this + " client=" + c.asBinder() |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 417 | + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 418 | try { |
| 419 | c.asBinder().linkToDeath(deathRecipient, 0); |
| 420 | } catch (RemoteException e) { |
| 421 | mDeathRecipient = null; |
| 422 | mAttachedWindow = null; |
| 423 | mLayoutAttached = false; |
| 424 | mIsImWindow = false; |
| 425 | mIsWallpaper = false; |
| 426 | mIsFloatingLayer = false; |
| 427 | mBaseLayer = 0; |
| 428 | mSubLayer = 0; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 429 | mInputWindowHandle = null; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 430 | mWinAnimator = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 431 | return; |
| 432 | } |
| 433 | mDeathRecipient = deathRecipient; |
| 434 | |
| 435 | if ((mAttrs.type >= FIRST_SUB_WINDOW && |
| 436 | mAttrs.type <= LAST_SUB_WINDOW)) { |
| 437 | // The multiplier here is to reserve space for multiple |
| 438 | // windows in the same type layer. |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 439 | mBaseLayer = mPolicy.windowTypeToLayerLw( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 440 | attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 441 | + WindowManagerService.TYPE_LAYER_OFFSET; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 442 | mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 443 | mAttachedWindow = attachedWindow; |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 444 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); |
takeda.masayuki | 1873509 | 2012-12-12 11:06:24 +0900 | [diff] [blame] | 445 | |
tiger_huang | e2a98a7 | 2014-11-13 19:46:28 +0800 | [diff] [blame] | 446 | final WindowList childWindows = mAttachedWindow.mChildWindows; |
| 447 | final int numChildWindows = childWindows.size(); |
| 448 | if (numChildWindows == 0) { |
| 449 | childWindows.add(this); |
takeda.masayuki | 1873509 | 2012-12-12 11:06:24 +0900 | [diff] [blame] | 450 | } else { |
tiger_huang | e2a98a7 | 2014-11-13 19:46:28 +0800 | [diff] [blame] | 451 | boolean added = false; |
| 452 | for (int i = 0; i < numChildWindows; i++) { |
| 453 | final int childSubLayer = childWindows.get(i).mSubLayer; |
| 454 | if (mSubLayer < childSubLayer |
| 455 | || (mSubLayer == childSubLayer && childSubLayer < 0)) { |
| 456 | // We insert the child window into the list ordered by the sub-layer. For |
| 457 | // same sub-layers, the negative one should go below others; the positive |
| 458 | // one should go above others. |
| 459 | childWindows.add(i, this); |
| 460 | added = true; |
takeda.masayuki | 1873509 | 2012-12-12 11:06:24 +0900 | [diff] [blame] | 461 | break; |
takeda.masayuki | 1873509 | 2012-12-12 11:06:24 +0900 | [diff] [blame] | 462 | } |
| 463 | } |
tiger_huang | e2a98a7 | 2014-11-13 19:46:28 +0800 | [diff] [blame] | 464 | if (!added) { |
| 465 | childWindows.add(this); |
takeda.masayuki | 1873509 | 2012-12-12 11:06:24 +0900 | [diff] [blame] | 466 | } |
| 467 | } |
| 468 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 469 | mLayoutAttached = mAttrs.type != |
| 470 | WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 471 | mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD |
| 472 | || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 473 | mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER; |
| 474 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 475 | } else { |
| 476 | // The multiplier here is to reserve space for multiple |
| 477 | // windows in the same type layer. |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 478 | mBaseLayer = mPolicy.windowTypeToLayerLw(a.type) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 479 | * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 480 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 481 | mSubLayer = 0; |
| 482 | mAttachedWindow = null; |
| 483 | mLayoutAttached = false; |
| 484 | mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD |
| 485 | || mAttrs.type == TYPE_INPUT_METHOD_DIALOG; |
| 486 | mIsWallpaper = mAttrs.type == TYPE_WALLPAPER; |
| 487 | mIsFloatingLayer = mIsImWindow || mIsWallpaper; |
| 488 | } |
| 489 | |
| 490 | WindowState appWin = this; |
| 491 | while (appWin.mAttachedWindow != null) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 492 | appWin = appWin.mAttachedWindow; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 493 | } |
| 494 | WindowToken appToken = appWin.mToken; |
| 495 | while (appToken.appWindowToken == null) { |
| 496 | WindowToken parent = mService.mTokenMap.get(appToken.token); |
| 497 | if (parent == null || appToken == parent) { |
| 498 | break; |
| 499 | } |
| 500 | appToken = parent; |
| 501 | } |
| 502 | mRootToken = appToken; |
| 503 | mAppToken = appToken.appWindowToken; |
Craig Mautner | 19ab828 | 2014-05-07 10:35:34 -0700 | [diff] [blame] | 504 | if (mAppToken != null) { |
| 505 | final DisplayContent appDisplay = getDisplayContent(); |
| 506 | mNotOnAppsDisplay = displayContent != appDisplay; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 507 | |
| 508 | if (mAppToken.showForAllUsers) { |
| 509 | // Windows for apps that can show for all users should also show when the |
| 510 | // device is locked. |
| 511 | mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED; |
| 512 | } |
Craig Mautner | 19ab828 | 2014-05-07 10:35:34 -0700 | [diff] [blame] | 513 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 514 | |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 515 | mWinAnimator = new WindowStateAnimator(this); |
| 516 | mWinAnimator.mAlpha = a.alpha; |
| 517 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 518 | mRequestedWidth = 0; |
| 519 | mRequestedHeight = 0; |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 520 | mLastRequestedWidth = 0; |
| 521 | mLastRequestedHeight = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 522 | mXOffset = 0; |
| 523 | mYOffset = 0; |
| 524 | mLayer = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 525 | mInputWindowHandle = new InputWindowHandle( |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 526 | mAppToken != null ? mAppToken.mInputApplicationHandle : null, this, |
| 527 | displayContent.getDisplayId()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | void attach() { |
| 531 | if (WindowManagerService.localLOGV) Slog.v( |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 532 | TAG, "Attaching " + this + " token=" + mToken |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 533 | + ", list=" + mToken.windows); |
| 534 | mSession.windowAddedLocked(); |
| 535 | } |
| 536 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 537 | @Override |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 538 | public int getOwningUid() { |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 539 | return mOwnerUid; |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | @Override |
| 543 | public String getOwningPackage() { |
| 544 | return mAttrs.packageName; |
| 545 | } |
| 546 | |
| 547 | @Override |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 548 | public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf, |
| 549 | Rect osf) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 550 | if (mAppToken != null && mAppToken.mReplacingWindow |
| 551 | && (mExiting || !mAppToken.mReplacingRemoveRequested)) { |
| 552 | // This window is being replaced and either already got information that it's being |
| 553 | // removed or we are still waiting for some information. Because of this we don't |
| 554 | // want to apply any more changes to it, so it remains in this state until new window |
| 555 | // appears. |
| 556 | return; |
| 557 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 558 | mHaveFrame = true; |
| 559 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 560 | final Task task = mAppToken != null ? getTask() : null; |
| 561 | final boolean nonFullscreenTask = task != null && !task.isFullscreen(); |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 562 | final boolean freeformWorkspace = task != null && task.inFreeformWorkspace(); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 563 | if (nonFullscreenTask) { |
| 564 | task.getBounds(mContainingFrame); |
Wale Ogunwale | f9c8149 | 2015-02-25 18:06:17 -0800 | [diff] [blame] | 565 | final WindowState imeWin = mService.mInputMethodWindow; |
| 566 | if (imeWin != null && imeWin.isVisibleNow() && mService.mInputMethodTarget == this |
| 567 | && mContainingFrame.bottom > cf.bottom) { |
| 568 | // IME is up and obscuring this window. Adjust the window position so it is visible. |
| 569 | mContainingFrame.top -= mContainingFrame.bottom - cf.bottom; |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 570 | } |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 571 | |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 572 | if (freeformWorkspace) { |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 573 | // In free form mode we have only to set the rectangle if it wasn't set already. No |
| 574 | // need to intersect it with the (visible) "content frame" since it is allowed to |
| 575 | // be outside the visible desktop. |
| 576 | if (mContainingFrame.isEmpty()) { |
| 577 | mContainingFrame.set(cf); |
| 578 | } |
| 579 | } else { |
| 580 | // Make sure the containing frame is within the content frame so we don't layout |
| 581 | // resized window under screen decorations. |
| 582 | if (!mContainingFrame.intersect(cf)) { |
| 583 | mContainingFrame.set(cf); |
| 584 | } |
Doris Liu | 06d582d | 2015-06-01 13:18:43 -0700 | [diff] [blame] | 585 | } |
Wale Ogunwale | 9459665 | 2015-02-06 19:27:34 -0800 | [diff] [blame] | 586 | mDisplayFrame.set(mContainingFrame); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 587 | } else { |
| 588 | mContainingFrame.set(pf); |
Wale Ogunwale | 9459665 | 2015-02-06 19:27:34 -0800 | [diff] [blame] | 589 | mDisplayFrame.set(df); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 590 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 591 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 592 | final int pw = mContainingFrame.width(); |
| 593 | final int ph = mContainingFrame.height(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 594 | |
| 595 | int w,h; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 596 | if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) { |
| 597 | if (mAttrs.width < 0) { |
| 598 | w = pw; |
| 599 | } else if (mEnforceSizeCompat) { |
| 600 | w = (int)(mAttrs.width * mGlobalScale + .5f); |
| 601 | } else { |
| 602 | w = mAttrs.width; |
| 603 | } |
| 604 | if (mAttrs.height < 0) { |
| 605 | h = ph; |
| 606 | } else if (mEnforceSizeCompat) { |
| 607 | h = (int)(mAttrs.height * mGlobalScale + .5f); |
| 608 | } else { |
| 609 | h = mAttrs.height; |
| 610 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 611 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 612 | if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) { |
| 613 | w = pw; |
| 614 | } else if (mEnforceSizeCompat) { |
| 615 | w = (int)(mRequestedWidth * mGlobalScale + .5f); |
| 616 | } else { |
| 617 | w = mRequestedWidth; |
| 618 | } |
| 619 | if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 620 | h = ph; |
| 621 | } else if (mEnforceSizeCompat) { |
| 622 | h = (int)(mRequestedHeight * mGlobalScale + .5f); |
| 623 | } else { |
| 624 | h = mRequestedHeight; |
| 625 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | if (!mParentFrame.equals(pf)) { |
| 629 | //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame |
| 630 | // + " to " + pf); |
| 631 | mParentFrame.set(pf); |
| 632 | mContentChanged = true; |
| 633 | } |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 634 | if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { |
| 635 | mLastRequestedWidth = mRequestedWidth; |
| 636 | mLastRequestedHeight = mRequestedHeight; |
| 637 | mContentChanged = true; |
| 638 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 639 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 640 | mOverscanFrame.set(of); |
| 641 | mContentFrame.set(cf); |
| 642 | mVisibleFrame.set(vf); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 643 | mDecorFrame.set(dcf); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 644 | mStableFrame.set(sf); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 645 | final boolean hasOutsets = osf != null; |
| 646 | if (hasOutsets) { |
| 647 | mOutsetFrame.set(osf); |
| 648 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 649 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 650 | final int fw = mFrame.width(); |
| 651 | final int fh = mFrame.height(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 652 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 653 | float x, y; |
| 654 | if (mEnforceSizeCompat) { |
| 655 | x = mAttrs.x * mGlobalScale; |
| 656 | y = mAttrs.y * mGlobalScale; |
| 657 | } else { |
| 658 | x = mAttrs.x; |
| 659 | y = mAttrs.y; |
| 660 | } |
| 661 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 662 | if (nonFullscreenTask) { |
Wale Ogunwale | b171abb | 2015-04-22 12:47:17 -0700 | [diff] [blame] | 663 | // Make sure window fits in containing frame since it is in a non-fullscreen stack as |
| 664 | // required by {@link Gravity#apply} call. |
| 665 | w = Math.min(w, pw); |
| 666 | h = Math.min(h, ph); |
| 667 | } |
| 668 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 669 | Gravity.apply(mAttrs.gravity, w, h, mContainingFrame, |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 670 | (int) (x + mAttrs.horizontalMargin * pw), |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 671 | (int) (y + mAttrs.verticalMargin * ph), mFrame); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 672 | |
Wale Ogunwale | 9459665 | 2015-02-06 19:27:34 -0800 | [diff] [blame] | 673 | // Now make sure the window fits in the overall display frame. |
| 674 | Gravity.applyDisplay(mAttrs.gravity, mDisplayFrame, mFrame); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 675 | |
Filip Gruszczynski | aaf1811 | 2015-06-05 13:37:40 -0700 | [diff] [blame] | 676 | // Calculate the outsets before the content frame gets shrinked to the window frame. |
| 677 | if (hasOutsets) { |
| 678 | mOutsets.set(Math.max(mContentFrame.left - mOutsetFrame.left, 0), |
| 679 | Math.max(mContentFrame.top - mOutsetFrame.top, 0), |
| 680 | Math.max(mOutsetFrame.right - mContentFrame.right, 0), |
| 681 | Math.max(mOutsetFrame.bottom - mContentFrame.bottom, 0)); |
| 682 | } else { |
| 683 | mOutsets.set(0, 0, 0, 0); |
| 684 | } |
| 685 | |
Craig Mautner | a248eee | 2013-05-07 11:41:27 -0700 | [diff] [blame] | 686 | // Make sure the content and visible frames are inside of the |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 687 | // final window frame. |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 688 | if (freeformWorkspace && !mFrame.isEmpty()) { |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 689 | // Keep the frame out of the blocked system area, limit it in size to the content area |
| 690 | // and make sure that there is always a minimum visible so that the user can drag it |
| 691 | // into a usable area.. |
| 692 | final int height = Math.min(mFrame.height(), mContentFrame.height()); |
| 693 | final int width = Math.min(mContentFrame.width(), mFrame.width()); |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 694 | final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); |
| 695 | final int minVisibleHeight = |
| 696 | mService.dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, displayMetrics); |
| 697 | final int minVisibleWidth = |
| 698 | mService.dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, displayMetrics); |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 699 | final int top = Math.max(mContentFrame.top, |
| 700 | Math.min(mFrame.top, mContentFrame.bottom - minVisibleHeight)); |
| 701 | final int left = Math.max(mContentFrame.left + minVisibleWidth - width, |
| 702 | Math.min(mFrame.left, mContentFrame.right - minVisibleWidth)); |
| 703 | mFrame.set(left, top, left + width, top + height); |
| 704 | mContentFrame.set(mFrame); |
| 705 | mVisibleFrame.set(mContentFrame); |
| 706 | mStableFrame.set(mContentFrame); |
| 707 | } else { |
| 708 | mContentFrame.set(Math.max(mContentFrame.left, mFrame.left), |
| 709 | Math.max(mContentFrame.top, mFrame.top), |
| 710 | Math.min(mContentFrame.right, mFrame.right), |
| 711 | Math.min(mContentFrame.bottom, mFrame.bottom)); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 712 | |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 713 | mVisibleFrame.set(Math.max(mVisibleFrame.left, mFrame.left), |
| 714 | Math.max(mVisibleFrame.top, mFrame.top), |
| 715 | Math.min(mVisibleFrame.right, mFrame.right), |
| 716 | Math.min(mVisibleFrame.bottom, mFrame.bottom)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 717 | |
Skuhne | 81c524a | 2015-08-12 13:34:14 -0700 | [diff] [blame] | 718 | mStableFrame.set(Math.max(mStableFrame.left, mFrame.left), |
| 719 | Math.max(mStableFrame.top, mFrame.top), |
| 720 | Math.min(mStableFrame.right, mFrame.right), |
| 721 | Math.min(mStableFrame.bottom, mFrame.bottom)); |
| 722 | } |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 723 | |
Craig Mautner | c36c8e6 | 2013-05-10 13:33:31 -0700 | [diff] [blame] | 724 | mOverscanInsets.set(Math.max(mOverscanFrame.left - mFrame.left, 0), |
| 725 | Math.max(mOverscanFrame.top - mFrame.top, 0), |
Adrian Roos | 3236f3a | 2014-12-09 15:06:40 +0000 | [diff] [blame] | 726 | Math.max(mFrame.right - mOverscanFrame.right, 0), |
| 727 | Math.max(mFrame.bottom - mOverscanFrame.bottom, 0)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 728 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 729 | mContentInsets.set(mContentFrame.left - mFrame.left, |
| 730 | mContentFrame.top - mFrame.top, |
| 731 | mFrame.right - mContentFrame.right, |
| 732 | mFrame.bottom - mContentFrame.bottom); |
| 733 | |
| 734 | mVisibleInsets.set(mVisibleFrame.left - mFrame.left, |
| 735 | mVisibleFrame.top - mFrame.top, |
| 736 | mFrame.right - mVisibleFrame.right, |
| 737 | mFrame.bottom - mVisibleFrame.bottom); |
| 738 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 739 | mStableInsets.set(Math.max(mStableFrame.left - mFrame.left, 0), |
| 740 | Math.max(mStableFrame.top - mFrame.top, 0), |
| 741 | Math.max(mFrame.right - mStableFrame.right, 0), |
| 742 | Math.max(mFrame.bottom - mStableFrame.bottom, 0)); |
| 743 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 744 | mCompatFrame.set(mFrame); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 745 | if (mEnforceSizeCompat) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 746 | // If there is a size compatibility scale being applied to the |
| 747 | // window, we need to apply this to its insets so that they are |
| 748 | // reported to the app in its coordinate space. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 749 | mOverscanInsets.scale(mInvGlobalScale); |
| 750 | mContentInsets.scale(mInvGlobalScale); |
| 751 | mVisibleInsets.scale(mInvGlobalScale); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 752 | mStableInsets.scale(mInvGlobalScale); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 753 | mOutsets.scale(mInvGlobalScale); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 754 | |
| 755 | // Also the scaled frame that we report to the app needs to be |
| 756 | // adjusted to be in its coordinate space. |
| 757 | mCompatFrame.scale(mInvGlobalScale); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 758 | } |
| 759 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 760 | if (mIsWallpaper && (fw != mFrame.width() || fh != mFrame.height())) { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 761 | final DisplayContent displayContent = getDisplayContent(); |
| 762 | if (displayContent != null) { |
| 763 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 764 | mService.mWallpaperControllerLocked.updateWallpaperOffset( |
| 765 | this, displayInfo.logicalWidth, displayInfo.logicalHeight, false); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 766 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 767 | } |
| 768 | |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 769 | if (DEBUG_LAYOUT || WindowManagerService.localLOGV) Slog.v(TAG, |
| 770 | "Resolving (mRequestedWidth=" |
| 771 | + mRequestedWidth + ", mRequestedheight=" |
| 772 | + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph |
| 773 | + "): frame=" + mFrame.toShortString() |
| 774 | + " ci=" + mContentInsets.toShortString() |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 775 | + " vi=" + mVisibleInsets.toShortString() |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 776 | + " vi=" + mStableInsets.toShortString() |
| 777 | + " of=" + mOutsets.toShortString()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 778 | } |
| 779 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 780 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 781 | public Rect getFrameLw() { |
| 782 | return mFrame; |
| 783 | } |
| 784 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 785 | @Override |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 786 | public RectF getShownFrameLw() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 787 | return mShownFrame; |
| 788 | } |
| 789 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 790 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 791 | public Rect getDisplayFrameLw() { |
| 792 | return mDisplayFrame; |
| 793 | } |
| 794 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 795 | @Override |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 796 | public Rect getOverscanFrameLw() { |
| 797 | return mOverscanFrame; |
| 798 | } |
| 799 | |
| 800 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 801 | public Rect getContentFrameLw() { |
| 802 | return mContentFrame; |
| 803 | } |
| 804 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 805 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 806 | public Rect getVisibleFrameLw() { |
| 807 | return mVisibleFrame; |
| 808 | } |
| 809 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 810 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 811 | public boolean getGivenInsetsPendingLw() { |
| 812 | return mGivenInsetsPending; |
| 813 | } |
| 814 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 815 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 816 | public Rect getGivenContentInsetsLw() { |
| 817 | return mGivenContentInsets; |
| 818 | } |
| 819 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 820 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 821 | public Rect getGivenVisibleInsetsLw() { |
| 822 | return mGivenVisibleInsets; |
| 823 | } |
| 824 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 825 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 826 | public WindowManager.LayoutParams getAttrs() { |
| 827 | return mAttrs; |
| 828 | } |
| 829 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 830 | @Override |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 831 | public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) { |
| 832 | int index = -1; |
| 833 | WindowState ws = this; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 834 | WindowList windows = getWindowList(); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 835 | while (true) { |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 836 | if (ws.mAttrs.needsMenuKey != WindowManager.LayoutParams.NEEDS_MENU_UNSET) { |
| 837 | return ws.mAttrs.needsMenuKey == WindowManager.LayoutParams.NEEDS_MENU_SET_TRUE; |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 838 | } |
| 839 | // If we reached the bottom of the range of windows we are considering, |
| 840 | // assume no menu is needed. |
| 841 | if (ws == bottom) { |
| 842 | return false; |
| 843 | } |
| 844 | // The current window hasn't specified whether menu key is needed; |
| 845 | // look behind it. |
| 846 | // First, we may need to determine the starting position. |
| 847 | if (index < 0) { |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 848 | index = windows.indexOf(ws); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 849 | } |
| 850 | index--; |
| 851 | if (index < 0) { |
| 852 | return false; |
| 853 | } |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 854 | ws = windows.get(index); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 855 | } |
| 856 | } |
| 857 | |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 858 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 859 | public int getSystemUiVisibility() { |
| 860 | return mSystemUiVisibility; |
| 861 | } |
| 862 | |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 863 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 864 | public int getSurfaceLayer() { |
| 865 | return mLayer; |
| 866 | } |
| 867 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 868 | @Override |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 869 | public int getBaseType() { |
| 870 | WindowState win = this; |
| 871 | while (win.mAttachedWindow != null) { |
| 872 | win = win.mAttachedWindow; |
| 873 | } |
| 874 | return win.mAttrs.type; |
| 875 | } |
| 876 | |
| 877 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 878 | public IApplicationToken getAppToken() { |
| 879 | return mAppToken != null ? mAppToken.appToken : null; |
| 880 | } |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 881 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 882 | @Override |
| 883 | public boolean isVoiceInteraction() { |
| 884 | return mAppToken != null ? mAppToken.voiceInteraction : false; |
| 885 | } |
| 886 | |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 887 | boolean setInsetsChanged() { |
| 888 | mOverscanInsetsChanged |= !mLastOverscanInsets.equals(mOverscanInsets); |
| 889 | mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets); |
| 890 | mVisibleInsetsChanged |= !mLastVisibleInsets.equals(mVisibleInsets); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 891 | mStableInsetsChanged |= !mLastStableInsets.equals(mStableInsets); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 892 | mOutsetsChanged |= !mLastOutsets.equals(mOutsets); |
| 893 | return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged |
| 894 | || mOutsetsChanged; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 895 | } |
| 896 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 897 | public DisplayContent getDisplayContent() { |
Chad Jones | f391ebc | 2014-06-12 17:45:05 -0700 | [diff] [blame] | 898 | if (mAppToken == null || mNotOnAppsDisplay) { |
Craig Mautner | be63495 | 2014-06-12 13:39:24 -0700 | [diff] [blame] | 899 | return mDisplayContent; |
| 900 | } |
| 901 | final TaskStack stack = getStack(); |
| 902 | return stack == null ? mDisplayContent : stack.getDisplayContent(); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 903 | } |
| 904 | |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 905 | public DisplayInfo getDisplayInfo() { |
| 906 | final DisplayContent displayContent = getDisplayContent(); |
| 907 | return displayContent != null ? displayContent.getDisplayInfo() : null; |
| 908 | } |
| 909 | |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 910 | public int getDisplayId() { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 911 | final DisplayContent displayContent = getDisplayContent(); |
| 912 | if (displayContent == null) { |
| 913 | return -1; |
| 914 | } |
| 915 | return displayContent.getDisplayId(); |
Craig Mautner | 19d59bc | 2012-09-04 11:15:56 -0700 | [diff] [blame] | 916 | } |
| 917 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 918 | Task getTask() { |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 919 | AppWindowToken wtoken = mAppToken == null ? mService.mFocusedApp : mAppToken; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 920 | if (wtoken == null) { |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 921 | return null; |
| 922 | } |
| 923 | final Task task = wtoken.mTask; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 924 | return task; |
| 925 | } |
| 926 | |
| 927 | TaskStack getStack() { |
| 928 | Task task = getTask(); |
| 929 | if (task != null) { |
| 930 | if (task.mStack != null) { |
| 931 | return task.mStack; |
Craig Mautner | f06b8c1 | 2013-04-18 14:27:28 -0700 | [diff] [blame] | 932 | } |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 933 | } |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 934 | return mDisplayContent.getHomeStack(); |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 935 | } |
| 936 | |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 937 | /** |
| 938 | * Retrieves the bounds for a task. |
| 939 | * @param bounds The rect which gets the bounds. |
| 940 | * @param forTouch Pass in BOUNDS_FOR_TOUCH to get touch related bounds, otherwise visible |
| 941 | * bounds will be returned. |
| 942 | */ |
| 943 | void getTaskBounds(Rect bounds, boolean forTouch) { |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 944 | final Task task = getTask(); |
| 945 | if (task != null) { |
| 946 | task.getBounds(bounds); |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 947 | if (forTouch == BOUNDS_FOR_TOUCH) { |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 948 | if (task.inFreeformWorkspace()) { |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 949 | final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); |
| 950 | final int delta = |
| 951 | mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, displayMetrics); |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 952 | bounds.inset(-delta, -delta); |
| 953 | } |
| 954 | } |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 955 | return; |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 956 | } |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 957 | bounds.set(mFrame); |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 958 | } |
| 959 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 960 | public long getInputDispatchingTimeoutNanos() { |
| 961 | return mAppToken != null |
| 962 | ? mAppToken.inputDispatchingTimeoutNanos |
| 963 | : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS; |
| 964 | } |
| 965 | |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 966 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 967 | public boolean hasAppShownWindows() { |
Craig Mautner | f412095 | 2012-06-21 18:25:39 -0700 | [diff] [blame] | 968 | return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 969 | } |
| 970 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 971 | boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { |
| 972 | if (dsdx < .99999f || dsdx > 1.00001f) return false; |
| 973 | if (dtdy < .99999f || dtdy > 1.00001f) return false; |
| 974 | if (dtdx < -.000001f || dtdx > .000001f) return false; |
| 975 | if (dsdy < -.000001f || dsdy > .000001f) return false; |
| 976 | return true; |
| 977 | } |
| 978 | |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 979 | void prelayout() { |
| 980 | if (mEnforceSizeCompat) { |
| 981 | mGlobalScale = mService.mCompatibleScreenScale; |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 982 | mInvGlobalScale = 1/mGlobalScale; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 983 | } else { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 984 | mGlobalScale = mInvGlobalScale = 1; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 985 | } |
| 986 | } |
| 987 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 988 | /** |
| 989 | * Is this window visible? It is not visible if there is no |
| 990 | * surface, or we are in the process of running an exit animation |
| 991 | * that will remove the surface, or its app token has been hidden. |
| 992 | */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 993 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 994 | public boolean isVisibleLw() { |
| 995 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 996 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 997 | && (atoken == null || !atoken.hiddenRequested) |
| 998 | && !mExiting && !mDestroying; |
| 999 | } |
| 1000 | |
| 1001 | /** |
| 1002 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 1003 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 1004 | * things like window flags that impact the keyguard. |
| 1005 | * XXX I am starting to think we need to have ANOTHER visibility flag |
| 1006 | * for this "hidden behind keyguard" state rather than overloading |
| 1007 | * mPolicyVisibility. Ungh. |
| 1008 | */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1009 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1010 | public boolean isVisibleOrBehindKeyguardLw() { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1011 | if (mRootToken.waitingToShow && |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1012 | mService.mAppTransition.isTransitionSet()) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1013 | return false; |
| 1014 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1015 | final AppWindowToken atoken = mAppToken; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1016 | final boolean animating = atoken != null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1017 | ? (atoken.mAppAnimator.animation != null) : false; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1018 | return mHasSurface && !mDestroying && !mExiting |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1019 | && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 1020 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1021 | && !mRootToken.hidden) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1022 | || mWinAnimator.mAnimation != null || animating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1023 | } |
| 1024 | |
| 1025 | /** |
| 1026 | * Is this window visible, ignoring its app token? It is not visible |
| 1027 | * if there is no surface, or we are in the process of running an exit animation |
| 1028 | * that will remove the surface. |
| 1029 | */ |
| 1030 | public boolean isWinVisibleLw() { |
| 1031 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1032 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1033 | && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1034 | && !mExiting && !mDestroying; |
| 1035 | } |
| 1036 | |
| 1037 | /** |
| 1038 | * The same as isVisible(), but follows the current hidden state of |
| 1039 | * the associated app token, not the pending requested hidden state. |
| 1040 | */ |
| 1041 | boolean isVisibleNow() { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1042 | return mHasSurface && mPolicyVisibility && !mAttachedHidden |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 1043 | && (!mRootToken.hidden || mAttrs.type == TYPE_APPLICATION_STARTING) |
| 1044 | && !mExiting && !mDestroying; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1045 | } |
| 1046 | |
| 1047 | /** |
| 1048 | * Can this window possibly be a drag/drop target? The test here is |
| 1049 | * a combination of the above "visible now" with the check that the |
| 1050 | * Input Manager uses when discarding windows from input consideration. |
| 1051 | */ |
| 1052 | boolean isPotentialDragTarget() { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1053 | return isVisibleNow() && !mRemoved |
| 1054 | && mInputChannel != null && mInputWindowHandle != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | /** |
| 1058 | * Same as isVisible(), but we also count it as visible between the |
| 1059 | * call to IWindowSession.add() and the first relayout(). |
| 1060 | */ |
| 1061 | boolean isVisibleOrAdding() { |
| 1062 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | bf08af3 | 2012-05-16 19:43:42 -0700 | [diff] [blame] | 1063 | return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1064 | && mPolicyVisibility && !mAttachedHidden |
| 1065 | && (atoken == null || !atoken.hiddenRequested) |
| 1066 | && !mExiting && !mDestroying; |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * Is this window currently on-screen? It is on-screen either if it |
| 1071 | * is visible or it is currently running an animation before no longer |
| 1072 | * being visible. |
| 1073 | */ |
| 1074 | boolean isOnScreen() { |
Jorim Jaggi | 44f60cc | 2014-11-07 20:33:51 +0100 | [diff] [blame] | 1075 | return mPolicyVisibility && isOnScreenIgnoringKeyguard(); |
| 1076 | } |
| 1077 | |
| 1078 | /** |
| 1079 | * Like isOnScreen(), but ignores any force hiding of the window due |
| 1080 | * to the keyguard. |
| 1081 | */ |
| 1082 | boolean isOnScreenIgnoringKeyguard() { |
| 1083 | if (!mHasSurface || mDestroying) { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1084 | return false; |
| 1085 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1086 | final AppWindowToken atoken = mAppToken; |
| 1087 | if (atoken != null) { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1088 | return ((!mAttachedHidden && !atoken.hiddenRequested) |
Craig Mautner | ccc9e9b | 2012-12-11 09:40:34 -0800 | [diff] [blame] | 1089 | || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1090 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1091 | return !mAttachedHidden || mWinAnimator.mAnimation != null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | /** |
| 1095 | * Like isOnScreen(), but we don't return true if the window is part |
| 1096 | * of a transition that has not yet been started. |
| 1097 | */ |
| 1098 | boolean isReadyForDisplay() { |
| 1099 | if (mRootToken.waitingToShow && |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1100 | mService.mAppTransition.isTransitionSet()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1101 | return false; |
| 1102 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1103 | return mHasSurface && mPolicyVisibility && !mDestroying |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1104 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1105 | && !mRootToken.hidden) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1106 | || mWinAnimator.mAnimation != null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1107 | || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null))); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1108 | } |
| 1109 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1110 | /** |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 1111 | * Like isReadyForDisplay(), but ignores any force hiding of the window due |
| 1112 | * to the keyguard. |
| 1113 | */ |
| 1114 | boolean isReadyForDisplayIgnoringKeyguard() { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1115 | if (mRootToken.waitingToShow && mService.mAppTransition.isTransitionSet()) { |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 1116 | return false; |
| 1117 | } |
| 1118 | final AppWindowToken atoken = mAppToken; |
| 1119 | if (atoken == null && !mPolicyVisibility) { |
| 1120 | // If this is not an app window, and the policy has asked to force |
| 1121 | // hide, then we really do want to hide. |
| 1122 | return false; |
| 1123 | } |
| 1124 | return mHasSurface && !mDestroying |
| 1125 | && ((!mAttachedHidden && mViewVisibility == View.VISIBLE |
| 1126 | && !mRootToken.hidden) |
| 1127 | || mWinAnimator.mAnimation != null |
Craig Mautner | 9c5bf3b | 2012-06-22 15:19:13 -0700 | [diff] [blame] | 1128 | || ((atoken != null) && (atoken.mAppAnimator.animation != null) |
| 1129 | && !mWinAnimator.isDummyAnimation())); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | /** |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1133 | * Like isOnScreen, but returns false if the surface hasn't yet |
| 1134 | * been drawn. |
| 1135 | */ |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 1136 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1137 | public boolean isDisplayedLw() { |
| 1138 | final AppWindowToken atoken = mAppToken; |
Craig Mautner | bf90eaa | 2012-03-15 11:28:53 -0700 | [diff] [blame] | 1139 | return isDrawnLw() && mPolicyVisibility |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1140 | && ((!mAttachedHidden && |
| 1141 | (atoken == null || !atoken.hiddenRequested)) |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 1142 | || mWinAnimator.mAnimating |
| 1143 | || (atoken != null && atoken.mAppAnimator.animation != null)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1144 | } |
| 1145 | |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1146 | /** |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 1147 | * Return true if this window or its app token is currently animating. |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1148 | */ |
Craig Mautner | e6f7d505 | 2012-10-08 10:34:17 -0700 | [diff] [blame] | 1149 | @Override |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1150 | public boolean isAnimatingLw() { |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 1151 | return mWinAnimator.mAnimation != null |
| 1152 | || (mAppToken != null && mAppToken.mAppAnimator.animation != null); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 1155 | @Override |
Dianne Hackborn | cfbf7de | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 1156 | public boolean isGoneForLayoutLw() { |
| 1157 | final AppWindowToken atoken = mAppToken; |
| 1158 | return mViewVisibility == View.GONE |
| 1159 | || !mRelayoutCalled |
| 1160 | || (atoken == null && mRootToken.hidden) |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 1161 | || (atoken != null && (atoken.hiddenRequested || atoken.hidden)) |
Dianne Hackborn | cfbf7de | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 1162 | || mAttachedHidden |
Craig Mautner | 0e415c6 | 2013-04-29 16:10:58 -0700 | [diff] [blame] | 1163 | || (mExiting && !isAnimatingLw()) |
| 1164 | || mDestroying; |
Dianne Hackborn | cfbf7de | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 1165 | } |
| 1166 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1167 | /** |
| 1168 | * Returns true if the window has a surface that it has drawn a |
| 1169 | * complete UI in to. |
| 1170 | */ |
Craig Mautner | ccc9e9b | 2012-12-11 09:40:34 -0800 | [diff] [blame] | 1171 | public boolean isDrawFinishedLw() { |
| 1172 | return mHasSurface && !mDestroying && |
| 1173 | (mWinAnimator.mDrawState == WindowStateAnimator.COMMIT_DRAW_PENDING |
| 1174 | || mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW |
| 1175 | || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN); |
| 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * Returns true if the window has a surface that it has drawn a |
| 1180 | * complete UI in to. |
| 1181 | */ |
Adrian Roos | 76d2fe4 | 2015-07-09 14:54:08 -0700 | [diff] [blame] | 1182 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1183 | public boolean isDrawnLw() { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1184 | return mHasSurface && !mDestroying && |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1185 | (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW |
| 1186 | || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | /** |
| 1190 | * Return true if the window is opaque and fully drawn. This indicates |
| 1191 | * it may obscure windows behind it. |
| 1192 | */ |
| 1193 | boolean isOpaqueDrawn() { |
| 1194 | return (mAttrs.format == PixelFormat.OPAQUE |
| 1195 | || mAttrs.type == TYPE_WALLPAPER) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1196 | && isDrawnLw() && mWinAnimator.mAnimation == null |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1197 | && (mAppToken == null || mAppToken.mAppAnimator.animation == null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | /** |
Craig Mautner | 4557c08 | 2015-04-27 13:07:40 -0700 | [diff] [blame] | 1201 | * Return whether this window has moved. (Only makes |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1202 | * sense to call from performLayoutAndPlaceSurfacesLockedInner().) |
| 1203 | */ |
Craig Mautner | 4557c08 | 2015-04-27 13:07:40 -0700 | [diff] [blame] | 1204 | boolean hasMoved() { |
| 1205 | return mHasSurface && mContentChanged && !mExiting && !mWinAnimator.mLastHidden |
| 1206 | && mService.okToDisplay() && (mFrame.top != mLastFrame.top |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1207 | || mFrame.left != mLastFrame.left) |
Craig Mautner | 4557c08 | 2015-04-27 13:07:40 -0700 | [diff] [blame] | 1208 | && (mAttachedWindow == null || !mAttachedWindow.hasMoved()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1209 | } |
| 1210 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1211 | boolean isFullscreen(int screenWidth, int screenHeight) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1212 | return mFrame.left <= 0 && mFrame.top <= 0 && |
| 1213 | mFrame.right >= screenWidth && mFrame.bottom >= screenHeight; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1214 | } |
| 1215 | |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 1216 | boolean isConfigChanged() { |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1217 | final Task task = getTask(); |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1218 | final Configuration overrideConfig = |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1219 | (task != null) ? task.mOverrideConfig : Configuration.EMPTY; |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1220 | final Configuration serviceConfig = mService.mCurConfiguration; |
| 1221 | boolean configChanged = |
| 1222 | (mConfiguration != serviceConfig && mConfiguration.diff(serviceConfig) != 0) |
| 1223 | || (mOverrideConfig != overrideConfig && !mOverrideConfig.equals(overrideConfig)); |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 1224 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1225 | if ((mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 1226 | // Retain configuration changed status until resetConfiguration called. |
| 1227 | mConfigHasChanged |= configChanged; |
| 1228 | configChanged = mConfigHasChanged; |
| 1229 | } |
| 1230 | |
| 1231 | return configChanged; |
Craig Mautner | 812d2ca | 2012-09-27 15:35:34 -0700 | [diff] [blame] | 1232 | } |
| 1233 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1234 | void removeLocked() { |
| 1235 | disposeInputChannel(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1236 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1237 | if (mAttachedWindow != null) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1238 | if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1239 | mAttachedWindow.mChildWindows.remove(this); |
| 1240 | } |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1241 | mWinAnimator.destroyDeferredSurfaceLocked(); |
| 1242 | mWinAnimator.destroySurfaceLocked(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1243 | mSession.windowRemovedLocked(); |
| 1244 | try { |
| 1245 | mClient.asBinder().unlinkToDeath(mDeathRecipient, 0); |
| 1246 | } catch (RuntimeException e) { |
| 1247 | // Ignore if it has already been removed (usually because |
| 1248 | // we are doing this as part of processing a death note.) |
| 1249 | } |
| 1250 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1251 | |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1252 | private void setConfiguration( |
| 1253 | final Configuration newConfig, final Configuration newOverrideConfig) { |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 1254 | mConfiguration = newConfig; |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1255 | mOverrideConfig = newOverrideConfig; |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 1256 | mConfigHasChanged = false; |
| 1257 | } |
| 1258 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1259 | void setInputChannel(InputChannel inputChannel) { |
| 1260 | if (mInputChannel != null) { |
| 1261 | throw new IllegalStateException("Window already has an input channel."); |
| 1262 | } |
| 1263 | |
| 1264 | mInputChannel = inputChannel; |
| 1265 | mInputWindowHandle.inputChannel = inputChannel; |
| 1266 | } |
| 1267 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1268 | void disposeInputChannel() { |
| 1269 | if (mInputChannel != null) { |
| 1270 | mService.mInputManager.unregisterInputChannel(mInputChannel); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1271 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1272 | mInputChannel.dispose(); |
| 1273 | mInputChannel = null; |
| 1274 | } |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1275 | |
| 1276 | mInputWindowHandle.inputChannel = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1277 | } |
| 1278 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1279 | void handleFlagDimBehind() { |
| 1280 | if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0 && isDisplayedLw() && !mExiting) { |
| 1281 | final Task task = getTask(); |
| 1282 | if (task == null) { |
| 1283 | return; |
| 1284 | } |
| 1285 | task.setContinueDimming(); |
| 1286 | if (!task.isDimming(mWinAnimator)) { |
| 1287 | if (WindowManagerService.localLOGV) Slog.v(TAG, "Win " + this + " start dimming."); |
| 1288 | task.startDimmingIfNeeded(mWinAnimator); |
| 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | |
Filip Gruszczynski | 76cc44f | 2015-09-03 16:03:10 -0700 | [diff] [blame] | 1293 | void maybeRemoveReplacedWindow() { |
| 1294 | AppWindowToken token = mAppToken; |
| 1295 | if (token != null && token.mReplacingWindow) { |
| 1296 | token.mReplacingWindow = false; |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1297 | token.mAnimateReplacingWindow = false; |
| 1298 | token.mReplacingRemoveRequested = false; |
Filip Gruszczynski | 76cc44f | 2015-09-03 16:03:10 -0700 | [diff] [blame] | 1299 | for (int i = token.allAppWindows.size() - 1; i >= 0; i--) { |
| 1300 | WindowState win = token.allAppWindows.get(i); |
| 1301 | if (win.mExiting) { |
| 1302 | mService.removeWindowInnerLocked(win); |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1308 | private class DeathRecipient implements IBinder.DeathRecipient { |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 1309 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1310 | public void binderDied() { |
| 1311 | try { |
| 1312 | synchronized(mService.mWindowMap) { |
| 1313 | WindowState win = mService.windowForClientLocked(mSession, mClient, false); |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1314 | Slog.i(TAG, "WIN DEATH: " + win); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1315 | if (win != null) { |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 1316 | mService.removeWindowLocked(win); |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 1317 | } else if (mHasSurface) { |
Craig Mautner | a99764e | 2013-03-06 10:22:16 -0800 | [diff] [blame] | 1318 | Slog.e(TAG, "!!! LEAK !!! Window removed but surface still valid."); |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 1319 | mService.removeWindowLocked(WindowState.this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | } catch (IllegalArgumentException ex) { |
| 1323 | // This will happen if the window has already been |
| 1324 | // removed. |
| 1325 | } |
| 1326 | } |
| 1327 | } |
| 1328 | |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 1329 | /** |
| 1330 | * @return true if this window desires key events. |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 1331 | */ |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1332 | public final boolean canReceiveKeys() { |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 1333 | return isVisibleOrAdding() |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1334 | && (mViewVisibility == View.VISIBLE) |
| 1335 | && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0); |
| 1336 | } |
| 1337 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1338 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1339 | public boolean hasDrawnLw() { |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1340 | return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1341 | } |
| 1342 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1343 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1344 | public boolean showLw(boolean doAnimation) { |
| 1345 | return showLw(doAnimation, true); |
| 1346 | } |
| 1347 | |
| 1348 | boolean showLw(boolean doAnimation, boolean requestAnim) { |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1349 | if (isHiddenFromUserLocked()) { |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 1350 | return false; |
| 1351 | } |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1352 | if (!mAppOpVisibility) { |
| 1353 | // Being hidden due to app op request. |
| 1354 | return false; |
| 1355 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1356 | if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 1357 | // Already showing. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1358 | return false; |
| 1359 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1360 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1361 | if (doAnimation) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1362 | if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility=" |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1363 | + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation); |
Craig Mautner | 2fb98b1 | 2012-03-20 17:24:00 -0700 | [diff] [blame] | 1364 | if (!mService.okToDisplay()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1365 | doAnimation = false; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1366 | } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1367 | // Check for the case where we are currently visible and |
| 1368 | // not animating; we do not want to do animation at such a |
| 1369 | // point to become visible when we already are. |
| 1370 | doAnimation = false; |
| 1371 | } |
| 1372 | } |
| 1373 | mPolicyVisibility = true; |
| 1374 | mPolicyVisibilityAfterAnim = true; |
| 1375 | if (doAnimation) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1376 | mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1377 | } |
| 1378 | if (requestAnim) { |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1379 | mService.scheduleAnimationLocked(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1380 | } |
| 1381 | return true; |
| 1382 | } |
| 1383 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1384 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1385 | public boolean hideLw(boolean doAnimation) { |
| 1386 | return hideLw(doAnimation, true); |
| 1387 | } |
| 1388 | |
| 1389 | boolean hideLw(boolean doAnimation, boolean requestAnim) { |
| 1390 | if (doAnimation) { |
Craig Mautner | 2fb98b1 | 2012-03-20 17:24:00 -0700 | [diff] [blame] | 1391 | if (!mService.okToDisplay()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1392 | doAnimation = false; |
| 1393 | } |
| 1394 | } |
| 1395 | boolean current = doAnimation ? mPolicyVisibilityAfterAnim |
| 1396 | : mPolicyVisibility; |
| 1397 | if (!current) { |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 1398 | // Already hiding. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1399 | return false; |
| 1400 | } |
| 1401 | if (doAnimation) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1402 | mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1403 | if (mWinAnimator.mAnimation == null) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1404 | doAnimation = false; |
| 1405 | } |
| 1406 | } |
| 1407 | if (doAnimation) { |
| 1408 | mPolicyVisibilityAfterAnim = false; |
| 1409 | } else { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1410 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1411 | mPolicyVisibilityAfterAnim = false; |
| 1412 | mPolicyVisibility = false; |
| 1413 | // Window is no longer visible -- make sure if we were waiting |
| 1414 | // for it to be displayed before enabling the display, that |
| 1415 | // we allow the display to be enabled now. |
| 1416 | mService.enableScreenIfNeededLocked(); |
| 1417 | if (mService.mCurrentFocus == this) { |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 1418 | if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, |
| 1419 | "WindowState.hideLw: setting mFocusMayChange true"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1420 | mService.mFocusMayChange = true; |
| 1421 | } |
| 1422 | } |
| 1423 | if (requestAnim) { |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1424 | mService.scheduleAnimationLocked(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1425 | } |
| 1426 | return true; |
| 1427 | } |
| 1428 | |
Craig Mautner | fb32c6e | 2013-02-12 15:08:44 -0800 | [diff] [blame] | 1429 | public void setAppOpVisibilityLw(boolean state) { |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1430 | if (mAppOpVisibility != state) { |
| 1431 | mAppOpVisibility = state; |
| 1432 | if (state) { |
| 1433 | // If the policy visibility had last been to hide, then this |
| 1434 | // will incorrectly show at this point since we lost that |
| 1435 | // information. Not a big deal -- for the windows that have app |
| 1436 | // ops modifies they should only be hidden by policy due to the |
| 1437 | // lock screen, and the user won't be changing this if locked. |
| 1438 | // 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] | 1439 | showLw(true, true); |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1440 | } else { |
Craig Mautner | fb32c6e | 2013-02-12 15:08:44 -0800 | [diff] [blame] | 1441 | hideLw(true, true); |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1442 | } |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1443 | } |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1444 | } |
| 1445 | |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 1446 | public void pokeDrawLockLw(long timeout) { |
| 1447 | if (isVisibleOrAdding()) { |
| 1448 | if (mDrawLock == null) { |
| 1449 | // We want the tag name to be somewhat stable so that it is easier to correlate |
| 1450 | // in wake lock statistics. So in particular, we don't want to include the |
| 1451 | // window's hash code as in toString(). |
| 1452 | CharSequence tag = mAttrs.getTitle(); |
| 1453 | if (tag == null) { |
| 1454 | tag = mAttrs.packageName; |
| 1455 | } |
| 1456 | mDrawLock = mService.mPowerManager.newWakeLock( |
| 1457 | PowerManager.DRAW_WAKE_LOCK, "Window:" + tag); |
| 1458 | mDrawLock.setReferenceCounted(false); |
| 1459 | mDrawLock.setWorkSource(new WorkSource(mOwnerUid, mAttrs.packageName)); |
| 1460 | } |
| 1461 | // Each call to acquire resets the timeout. |
| 1462 | if (DEBUG_POWER) { |
| 1463 | Slog.d(TAG, "pokeDrawLock: poking draw lock on behalf of visible window owned by " |
| 1464 | + mAttrs.packageName); |
| 1465 | } |
| 1466 | mDrawLock.acquire(timeout); |
| 1467 | } else if (DEBUG_POWER) { |
| 1468 | Slog.d(TAG, "pokeDrawLock: suppressed draw lock request for invisible window " |
| 1469 | + "owned by " + mAttrs.packageName); |
| 1470 | } |
| 1471 | } |
| 1472 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1473 | @Override |
| 1474 | public boolean isAlive() { |
| 1475 | return mClient.asBinder().isBinderAlive(); |
| 1476 | } |
| 1477 | |
Craig Mautner | a987d43 | 2012-10-11 14:07:58 -0700 | [diff] [blame] | 1478 | boolean isClosing() { |
| 1479 | return mExiting || (mService.mClosingApps.contains(mAppToken)); |
| 1480 | } |
| 1481 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1482 | @Override |
| 1483 | public boolean isDefaultDisplay() { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1484 | final DisplayContent displayContent = getDisplayContent(); |
| 1485 | if (displayContent == null) { |
| 1486 | // Only a window that was on a non-default display can be detached from it. |
| 1487 | return false; |
| 1488 | } |
Winson Chung | 47a3e65 | 2014-05-21 16:03:42 -0700 | [diff] [blame] | 1489 | return displayContent.isDefaultDisplay; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 1492 | @Override |
| 1493 | public boolean isDimming() { |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1494 | Task task = getTask(); |
| 1495 | if (task == null) { |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 1496 | return false; |
| 1497 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1498 | return task.isDimming(mWinAnimator); |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 1499 | } |
| 1500 | |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1501 | public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) { |
| 1502 | mShowToOwnerOnly = showToOwnerOnly; |
| 1503 | } |
| 1504 | |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1505 | boolean isHiddenFromUserLocked() { |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1506 | // Attached windows are evaluated based on the window that they are attached to. |
| 1507 | WindowState win = this; |
| 1508 | while (win.mAttachedWindow != null) { |
| 1509 | win = win.mAttachedWindow; |
| 1510 | } |
| 1511 | if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 1512 | && win.mAppToken != null && win.mAppToken.showForAllUsers) { |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1513 | // Save some cycles by not calling getDisplayInfo unless it is an application |
| 1514 | // window intended for all users. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1515 | final DisplayContent displayContent = win.getDisplayContent(); |
| 1516 | if (displayContent == null) { |
| 1517 | return true; |
| 1518 | } |
| 1519 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1520 | if (win.mFrame.left <= 0 && win.mFrame.top <= 0 |
| 1521 | && win.mFrame.right >= displayInfo.appWidth |
| 1522 | && win.mFrame.bottom >= displayInfo.appHeight) { |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1523 | // Is a fullscreen window, like the clock alarm. Show to everyone. |
| 1524 | return false; |
| 1525 | } |
| 1526 | } |
| 1527 | |
Craig Mautner | 341220f | 2012-10-16 15:20:09 -0700 | [diff] [blame] | 1528 | return win.mShowToOwnerOnly |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 1529 | && !mService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid)); |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 1530 | } |
| 1531 | |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1532 | private static void applyInsets(Region outRegion, Rect frame, Rect inset) { |
| 1533 | outRegion.set( |
| 1534 | frame.left + inset.left, frame.top + inset.top, |
| 1535 | frame.right - inset.right, frame.bottom - inset.bottom); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1536 | } |
| 1537 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1538 | public void getTouchableRegion(Region outRegion) { |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1539 | final Rect frame = mFrame; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1540 | switch (mTouchableInsets) { |
| 1541 | default: |
| 1542 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME: |
| 1543 | outRegion.set(frame); |
| 1544 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1545 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1546 | applyInsets(outRegion, frame, mGivenContentInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1547 | break; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1548 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE: |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1549 | applyInsets(outRegion, frame, mGivenVisibleInsets); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1550 | break; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1551 | case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: { |
| 1552 | final Region givenTouchableRegion = mGivenTouchableRegion; |
| 1553 | outRegion.set(givenTouchableRegion); |
| 1554 | outRegion.translate(frame.left, frame.top); |
| 1555 | break; |
| 1556 | } |
| 1557 | } |
| 1558 | } |
| 1559 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1560 | WindowList getWindowList() { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1561 | final DisplayContent displayContent = getDisplayContent(); |
| 1562 | return displayContent == null ? null : displayContent.getWindowList(); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 1565 | /** |
| 1566 | * Report a focus change. Must be called with no locks held, and consistently |
| 1567 | * from the same serialized thread (such as dispatched from a handler). |
| 1568 | */ |
| 1569 | public void reportFocusChangedSerialized(boolean focused, boolean inTouchMode) { |
| 1570 | try { |
| 1571 | mClient.windowFocusChanged(focused, inTouchMode); |
| 1572 | } catch (RemoteException e) { |
| 1573 | } |
| 1574 | if (mFocusCallbacks != null) { |
| 1575 | final int N = mFocusCallbacks.beginBroadcast(); |
| 1576 | for (int i=0; i<N; i++) { |
| 1577 | IWindowFocusObserver obs = mFocusCallbacks.getBroadcastItem(i); |
| 1578 | try { |
| 1579 | if (focused) { |
| 1580 | obs.focusGained(mWindowId.asBinder()); |
| 1581 | } else { |
| 1582 | obs.focusLost(mWindowId.asBinder()); |
| 1583 | } |
| 1584 | } catch (RemoteException e) { |
| 1585 | } |
| 1586 | } |
| 1587 | mFocusCallbacks.finishBroadcast(); |
| 1588 | } |
| 1589 | } |
| 1590 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1591 | void reportResized() { |
| 1592 | try { |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 1593 | if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + this |
| 1594 | + ": " + mCompatFrame); |
| 1595 | boolean configChanged = isConfigChanged(); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1596 | final Task task = getTask(); |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1597 | final Configuration overrideConfig = |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1598 | (task != null) ? task.mOverrideConfig : Configuration.EMPTY; |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 1599 | if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION) && configChanged) { |
| 1600 | Slog.i(TAG, "Sending new config to window " + this + ": " |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1601 | + mWinAnimator.mSurfaceW + "x" + mWinAnimator.mSurfaceH + " / config=" |
| 1602 | + mService.mCurConfiguration + " overrideConfig=" + overrideConfig); |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 1603 | } |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1604 | setConfiguration(mService.mCurConfiguration, overrideConfig); |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 1605 | if (DEBUG_ORIENTATION && mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) |
| 1606 | Slog.i(TAG, "Resizing " + this + " WITH DRAW PENDING"); |
| 1607 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1608 | final Rect frame = mFrame; |
| 1609 | final Rect overscanInsets = mLastOverscanInsets; |
| 1610 | final Rect contentInsets = mLastContentInsets; |
| 1611 | final Rect visibleInsets = mLastVisibleInsets; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 1612 | final Rect stableInsets = mLastStableInsets; |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1613 | final Rect outsets = mLastOutsets; |
Craig Mautner | d1c2c54 | 2014-02-06 10:31:41 -0800 | [diff] [blame] | 1614 | final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING; |
| 1615 | final Configuration newConfig = configChanged ? mConfiguration : null; |
Chet Haase | 8eb48d2 | 2014-09-24 07:31:29 -0700 | [diff] [blame] | 1616 | if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING |
| 1617 | && mClient instanceof IWindow.Stub) { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1618 | // To prevent deadlock simulate one-way call if win.mClient is a local object. |
| 1619 | mService.mH.post(new Runnable() { |
| 1620 | @Override |
| 1621 | public void run() { |
| 1622 | try { |
| 1623 | mClient.resized(frame, overscanInsets, contentInsets, |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1624 | visibleInsets, stableInsets, outsets, reportDraw, newConfig); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1625 | } catch (RemoteException e) { |
| 1626 | // Not a remote call, RemoteException won't be raised. |
| 1627 | } |
| 1628 | } |
| 1629 | }); |
| 1630 | } else { |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 1631 | mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1632 | outsets, reportDraw, newConfig); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1633 | } |
Svetoslav | 4604abc | 2014-06-10 18:59:30 -0700 | [diff] [blame] | 1634 | |
| 1635 | //TODO (multidisplay): Accessibility supported only for the default display. |
| 1636 | if (mService.mAccessibilityController != null |
| 1637 | && getDisplayId() == Display.DEFAULT_DISPLAY) { |
Svetoslav | f7174e8 | 2014-06-12 11:29:35 -0700 | [diff] [blame] | 1638 | mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked(); |
Svetoslav | 4604abc | 2014-06-10 18:59:30 -0700 | [diff] [blame] | 1639 | } |
| 1640 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1641 | mOverscanInsetsChanged = false; |
| 1642 | mContentInsetsChanged = false; |
| 1643 | mVisibleInsetsChanged = false; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 1644 | mStableInsetsChanged = false; |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1645 | mOutsetsChanged = false; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1646 | mWinAnimator.mSurfaceResized = false; |
| 1647 | } catch (RemoteException e) { |
| 1648 | mOrientationChanging = false; |
| 1649 | mLastFreezeDuration = (int)(SystemClock.elapsedRealtime() |
| 1650 | - mService.mDisplayFreezeTime); |
tiger_huang | 950ee77 | 2014-07-11 18:41:48 +0800 | [diff] [blame] | 1651 | // We are assuming the hosting process is dead or in a zombie state. |
| 1652 | Slog.w(TAG, "Failed to report 'resized' to the client of " + this |
| 1653 | + ", removing this window."); |
| 1654 | mService.mPendingRemove.add(this); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1655 | mService.mWindowPlacerLocked.requestTraversal(); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1656 | } |
| 1657 | } |
| 1658 | |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 1659 | public void registerFocusObserver(IWindowFocusObserver observer) { |
| 1660 | synchronized(mService.mWindowMap) { |
| 1661 | if (mFocusCallbacks == null) { |
| 1662 | mFocusCallbacks = new RemoteCallbackList<IWindowFocusObserver>(); |
| 1663 | } |
| 1664 | mFocusCallbacks.register(observer); |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | public void unregisterFocusObserver(IWindowFocusObserver observer) { |
| 1669 | synchronized(mService.mWindowMap) { |
| 1670 | if (mFocusCallbacks != null) { |
| 1671 | mFocusCallbacks.unregister(observer); |
| 1672 | } |
| 1673 | } |
| 1674 | } |
| 1675 | |
| 1676 | public boolean isFocused() { |
| 1677 | synchronized(mService.mWindowMap) { |
| 1678 | return mService.mCurrentFocus == this; |
| 1679 | } |
| 1680 | } |
| 1681 | |
Filip Gruszczynski | 1a1d831 | 2015-08-26 17:00:47 -0700 | [diff] [blame] | 1682 | boolean inFreeformWorkspace() { |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 1683 | final Task task = mAppToken != null ? getTask() : null; |
| 1684 | return task != null && task.inFreeformWorkspace(); |
| 1685 | } |
| 1686 | |
| 1687 | boolean isDragResizing() { |
| 1688 | final Task task = mAppToken != null ? getTask() : null; |
| 1689 | return mService.mTaskPositioner != null && mService.mTaskPositioner.isTaskResizing(task); |
Skuhne | f932e56 | 2015-08-20 12:07:30 -0700 | [diff] [blame] | 1690 | } |
| 1691 | |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1692 | void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
Wale Ogunwale | 30cc7bf | 2015-02-04 16:47:57 -0800 | [diff] [blame] | 1693 | final TaskStack stack = getStack(); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1694 | pw.print(prefix); pw.print("mDisplayId="); pw.print(getDisplayId()); |
Wale Ogunwale | 30cc7bf | 2015-02-04 16:47:57 -0800 | [diff] [blame] | 1695 | if (stack != null) { |
| 1696 | pw.print(" stackId="); pw.print(stack.mStackId); |
| 1697 | } |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1698 | pw.print(" mSession="); pw.print(mSession); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1699 | pw.print(" mClient="); pw.println(mClient.asBinder()); |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1700 | pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid); |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1701 | pw.print(" mShowToOwnerOnly="); pw.print(mShowToOwnerOnly); |
| 1702 | pw.print(" package="); pw.print(mAttrs.packageName); |
| 1703 | pw.print(" appop="); pw.println(AppOpsManager.opToName(mAppOp)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1704 | pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1705 | pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); |
| 1706 | pw.print(" h="); pw.print(mRequestedHeight); |
| 1707 | pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); |
Dianne Hackborn | 1743b64 | 2012-03-12 17:04:43 -0700 | [diff] [blame] | 1708 | if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { |
| 1709 | pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth); |
| 1710 | pw.print(" h="); pw.println(mLastRequestedHeight); |
| 1711 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1712 | if (mAttachedWindow != null || mLayoutAttached) { |
| 1713 | pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); |
| 1714 | pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); |
| 1715 | } |
| 1716 | if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) { |
| 1717 | pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow); |
| 1718 | pw.print(" mIsWallpaper="); pw.print(mIsWallpaper); |
| 1719 | pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer); |
| 1720 | pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible); |
| 1721 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1722 | if (dumpAll) { |
| 1723 | pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); |
| 1724 | pw.print(" mSubLayer="); pw.print(mSubLayer); |
| 1725 | pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1726 | pw.print((mTargetAppToken != null ? |
| 1727 | mTargetAppToken.mAppAnimator.animLayerAdjustment |
| 1728 | : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0))); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1729 | pw.print("="); pw.print(mWinAnimator.mAnimLayer); |
| 1730 | pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer); |
Dianne Hackborn | 6d05fd3 | 2011-11-19 14:36:15 -0800 | [diff] [blame] | 1731 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1732 | if (dumpAll) { |
| 1733 | pw.print(prefix); pw.print("mToken="); pw.println(mToken); |
| 1734 | pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); |
| 1735 | if (mAppToken != null) { |
| 1736 | pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); |
| 1737 | } |
| 1738 | if (mTargetAppToken != null) { |
| 1739 | pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); |
| 1740 | } |
| 1741 | pw.print(prefix); pw.print("mViewVisibility=0x"); |
| 1742 | pw.print(Integer.toHexString(mViewVisibility)); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1743 | pw.print(" mHaveFrame="); pw.print(mHaveFrame); |
| 1744 | pw.print(" mObscured="); pw.println(mObscured); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 1745 | pw.print(prefix); pw.print("mSeq="); pw.print(mSeq); |
| 1746 | pw.print(" mSystemUiVisibility=0x"); |
| 1747 | pw.println(Integer.toHexString(mSystemUiVisibility)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1748 | } |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1749 | if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || !mAppOpVisibility |
| 1750 | || mAttachedHidden) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1751 | pw.print(prefix); pw.print("mPolicyVisibility="); |
| 1752 | pw.print(mPolicyVisibility); |
| 1753 | pw.print(" mPolicyVisibilityAfterAnim="); |
| 1754 | pw.print(mPolicyVisibilityAfterAnim); |
Dianne Hackborn | b6b23ec | 2013-02-11 19:29:06 -0800 | [diff] [blame] | 1755 | pw.print(" mAppOpVisibility="); |
| 1756 | pw.print(mAppOpVisibility); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1757 | pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); |
| 1758 | } |
Dianne Hackborn | b7ff51b | 2012-01-23 19:15:27 -0800 | [diff] [blame] | 1759 | if (!mRelayoutCalled || mLayoutNeeded) { |
| 1760 | pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled); |
| 1761 | pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1762 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1763 | if (mXOffset != 0 || mYOffset != 0) { |
| 1764 | pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); |
| 1765 | pw.print(" y="); pw.println(mYOffset); |
| 1766 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1767 | if (dumpAll) { |
| 1768 | pw.print(prefix); pw.print("mGivenContentInsets="); |
| 1769 | mGivenContentInsets.printShortString(pw); |
| 1770 | pw.print(" mGivenVisibleInsets="); |
| 1771 | mGivenVisibleInsets.printShortString(pw); |
| 1772 | pw.println(); |
| 1773 | if (mTouchableInsets != 0 || mGivenInsetsPending) { |
| 1774 | pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); |
| 1775 | pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1776 | Region region = new Region(); |
| 1777 | getTouchableRegion(region); |
| 1778 | pw.print(prefix); pw.print("touchable region="); pw.println(region); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1779 | } |
| 1780 | pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration); |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 1781 | if (mOverrideConfig != Configuration.EMPTY) { |
| 1782 | pw.print(prefix); pw.print("mOverrideConfig="); pw.println(mOverrideConfig); |
| 1783 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1784 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1785 | pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface); |
Craig Mautner | 178af59 | 2012-09-17 10:37:29 -0700 | [diff] [blame] | 1786 | pw.print(" mShownFrame="); mShownFrame.printShortString(pw); |
| 1787 | pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay()); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1788 | if (dumpAll) { |
| 1789 | pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); |
| 1790 | pw.print(" last="); mLastFrame.printShortString(pw); |
| 1791 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1792 | pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw); |
| 1793 | pw.print(" last="); mLastSystemDecorRect.printShortString(pw); |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 1794 | if (mWinAnimator.mHasClipRect) { |
| 1795 | pw.print(" mLastClipRect="); |
| 1796 | mWinAnimator.mLastClipRect.printShortString(pw); |
| 1797 | } |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1798 | pw.println(); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1799 | } |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1800 | if (mEnforceSizeCompat) { |
| 1801 | pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); |
Dianne Hackborn | ffb3d93 | 2011-05-17 17:44:51 -0700 | [diff] [blame] | 1802 | pw.println(); |
| 1803 | } |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1804 | if (dumpAll) { |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1805 | pw.print(prefix); pw.print("Frames: containing="); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1806 | mContainingFrame.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1807 | pw.print(" parent="); mParentFrame.printShortString(pw); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 1808 | pw.println(); |
| 1809 | pw.print(prefix); pw.print(" display="); mDisplayFrame.printShortString(pw); |
| 1810 | pw.print(" overscan="); mOverscanFrame.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1811 | pw.println(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1812 | pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1813 | pw.print(" visible="); mVisibleFrame.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1814 | pw.println(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 1815 | pw.print(prefix); pw.print(" decor="); mDecorFrame.printShortString(pw); |
| 1816 | pw.println(); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1817 | pw.print(prefix); pw.print(" outset="); mOutsetFrame.printShortString(pw); |
| 1818 | pw.println(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 1819 | pw.print(prefix); pw.print("Cur insets: overscan="); |
| 1820 | mOverscanInsets.printShortString(pw); |
| 1821 | pw.print(" content="); mContentInsets.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1822 | pw.print(" visible="); mVisibleInsets.printShortString(pw); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 1823 | pw.print(" stable="); mStableInsets.printShortString(pw); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1824 | pw.print(" outsets="); mOutsets.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1825 | pw.println(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 1826 | pw.print(prefix); pw.print("Lst insets: overscan="); |
| 1827 | mLastOverscanInsets.printShortString(pw); |
| 1828 | pw.print(" content="); mLastContentInsets.printShortString(pw); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 1829 | pw.print(" visible="); mLastVisibleInsets.printShortString(pw); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 1830 | pw.print(" stable="); mLastStableInsets.printShortString(pw); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1831 | pw.print(" physical="); mLastOutsets.printShortString(pw); |
| 1832 | pw.print(" outset="); mLastOutsets.printShortString(pw); |
Dianne Hackborn | a44abeb | 2011-08-08 19:24:01 -0700 | [diff] [blame] | 1833 | pw.println(); |
| 1834 | } |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 1835 | pw.print(prefix); pw.print(mWinAnimator); pw.println(":"); |
| 1836 | mWinAnimator.dump(pw, prefix + " ", dumpAll); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1837 | if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { |
| 1838 | pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); |
| 1839 | pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); |
| 1840 | pw.print(" mDestroying="); pw.print(mDestroying); |
| 1841 | pw.print(" mRemoved="); pw.println(mRemoved); |
| 1842 | } |
| 1843 | if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { |
| 1844 | pw.print(prefix); pw.print("mOrientationChanging="); |
| 1845 | pw.print(mOrientationChanging); |
| 1846 | pw.print(" mAppFreezing="); pw.print(mAppFreezing); |
| 1847 | pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); |
| 1848 | } |
Dianne Hackborn | a57c695 | 2013-03-29 14:46:40 -0700 | [diff] [blame] | 1849 | if (mLastFreezeDuration != 0) { |
| 1850 | pw.print(prefix); pw.print("mLastFreezeDuration="); |
| 1851 | TimeUtils.formatDuration(mLastFreezeDuration, pw); pw.println(); |
| 1852 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1853 | if (mHScale != 1 || mVScale != 1) { |
| 1854 | pw.print(prefix); pw.print("mHScale="); pw.print(mHScale); |
| 1855 | pw.print(" mVScale="); pw.println(mVScale); |
| 1856 | } |
| 1857 | if (mWallpaperX != -1 || mWallpaperY != -1) { |
| 1858 | pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); |
| 1859 | pw.print(" mWallpaperY="); pw.println(mWallpaperY); |
| 1860 | } |
| 1861 | if (mWallpaperXStep != -1 || mWallpaperYStep != -1) { |
| 1862 | pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep); |
| 1863 | pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep); |
| 1864 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1865 | if (mWallpaperDisplayOffsetX != Integer.MIN_VALUE |
| 1866 | || mWallpaperDisplayOffsetY != Integer.MIN_VALUE) { |
| 1867 | pw.print(prefix); pw.print("mWallpaperDisplayOffsetX="); |
| 1868 | pw.print(mWallpaperDisplayOffsetX); |
| 1869 | pw.print(" mWallpaperDisplayOffsetY="); |
| 1870 | pw.println(mWallpaperDisplayOffsetY); |
| 1871 | } |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 1872 | if (mDrawLock != null) { |
Wale Ogunwale | 85b90ab | 2015-04-27 20:54:47 -0700 | [diff] [blame] | 1873 | pw.print(prefix); pw.println("mDrawLock=" + mDrawLock); |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 1874 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1875 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1876 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1877 | String makeInputChannelName() { |
| 1878 | return Integer.toHexString(System.identityHashCode(this)) |
| 1879 | + " " + mAttrs.getTitle(); |
| 1880 | } |
| 1881 | |
| 1882 | @Override |
| 1883 | public String toString() { |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1884 | CharSequence title = mAttrs.getTitle(); |
| 1885 | if (title == null || title.length() <= 0) { |
| 1886 | title = mAttrs.packageName; |
| 1887 | } |
| 1888 | if (mStringNameCache == null || mLastTitle != title || mWasExiting != mExiting) { |
| 1889 | mLastTitle = title; |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 1890 | mWasExiting = mExiting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1891 | mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this)) |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 1892 | + " u" + UserHandle.getUserId(mSession.mUid) |
Craig Mautner | a987d43 | 2012-10-11 14:07:58 -0700 | [diff] [blame] | 1893 | + " " + mLastTitle + (mExiting ? " EXITING}" : "}"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1894 | } |
| 1895 | return mStringNameCache; |
| 1896 | } |
satok | cef37fb | 2011-10-24 21:49:38 +0900 | [diff] [blame] | 1897 | } |