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