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