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