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