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