Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
| 20 | import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 21 | import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 22 | import static android.app.ActivityManager.StackId.HOME_STACK_ID; |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 23 | import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 24 | import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 25 | import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION; |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 26 | import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS; |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 27 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 28 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE; |
| 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 31 | import static com.android.server.wm.WindowManagerService.H.RESIZE_TASK; |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 32 | import static com.android.server.wm.WindowManagerService.H.SHOW_NON_RESIZEABLE_DOCK_TOAST; |
| 33 | import static android.view.WindowManager.DOCKED_INVALID; |
| 34 | import static android.view.WindowManager.DOCKED_LEFT; |
| 35 | import static android.view.WindowManager.DOCKED_RIGHT; |
| 36 | import static android.view.WindowManager.DOCKED_TOP; |
Wale Ogunwale | 99db186 | 2015-10-23 20:08:22 -0700 | [diff] [blame] | 37 | |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 38 | import android.app.ActivityManager.StackId; |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 39 | import android.content.pm.ActivityInfo; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 40 | import android.content.res.Configuration; |
| 41 | import android.graphics.Rect; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 42 | import android.util.EventLog; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 43 | import android.util.Slog; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 44 | import android.view.DisplayInfo; |
| 45 | import android.view.Surface; |
| 46 | |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 47 | import com.android.internal.R; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 48 | import com.android.server.EventLogTags; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 49 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 50 | import java.io.PrintWriter; |
| 51 | import java.util.ArrayList; |
| 52 | |
| 53 | class Task implements DimLayer.DimLayerUser { |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 54 | static final String TAG = TAG_WITH_CLASS_NAME ? "Task" : TAG_WM; |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 55 | // Return value from {@link setBounds} indicating no change was made to the Task bounds. |
| 56 | static final int BOUNDS_CHANGE_NONE = 0; |
| 57 | // Return value from {@link setBounds} indicating the position of the Task bounds changed. |
| 58 | static final int BOUNDS_CHANGE_POSITION = 1; |
| 59 | // Return value from {@link setBounds} indicating the size of the Task bounds changed. |
| 60 | static final int BOUNDS_CHANGE_SIZE = 1 << 1; |
| 61 | |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 62 | TaskStack mStack; |
Craig Mautner | 05d6272ba | 2013-02-11 09:39:27 -0800 | [diff] [blame] | 63 | final AppTokenList mAppTokens = new AppTokenList(); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 64 | final int mTaskId; |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 65 | final int mUserId; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 66 | boolean mDeferRemoval = false; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 67 | final WindowManagerService mService; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 68 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 69 | // Content limits relative to the DisplayContent this sits in. |
| 70 | private Rect mBounds = new Rect(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 71 | final Rect mPreparedFrozenBounds = new Rect(); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 72 | |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 73 | private Rect mPreScrollBounds = new Rect(); |
| 74 | private boolean mScrollValid; |
| 75 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 76 | // Bounds used to calculate the insets. |
| 77 | private final Rect mTempInsetBounds = new Rect(); |
| 78 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 79 | // Device rotation as of the last time {@link #mBounds} was set. |
| 80 | int mRotation; |
| 81 | |
| 82 | // Whether mBounds is fullscreen |
| 83 | private boolean mFullscreen = true; |
| 84 | |
| 85 | // Contains configurations settings that are different from the global configuration due to |
| 86 | // stack specific operations. E.g. {@link #setBounds}. |
| 87 | Configuration mOverrideConfig; |
| 88 | |
| 89 | // For comparison with DisplayContent bounds. |
| 90 | private Rect mTmpRect = new Rect(); |
| 91 | // For handling display rotations. |
| 92 | private Rect mTmpRect2 = new Rect(); |
| 93 | |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 94 | // Resize mode of the task. See {@link ActivityInfo#resizeMode} |
| 95 | private int mResizeMode; |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 96 | |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 97 | // Whether we need to show toast about the app being non-resizeable when it becomes visible. |
| 98 | // This flag is set when a non-resizeable task is docked (or side-by-side). It's cleared |
| 99 | // after we show the toast. |
| 100 | private boolean mShowNonResizeableDockToast; |
| 101 | |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 102 | // Whether the task is currently being drag-resized |
| 103 | private boolean mDragResizing; |
| 104 | |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 105 | private boolean mHomeTask; |
| 106 | |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 107 | Task(int taskId, TaskStack stack, int userId, WindowManagerService service, Rect bounds, |
| 108 | Configuration config) { |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 109 | mTaskId = taskId; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 110 | mStack = stack; |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 111 | mUserId = userId; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 112 | mService = service; |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 113 | setBounds(bounds, config); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | DisplayContent getDisplayContent() { |
| 117 | return mStack.getDisplayContent(); |
| 118 | } |
| 119 | |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 120 | void setShowNonResizeableDockToast() { |
| 121 | mShowNonResizeableDockToast = true; |
| 122 | } |
| 123 | |
| 124 | void scheduleShowNonResizeableDockToastIfNeeded() { |
| 125 | if (!mShowNonResizeableDockToast) { |
| 126 | return; |
| 127 | } |
| 128 | final DisplayContent displayContent = mStack.getDisplayContent(); |
| 129 | // If docked stack is not yet visible, we don't want to show the toast yet, |
| 130 | // since we need the visible rect of the docked task to position the toast. |
| 131 | if (displayContent == null || displayContent.getDockedStackLocked() == null) { |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | mShowNonResizeableDockToast = false; |
| 136 | |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 137 | if (isResizeable()) { |
| 138 | Slog.wtf(TAG, |
| 139 | "Trying to show non-resizeable toast when task is resizeable task=" + this); |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | if (mResizeMode == RESIZE_MODE_UNRESIZEABLE) { |
| 144 | final String text = |
| 145 | mService.mContext.getString(R.string.dock_non_resizeble_failed_to_dock_text); |
| 146 | mService.mH.obtainMessage(SHOW_NON_RESIZEABLE_DOCK_TOAST, 0, 0, text).sendToTarget(); |
| 147 | return; |
| 148 | } |
| 149 | |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 150 | final int dockSide = mStack.getDockSide(); |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 151 | if (!inCropWindowsResizeMode() || dockSide == DOCKED_INVALID) { |
| 152 | return; |
| 153 | } |
| 154 | |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 155 | int xOffset = 0; |
| 156 | int yOffset = 0; |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 157 | mStack.getBounds(mTmpRect); |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 158 | |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 159 | if (dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT) { |
| 160 | // The toast was originally placed at the bottom and centered. To place it at the |
| 161 | // bottom-center of the stack, we offset it horizontally by the diff between the center |
| 162 | // of the stack bounds vs. the center of the screen. |
| 163 | displayContent.getLogicalDisplayRect(mTmpRect2); |
| 164 | xOffset = mTmpRect.centerX() - mTmpRect2.centerX(); |
| 165 | } else if (dockSide == DOCKED_TOP) { |
| 166 | // The toast was originally placed at the bottom and centered. To place it at the bottom |
| 167 | // center of the top stack, we offset it vertically by the diff between the bottom of |
| 168 | // the stack bounds vs. the bottom of the content rect. |
| 169 | // |
| 170 | // Note here we use the content rect instead of the display rect, as we want the toast's |
| 171 | // distance to the dock divider (when it's placed at the top half) to be the same as |
| 172 | // it's distance to the top of the navigation bar (when it's placed at the bottom). |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 173 | |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 174 | // We don't adjust for DOCKED_BOTTOM case since it's already at the bottom. |
| 175 | displayContent.getContentRect(mTmpRect2); |
| 176 | yOffset = mTmpRect2.bottom - mTmpRect.bottom; |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 177 | } |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 178 | final String text = |
| 179 | mService.mContext.getString(R.string.dock_cropped_windows_text); |
| 180 | mService.mH.obtainMessage(SHOW_NON_RESIZEABLE_DOCK_TOAST, |
| 181 | xOffset, yOffset, text).sendToTarget(); |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 184 | void addAppToken(int addPos, AppWindowToken wtoken, int resizeMode, boolean homeTask) { |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 185 | final int lastPos = mAppTokens.size(); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 186 | if (addPos >= lastPos) { |
| 187 | addPos = lastPos; |
| 188 | } else { |
| 189 | for (int pos = 0; pos < lastPos && pos < addPos; ++pos) { |
| 190 | if (mAppTokens.get(pos).removed) { |
| 191 | // addPos assumes removed tokens are actually gone. |
| 192 | ++addPos; |
| 193 | } |
Craig Mautner | 01f79cf | 2014-08-27 09:56:02 -0700 | [diff] [blame] | 194 | } |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 195 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 196 | mAppTokens.add(addPos, wtoken); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 197 | wtoken.mTask = this; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 198 | mDeferRemoval = false; |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 199 | mResizeMode = resizeMode; |
| 200 | mHomeTask = homeTask; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 201 | } |
| 202 | |
Chong Zhang | 7e8eeb7 | 2016-01-06 19:14:47 -0800 | [diff] [blame] | 203 | private boolean hasAppTokensAlive() { |
| 204 | for (int i = mAppTokens.size() - 1; i >= 0; i--) { |
| 205 | if (!mAppTokens.get(i).appDied) { |
| 206 | return true; |
| 207 | } |
| 208 | } |
| 209 | return false; |
| 210 | } |
| 211 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 212 | void removeLocked() { |
Chong Zhang | 7e8eeb7 | 2016-01-06 19:14:47 -0800 | [diff] [blame] | 213 | if (hasAppTokensAlive() && mStack.isAnimating()) { |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 214 | if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + mTaskId); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 215 | mDeferRemoval = true; |
| 216 | return; |
| 217 | } |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 218 | if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing taskId=" + mTaskId); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 219 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "removeTask"); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 220 | mDeferRemoval = false; |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 221 | DisplayContent content = getDisplayContent(); |
| 222 | if (content != null) { |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 223 | content.mDimLayerController.removeDimLayerUser(this); |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 224 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 225 | mStack.removeTask(this); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 226 | mService.mTaskIdToTask.delete(mTaskId); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Wale Ogunwale | 53a29a9 | 2015-02-23 15:42:52 -0800 | [diff] [blame] | 229 | void moveTaskToStack(TaskStack stack, boolean toTop) { |
| 230 | if (stack == mStack) { |
| 231 | return; |
| 232 | } |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 233 | if (DEBUG_STACK) Slog.i(TAG, "moveTaskToStack: removing taskId=" + mTaskId |
Wale Ogunwale | 53a29a9 | 2015-02-23 15:42:52 -0800 | [diff] [blame] | 234 | + " from stack=" + mStack); |
Wale Ogunwale | 000957c | 2015-04-03 08:19:12 -0700 | [diff] [blame] | 235 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "moveTask"); |
Wale Ogunwale | 53a29a9 | 2015-02-23 15:42:52 -0800 | [diff] [blame] | 236 | if (mStack != null) { |
| 237 | mStack.removeTask(this); |
| 238 | } |
| 239 | stack.addTask(this, toTop); |
| 240 | } |
| 241 | |
Wale Ogunwale | 935e502 | 2015-11-10 12:36:10 -0800 | [diff] [blame] | 242 | void positionTaskInStack(TaskStack stack, int position, Rect bounds, Configuration config) { |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 243 | if (mStack != null && stack != mStack) { |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 244 | if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: removing taskId=" + mTaskId |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 245 | + " from stack=" + mStack); |
| 246 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "moveTask"); |
| 247 | mStack.removeTask(this); |
| 248 | } |
| 249 | stack.positionTask(this, position, showForAllUsers()); |
Wale Ogunwale | 935e502 | 2015-11-10 12:36:10 -0800 | [diff] [blame] | 250 | setBounds(bounds, config); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 253 | boolean removeAppToken(AppWindowToken wtoken) { |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 254 | boolean removed = mAppTokens.remove(wtoken); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 255 | if (mAppTokens.size() == 0) { |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 256 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "removeAppToken: last token"); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 257 | if (mDeferRemoval) { |
| 258 | removeLocked(); |
| 259 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 260 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 261 | wtoken.mTask = null; |
| 262 | /* Leave mTaskId for now, it might be useful for debug |
| 263 | wtoken.mTaskId = -1; |
| 264 | */ |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 265 | return removed; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 266 | } |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 267 | |
Craig Mautner | cbd84af | 2014-10-22 13:21:22 -0700 | [diff] [blame] | 268 | void setSendingToBottom(boolean toBottom) { |
| 269 | for (int appTokenNdx = 0; appTokenNdx < mAppTokens.size(); appTokenNdx++) { |
| 270 | mAppTokens.get(appTokenNdx).sendingToBottom = toBottom; |
| 271 | } |
| 272 | } |
| 273 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 274 | /** Set the task bounds. Passing in null sets the bounds to fullscreen. */ |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 275 | int setBounds(Rect bounds, Configuration config) { |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 276 | if (config == null) { |
| 277 | config = Configuration.EMPTY; |
| 278 | } |
| 279 | if (bounds == null && !Configuration.EMPTY.equals(config)) { |
| 280 | throw new IllegalArgumentException("null bounds but non empty configuration: " |
| 281 | + config); |
| 282 | } |
| 283 | if (bounds != null && Configuration.EMPTY.equals(config)) { |
| 284 | throw new IllegalArgumentException("non null bounds, but empty configuration"); |
| 285 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 286 | boolean oldFullscreen = mFullscreen; |
| 287 | int rotation = Surface.ROTATION_0; |
| 288 | final DisplayContent displayContent = mStack.getDisplayContent(); |
| 289 | if (displayContent != null) { |
| 290 | displayContent.getLogicalDisplayRect(mTmpRect); |
| 291 | rotation = displayContent.getDisplayInfo().rotation; |
Jorim Jaggi | 067e817 | 2016-02-03 18:24:12 -0800 | [diff] [blame] | 292 | mFullscreen = bounds == null; |
| 293 | if (mFullscreen) { |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 294 | bounds = mTmpRect; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
| 298 | if (bounds == null) { |
| 299 | // Can't set to fullscreen if we don't have a display to get bounds from... |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 300 | return BOUNDS_CHANGE_NONE; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 301 | } |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 302 | if (mPreScrollBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) { |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 303 | return BOUNDS_CHANGE_NONE; |
| 304 | } |
| 305 | |
| 306 | int boundsChange = BOUNDS_CHANGE_NONE; |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 307 | if (mPreScrollBounds.left != bounds.left || mPreScrollBounds.top != bounds.top) { |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 308 | boundsChange |= BOUNDS_CHANGE_POSITION; |
| 309 | } |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 310 | if (mPreScrollBounds.width() != bounds.width() || mPreScrollBounds.height() != bounds.height()) { |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 311 | boundsChange |= BOUNDS_CHANGE_SIZE; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 314 | |
| 315 | mPreScrollBounds.set(bounds); |
| 316 | |
| 317 | resetScrollLocked(); |
| 318 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 319 | mRotation = rotation; |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 320 | if (displayContent != null) { |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 321 | displayContent.mDimLayerController.updateDimLayer(this); |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 322 | } |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 323 | mOverrideConfig = mFullscreen ? Configuration.EMPTY : config; |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 324 | return boundsChange; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 327 | /** |
| 328 | * Sets the bounds used to calculate the insets. See |
| 329 | * {@link android.app.IActivityManager#resizeDockedStack} why this is needed. |
| 330 | */ |
| 331 | void setTempInsetBounds(Rect tempInsetBounds) { |
| 332 | if (tempInsetBounds != null) { |
| 333 | mTempInsetBounds.set(tempInsetBounds); |
| 334 | } else { |
| 335 | mTempInsetBounds.setEmpty(); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Gets the bounds used to calculate the insets. See |
| 341 | * {@link android.app.IActivityManager#resizeDockedStack} why this is needed. |
| 342 | */ |
| 343 | void getTempInsetBounds(Rect out) { |
| 344 | out.set(mTempInsetBounds); |
| 345 | } |
| 346 | |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 347 | void setResizeable(int resizeMode) { |
| 348 | mResizeMode = resizeMode; |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | boolean isResizeable() { |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 352 | return !mHomeTask |
| 353 | && (ActivityInfo.isResizeableMode(mResizeMode) || mService.mForceResizableTasks); |
| 354 | } |
| 355 | |
| 356 | boolean cropWindowsToStackBounds() { |
| 357 | return !mHomeTask && (isResizeable() || mResizeMode == RESIZE_MODE_CROP_WINDOWS); |
| 358 | } |
| 359 | |
| 360 | private boolean inCropWindowsResizeMode() { |
| 361 | return !mHomeTask && !isResizeable() && mResizeMode == RESIZE_MODE_CROP_WINDOWS; |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 362 | } |
| 363 | |
Chong Zhang | 87b2172 | 2015-09-21 15:39:51 -0700 | [diff] [blame] | 364 | boolean resizeLocked(Rect bounds, Configuration configuration, boolean forced) { |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 365 | int boundsChanged = setBounds(bounds, configuration); |
Chong Zhang | 87b2172 | 2015-09-21 15:39:51 -0700 | [diff] [blame] | 366 | if (forced) { |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 367 | boundsChanged |= BOUNDS_CHANGE_SIZE; |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 368 | } |
| 369 | if (boundsChanged == BOUNDS_CHANGE_NONE) { |
| 370 | return false; |
| 371 | } |
| 372 | if ((boundsChanged & BOUNDS_CHANGE_SIZE) == BOUNDS_CHANGE_SIZE) { |
| 373 | resizeWindows(); |
Chong Zhang | bd0d937 | 2015-12-28 15:18:29 -0800 | [diff] [blame] | 374 | } else { |
| 375 | moveWindows(); |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 376 | } |
| 377 | return true; |
| 378 | } |
| 379 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 380 | /** |
| 381 | * Prepares the task bounds to be frozen with the current size. See |
| 382 | * {@link AppWindowToken#freezeBounds}. |
| 383 | */ |
| 384 | void prepareFreezingBounds() { |
| 385 | mPreparedFrozenBounds.set(mBounds); |
| 386 | } |
| 387 | |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 388 | void resetScrollLocked() { |
| 389 | if (mScrollValid) { |
| 390 | mScrollValid = false; |
| 391 | applyScrollToAllWindows(0, 0); |
| 392 | } |
| 393 | mBounds.set(mPreScrollBounds); |
| 394 | } |
| 395 | |
| 396 | void applyScrollToAllWindows(final int xOffset, final int yOffset) { |
| 397 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 398 | final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows; |
| 399 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 400 | final WindowState win = windows.get(winNdx); |
| 401 | win.mXOffset = xOffset; |
| 402 | win.mYOffset = yOffset; |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | void applyScrollToWindowIfNeeded(final WindowState win) { |
| 408 | if (mScrollValid) { |
| 409 | win.mXOffset = mBounds.left; |
| 410 | win.mYOffset = mBounds.top; |
| 411 | } |
| 412 | } |
| 413 | |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 414 | boolean scrollLocked(Rect bounds) { |
| 415 | // shift the task bound if it doesn't fully cover the stack area |
| 416 | mStack.getDimBounds(mTmpRect); |
| 417 | if (mService.mCurConfiguration.orientation == ORIENTATION_LANDSCAPE) { |
| 418 | if (bounds.left > mTmpRect.left) { |
| 419 | bounds.left = mTmpRect.left; |
| 420 | bounds.right = mTmpRect.left + mBounds.width(); |
| 421 | } else if (bounds.right < mTmpRect.right) { |
| 422 | bounds.left = mTmpRect.right - mBounds.width(); |
| 423 | bounds.right = mTmpRect.right; |
| 424 | } |
| 425 | } else { |
| 426 | if (bounds.top > mTmpRect.top) { |
| 427 | bounds.top = mTmpRect.top; |
| 428 | bounds.bottom = mTmpRect.top + mBounds.height(); |
| 429 | } else if (bounds.bottom < mTmpRect.bottom) { |
| 430 | bounds.top = mTmpRect.bottom - mBounds.height(); |
| 431 | bounds.bottom = mTmpRect.bottom; |
| 432 | } |
| 433 | } |
| 434 | |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 435 | // We can stop here if we're already scrolling and the scrolled bounds not changed. |
| 436 | if (mScrollValid && bounds.equals(mBounds)) { |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 437 | return false; |
| 438 | } |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 439 | |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 440 | // Normal setBounds() does not allow non-null bounds for fullscreen apps. |
| 441 | // We only change bounds for the scrolling case without change it size, |
| 442 | // on resizing path we should still want the validation. |
| 443 | mBounds.set(bounds); |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 444 | mScrollValid = true; |
| 445 | applyScrollToAllWindows(bounds.left, bounds.top); |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 446 | return true; |
| 447 | } |
| 448 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 449 | /** Return true if the current bound can get outputted to the rest of the system as-is. */ |
| 450 | private boolean useCurrentBounds() { |
| 451 | final DisplayContent displayContent = mStack.getDisplayContent(); |
| 452 | if (mFullscreen |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 453 | || !StackId.isTaskResizeableByDockedStack(mStack.mStackId) |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 454 | || displayContent == null |
| 455 | || displayContent.getDockedStackLocked() != null) { |
| 456 | return true; |
| 457 | } |
| 458 | return false; |
| 459 | } |
| 460 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 461 | /** Original bounds of the task if applicable, otherwise fullscreen rect. */ |
Wale Ogunwale | ccb6ce2 | 2016-01-14 15:36:35 -0800 | [diff] [blame] | 462 | void getBounds(Rect out) { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 463 | if (useCurrentBounds()) { |
| 464 | // No need to adjust the output bounds if fullscreen or the docked stack is visible |
| 465 | // since it is already what we want to represent to the rest of the system. |
| 466 | out.set(mBounds); |
| 467 | return; |
| 468 | } |
| 469 | |
Wale Ogunwale | ccb6ce2 | 2016-01-14 15:36:35 -0800 | [diff] [blame] | 470 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack is |
| 471 | // not currently visible. Go ahead a represent it as fullscreen to the rest of the system. |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 472 | mStack.getDisplayContent().getLogicalDisplayRect(out); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 475 | /** |
| 476 | * Calculate the maximum visible area of this task. If the task has only one app, |
| 477 | * the result will be visible frame of that app. If the task has more than one apps, |
| 478 | * we search from top down if the next app got different visible area. |
| 479 | * |
| 480 | * This effort is to handle the case where some task (eg. GMail composer) might pop up |
| 481 | * a dialog that's different in size from the activity below, in which case we should |
| 482 | * be dimming the entire task area behind the dialog. |
| 483 | * |
| 484 | * @param out Rect containing the max visible bounds. |
| 485 | * @return true if the task has some visible app windows; false otherwise. |
| 486 | */ |
| 487 | boolean getMaxVisibleBounds(Rect out) { |
| 488 | boolean foundTop = false; |
| 489 | for (int i = mAppTokens.size() - 1; i >= 0; i--) { |
Chong Zhang | d8ceb85 | 2015-11-11 14:53:41 -0800 | [diff] [blame] | 490 | final AppWindowToken token = mAppTokens.get(i); |
| 491 | // skip hidden (or about to hide) apps |
| 492 | if (token.mIsExiting || token.clientHidden || token.hiddenRequested) { |
| 493 | continue; |
| 494 | } |
| 495 | final WindowState win = token.findMainWindow(); |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 496 | if (win == null) { |
| 497 | continue; |
| 498 | } |
| 499 | if (!foundTop) { |
| 500 | out.set(win.mVisibleFrame); |
| 501 | foundTop = true; |
| 502 | continue; |
| 503 | } |
| 504 | if (win.mVisibleFrame.left < out.left) { |
| 505 | out.left = win.mVisibleFrame.left; |
| 506 | } |
| 507 | if (win.mVisibleFrame.top < out.top) { |
| 508 | out.top = win.mVisibleFrame.top; |
| 509 | } |
| 510 | if (win.mVisibleFrame.right > out.right) { |
| 511 | out.right = win.mVisibleFrame.right; |
| 512 | } |
| 513 | if (win.mVisibleFrame.bottom > out.bottom) { |
| 514 | out.bottom = win.mVisibleFrame.bottom; |
| 515 | } |
| 516 | } |
| 517 | return foundTop; |
| 518 | } |
| 519 | |
| 520 | /** Bounds of the task to be used for dimming, as well as touch related tests. */ |
| 521 | @Override |
| 522 | public void getDimBounds(Rect out) { |
| 523 | if (useCurrentBounds()) { |
| 524 | if (inFreeformWorkspace() && getMaxVisibleBounds(out)) { |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | out.set(mBounds); |
| 529 | return; |
| 530 | } |
| 531 | |
| 532 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 533 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 534 | // system. |
| 535 | mStack.getDisplayContent().getLogicalDisplayRect(out); |
| 536 | } |
| 537 | |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 538 | void setDragResizing(boolean dragResizing) { |
Jorim Jaggi | c662d8e | 2016-02-05 16:54:54 -0800 | [diff] [blame^] | 539 | if (mDragResizing != dragResizing) { |
| 540 | mDragResizing = dragResizing; |
| 541 | resetDragResizingChangeReported(); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | void resetDragResizingChangeReported() { |
| 546 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 547 | final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows; |
| 548 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 549 | final WindowState win = windows.get(winNdx); |
| 550 | win.resetDragResizingChangeReported(); |
| 551 | } |
| 552 | } |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | boolean isDragResizing() { |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 556 | return mDragResizing || (mStack != null && mStack.isDragResizing()); |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 559 | void updateDisplayInfo(final DisplayContent displayContent) { |
| 560 | if (displayContent == null) { |
| 561 | return; |
| 562 | } |
| 563 | if (mFullscreen) { |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 564 | setBounds(null, Configuration.EMPTY); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 565 | return; |
| 566 | } |
| 567 | final int newRotation = displayContent.getDisplayInfo().rotation; |
| 568 | if (mRotation == newRotation) { |
| 569 | return; |
| 570 | } |
| 571 | |
Wale Ogunwale | e1fe4d1 | 2016-01-14 08:52:30 -0800 | [diff] [blame] | 572 | // Device rotation changed. |
| 573 | // - Reset the bounds to the pre-scroll bounds as whatever scrolling was done is no longer |
| 574 | // valid. |
| 575 | // - Rotate the bounds and notify activity manager if the task can be resized independently |
| 576 | // from its stack. The stack will take care of task rotation for the other case. |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 577 | mTmpRect2.set(mPreScrollBounds); |
Wale Ogunwale | e1fe4d1 | 2016-01-14 08:52:30 -0800 | [diff] [blame] | 578 | |
| 579 | if (!StackId.isTaskResizeAllowed(mStack.mStackId)) { |
| 580 | setBounds(mTmpRect2, mOverrideConfig); |
| 581 | return; |
| 582 | } |
| 583 | |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 584 | displayContent.rotateBounds(mRotation, newRotation, mTmpRect2); |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 585 | if (setBounds(mTmpRect2, mOverrideConfig) != BOUNDS_CHANGE_NONE) { |
Wale Ogunwale | e1fe4d1 | 2016-01-14 08:52:30 -0800 | [diff] [blame] | 586 | // Post message to inform activity manager of the bounds change simulating a one-way |
| 587 | // call. We do this to prevent a deadlock between window manager lock and activity |
| 588 | // manager lock been held. |
| 589 | mService.mH.obtainMessage(RESIZE_TASK, mTaskId, |
| 590 | RESIZE_MODE_SYSTEM_SCREEN_ROTATION, mPreScrollBounds).sendToTarget(); |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 591 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 594 | void resizeWindows() { |
| 595 | final ArrayList<WindowState> resizingWindows = mService.mResizingWindows; |
| 596 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 597 | final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows; |
| 598 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 599 | final WindowState win = windows.get(winNdx); |
Jorim Jaggi | 69abc19 | 2016-02-04 19:34:00 -0800 | [diff] [blame] | 600 | if (win.mHasSurface && !resizingWindows.contains(win)) { |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 601 | if (DEBUG_RESIZE) Slog.d(TAG, "resizeWindows: Resizing " + win); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 602 | resizingWindows.add(win); |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
Chong Zhang | bd0d937 | 2015-12-28 15:18:29 -0800 | [diff] [blame] | 608 | void moveWindows() { |
| 609 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 610 | final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows; |
| 611 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 612 | final WindowState win = windows.get(winNdx); |
Wale Ogunwale | b9b16a7 | 2016-01-27 12:24:44 -0800 | [diff] [blame] | 613 | if (DEBUG_RESIZE) Slog.d(TAG, "moveWindows: Moving " + win); |
Chong Zhang | bd0d937 | 2015-12-28 15:18:29 -0800 | [diff] [blame] | 614 | win.mMovedByResize = true; |
| 615 | } |
| 616 | } |
| 617 | } |
| 618 | |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 619 | /** |
| 620 | * Cancels any running app transitions associated with the task. |
| 621 | */ |
| 622 | void cancelTaskWindowTransition() { |
| 623 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 624 | mAppTokens.get(activityNdx).mAppAnimator.clearAnimation(); |
| 625 | } |
| 626 | } |
| 627 | |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 628 | /** |
| 629 | * Cancels any running thumbnail transitions associated with the task. |
| 630 | */ |
| 631 | void cancelTaskThumbnailTransition() { |
| 632 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 633 | mAppTokens.get(activityNdx).mAppAnimator.clearThumbnail(); |
| 634 | } |
| 635 | } |
| 636 | |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 637 | boolean showForAllUsers() { |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 638 | final int tokensCount = mAppTokens.size(); |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 639 | return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers; |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 642 | boolean inHomeStack() { |
| 643 | return mStack != null && mStack.mStackId == HOME_STACK_ID; |
| 644 | } |
| 645 | |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 646 | boolean inFreeformWorkspace() { |
| 647 | return mStack != null && mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID; |
| 648 | } |
| 649 | |
Filip Gruszczynski | 955b2fc | 2015-10-15 14:46:07 -0700 | [diff] [blame] | 650 | boolean inDockedWorkspace() { |
| 651 | return mStack != null && mStack.mStackId == DOCKED_STACK_ID; |
| 652 | } |
| 653 | |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 654 | boolean isResizeableByDockedStack() { |
Wale Ogunwale | 5e7409c | 2016-01-11 12:24:19 -0800 | [diff] [blame] | 655 | final DisplayContent displayContent = getDisplayContent(); |
| 656 | return displayContent != null && displayContent.getDockedStackLocked() != null |
| 657 | && mStack != null && StackId.isTaskResizeableByDockedStack(mStack.mStackId); |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | /** |
| 661 | * Whether the task should be treated as if it's docked. Returns true if the task |
| 662 | * is currently in docked workspace, or it's side-by-side to a docked task. |
| 663 | */ |
| 664 | boolean isDockedInEffect() { |
| 665 | return inDockedWorkspace() || isResizeableByDockedStack(); |
| 666 | } |
| 667 | |
Chong Zhang | 2a88fc3 | 2016-01-11 17:14:24 -0800 | [diff] [blame] | 668 | boolean isTwoFingerScrollMode() { |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 669 | return inCropWindowsResizeMode() && isDockedInEffect(); |
Chong Zhang | 2a88fc3 | 2016-01-11 17:14:24 -0800 | [diff] [blame] | 670 | } |
| 671 | |
Chong Zhang | d8ceb85 | 2015-11-11 14:53:41 -0800 | [diff] [blame] | 672 | WindowState getTopVisibleAppMainWindow() { |
| 673 | final AppWindowToken token = getTopVisibleAppToken(); |
| 674 | return token != null ? token.findMainWindow() : null; |
Chong Zhang | 9184ec6 | 2015-09-24 12:32:21 -0700 | [diff] [blame] | 675 | } |
| 676 | |
Chong Zhang | d8ceb85 | 2015-11-11 14:53:41 -0800 | [diff] [blame] | 677 | AppWindowToken getTopVisibleAppToken() { |
| 678 | for (int i = mAppTokens.size() - 1; i >= 0; i--) { |
| 679 | final AppWindowToken token = mAppTokens.get(i); |
| 680 | // skip hidden (or about to hide) apps |
| 681 | if (!token.mIsExiting && !token.clientHidden && !token.hiddenRequested) { |
| 682 | return token; |
| 683 | } |
| 684 | } |
| 685 | return null; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 686 | } |
| 687 | |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 688 | @Override |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 689 | public boolean isFullscreen() { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 690 | if (useCurrentBounds()) { |
| 691 | return mFullscreen; |
| 692 | } |
| 693 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 694 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 695 | // system. |
| 696 | return true; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | @Override |
| 700 | public DisplayInfo getDisplayInfo() { |
| 701 | return mStack.getDisplayContent().getDisplayInfo(); |
| 702 | } |
| 703 | |
| 704 | @Override |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 705 | public String toString() { |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 706 | return "{taskId=" + mTaskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}"; |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 707 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 708 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 709 | @Override |
| 710 | public String toShortString() { |
| 711 | return "Task=" + mTaskId; |
| 712 | } |
| 713 | |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 714 | public void dump(String prefix, PrintWriter pw) { |
| 715 | final String doublePrefix = prefix + " "; |
| 716 | |
| 717 | pw.println(prefix + "taskId=" + mTaskId); |
| 718 | pw.println(doublePrefix + "mFullscreen=" + mFullscreen); |
| 719 | pw.println(doublePrefix + "mBounds=" + mBounds.toShortString()); |
| 720 | pw.println(doublePrefix + "mdr=" + mDeferRemoval); |
| 721 | pw.println(doublePrefix + "appTokens=" + mAppTokens); |
| 722 | pw.println(doublePrefix + "mTempInsetBounds=" + mTempInsetBounds.toShortString()); |
| 723 | |
| 724 | final String triplePrefix = doublePrefix + " "; |
| 725 | |
| 726 | for (int i = mAppTokens.size() - 1; i >= 0; i--) { |
| 727 | final AppWindowToken wtoken = mAppTokens.get(i); |
| 728 | pw.println(triplePrefix + "Activity #" + i + " " + wtoken); |
| 729 | wtoken.dump(pw, triplePrefix); |
| 730 | } |
| 731 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 732 | } |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 733 | } |