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