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