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