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