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 | |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.DOCKED_STACK_ID; |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 20 | import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 21 | import static com.android.server.wm.WindowManagerService.TAG; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 22 | import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 23 | import static com.android.server.wm.WindowManagerService.DEBUG_STACK; |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 24 | import static com.android.server.wm.WindowManagerService.H.RESIZE_TASK; |
Stefan Kuhne | 234dbf8 | 2015-08-13 09:44:28 -0700 | [diff] [blame] | 25 | import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 26 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 27 | import android.content.res.Configuration; |
| 28 | import android.graphics.Rect; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 29 | import android.util.EventLog; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 30 | import android.util.Slog; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 31 | import android.util.SparseArray; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 32 | import android.view.DisplayInfo; |
| 33 | import android.view.Surface; |
| 34 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 35 | import com.android.server.EventLogTags; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 36 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 37 | import java.io.PrintWriter; |
| 38 | import java.util.ArrayList; |
| 39 | |
| 40 | class Task implements DimLayer.DimLayerUser { |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 41 | // Return value from {@link setBounds} indicating no change was made to the Task bounds. |
| 42 | static final int BOUNDS_CHANGE_NONE = 0; |
| 43 | // Return value from {@link setBounds} indicating the position of the Task bounds changed. |
| 44 | static final int BOUNDS_CHANGE_POSITION = 1; |
| 45 | // Return value from {@link setBounds} indicating the size of the Task bounds changed. |
| 46 | static final int BOUNDS_CHANGE_SIZE = 1 << 1; |
| 47 | |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 48 | TaskStack mStack; |
Craig Mautner | 05d6272ba | 2013-02-11 09:39:27 -0800 | [diff] [blame] | 49 | final AppTokenList mAppTokens = new AppTokenList(); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 50 | final int mTaskId; |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 51 | final int mUserId; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 52 | boolean mDeferRemoval = false; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 53 | final WindowManagerService mService; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 54 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 55 | // Content limits relative to the DisplayContent this sits in. |
| 56 | private Rect mBounds = new Rect(); |
| 57 | |
| 58 | // Device rotation as of the last time {@link #mBounds} was set. |
| 59 | int mRotation; |
| 60 | |
| 61 | // Whether mBounds is fullscreen |
| 62 | private boolean mFullscreen = true; |
| 63 | |
| 64 | // Contains configurations settings that are different from the global configuration due to |
| 65 | // stack specific operations. E.g. {@link #setBounds}. |
| 66 | Configuration mOverrideConfig; |
| 67 | |
| 68 | // For comparison with DisplayContent bounds. |
| 69 | private Rect mTmpRect = new Rect(); |
| 70 | // For handling display rotations. |
| 71 | private Rect mTmpRect2 = new Rect(); |
| 72 | |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 73 | // Whether the task is currently being drag-resized |
| 74 | private boolean mDragResizing; |
| 75 | |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 76 | Task(int taskId, TaskStack stack, int userId, WindowManagerService service, Rect bounds, |
| 77 | Configuration config) { |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 78 | mTaskId = taskId; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 79 | mStack = stack; |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 80 | mUserId = userId; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 81 | mService = service; |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 82 | setBounds(bounds, config); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | DisplayContent getDisplayContent() { |
| 86 | return mStack.getDisplayContent(); |
| 87 | } |
| 88 | |
| 89 | void addAppToken(int addPos, AppWindowToken wtoken) { |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 90 | final int lastPos = mAppTokens.size(); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 91 | if (addPos >= lastPos) { |
| 92 | addPos = lastPos; |
| 93 | } else { |
| 94 | for (int pos = 0; pos < lastPos && pos < addPos; ++pos) { |
| 95 | if (mAppTokens.get(pos).removed) { |
| 96 | // addPos assumes removed tokens are actually gone. |
| 97 | ++addPos; |
| 98 | } |
Craig Mautner | 01f79cf | 2014-08-27 09:56:02 -0700 | [diff] [blame] | 99 | } |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 100 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 101 | mAppTokens.add(addPos, wtoken); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 102 | wtoken.mTask = this; |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 103 | mDeferRemoval = false; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 106 | void removeLocked() { |
| 107 | if (!mAppTokens.isEmpty() && mStack.isAnimating()) { |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 108 | if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + mTaskId); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 109 | mDeferRemoval = true; |
| 110 | return; |
| 111 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 112 | if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing taskId=" + mTaskId); |
| 113 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "removeTask"); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 114 | mDeferRemoval = false; |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame^] | 115 | DisplayContent content = getDisplayContent(); |
| 116 | if (content != null) { |
| 117 | content.mDimBehindController.removeDimLayerUser(this); |
| 118 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 119 | mStack.removeTask(this); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 120 | mService.mTaskIdToTask.delete(mTaskId); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 121 | } |
| 122 | |
Wale Ogunwale | 53a29a9 | 2015-02-23 15:42:52 -0800 | [diff] [blame] | 123 | void moveTaskToStack(TaskStack stack, boolean toTop) { |
| 124 | if (stack == mStack) { |
| 125 | return; |
| 126 | } |
| 127 | if (DEBUG_STACK) Slog.i(TAG, "moveTaskToStack: removing taskId=" + mTaskId |
| 128 | + " from stack=" + mStack); |
Wale Ogunwale | 000957c | 2015-04-03 08:19:12 -0700 | [diff] [blame] | 129 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "moveTask"); |
Wale Ogunwale | 53a29a9 | 2015-02-23 15:42:52 -0800 | [diff] [blame] | 130 | if (mStack != null) { |
| 131 | mStack.removeTask(this); |
| 132 | } |
| 133 | stack.addTask(this, toTop); |
| 134 | } |
| 135 | |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 136 | void positionTaskInStack(TaskStack stack, int position) { |
| 137 | if (mStack != null && stack != mStack) { |
| 138 | if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: removing taskId=" + mTaskId |
| 139 | + " from stack=" + mStack); |
| 140 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "moveTask"); |
| 141 | mStack.removeTask(this); |
| 142 | } |
| 143 | stack.positionTask(this, position, showForAllUsers()); |
| 144 | } |
| 145 | |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 146 | boolean removeAppToken(AppWindowToken wtoken) { |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 147 | boolean removed = mAppTokens.remove(wtoken); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 148 | if (mAppTokens.size() == 0) { |
Wale Ogunwale | 000957c | 2015-04-03 08:19:12 -0700 | [diff] [blame] | 149 | EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 150 | "removeAppToken: last token"); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 151 | if (mDeferRemoval) { |
| 152 | removeLocked(); |
| 153 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 154 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 155 | wtoken.mTask = null; |
| 156 | /* Leave mTaskId for now, it might be useful for debug |
| 157 | wtoken.mTaskId = -1; |
| 158 | */ |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 159 | return removed; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 160 | } |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 161 | |
Craig Mautner | cbd84af | 2014-10-22 13:21:22 -0700 | [diff] [blame] | 162 | void setSendingToBottom(boolean toBottom) { |
| 163 | for (int appTokenNdx = 0; appTokenNdx < mAppTokens.size(); appTokenNdx++) { |
| 164 | mAppTokens.get(appTokenNdx).sendingToBottom = toBottom; |
| 165 | } |
| 166 | } |
| 167 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 168 | /** Set the task bounds. Passing in null sets the bounds to fullscreen. */ |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 169 | int setBounds(Rect bounds, Configuration config) { |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 170 | if (config == null) { |
| 171 | config = Configuration.EMPTY; |
| 172 | } |
| 173 | if (bounds == null && !Configuration.EMPTY.equals(config)) { |
| 174 | throw new IllegalArgumentException("null bounds but non empty configuration: " |
| 175 | + config); |
| 176 | } |
| 177 | if (bounds != null && Configuration.EMPTY.equals(config)) { |
| 178 | throw new IllegalArgumentException("non null bounds, but empty configuration"); |
| 179 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 180 | boolean oldFullscreen = mFullscreen; |
| 181 | int rotation = Surface.ROTATION_0; |
| 182 | final DisplayContent displayContent = mStack.getDisplayContent(); |
| 183 | if (displayContent != null) { |
| 184 | displayContent.getLogicalDisplayRect(mTmpRect); |
| 185 | rotation = displayContent.getDisplayInfo().rotation; |
| 186 | if (bounds == null) { |
| 187 | bounds = mTmpRect; |
| 188 | mFullscreen = true; |
| 189 | } else { |
Stefan Kuhne | 234dbf8 | 2015-08-13 09:44:28 -0700 | [diff] [blame] | 190 | if (mStack.mStackId != FREEFORM_WORKSPACE_STACK_ID || bounds.isEmpty()) { |
| 191 | // ensure bounds are entirely within the display rect |
| 192 | if (!bounds.intersect(mTmpRect)) { |
| 193 | // Can't set bounds outside the containing display...Sorry! |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 194 | return BOUNDS_CHANGE_NONE; |
Stefan Kuhne | 234dbf8 | 2015-08-13 09:44:28 -0700 | [diff] [blame] | 195 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 196 | } |
| 197 | mFullscreen = mTmpRect.equals(bounds); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | if (bounds == null) { |
| 202 | // 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] | 203 | return BOUNDS_CHANGE_NONE; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 204 | } |
| 205 | if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) { |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 206 | return BOUNDS_CHANGE_NONE; |
| 207 | } |
| 208 | |
| 209 | int boundsChange = BOUNDS_CHANGE_NONE; |
| 210 | if (mBounds.left != bounds.left || mBounds.right != bounds.right) { |
| 211 | boundsChange |= BOUNDS_CHANGE_POSITION; |
| 212 | } |
| 213 | if (mBounds.width() != bounds.width() || mBounds.height() != bounds.height()) { |
| 214 | boundsChange |= BOUNDS_CHANGE_SIZE; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | mBounds.set(bounds); |
| 218 | mRotation = rotation; |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame^] | 219 | if (displayContent != null) { |
| 220 | displayContent.mDimBehindController.updateDimLayer(this); |
| 221 | } |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 222 | mOverrideConfig = mFullscreen ? Configuration.EMPTY : config; |
Wale Ogunwale | 2cc92f5 | 2015-09-09 13:12:10 -0700 | [diff] [blame] | 223 | return boundsChange; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Chong Zhang | 87b2172 | 2015-09-21 15:39:51 -0700 | [diff] [blame] | 226 | boolean resizeLocked(Rect bounds, Configuration configuration, boolean forced) { |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 227 | int boundsChanged = setBounds(bounds, configuration); |
Chong Zhang | 87b2172 | 2015-09-21 15:39:51 -0700 | [diff] [blame] | 228 | if (forced) { |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 229 | boundsChanged |= BOUNDS_CHANGE_SIZE; |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 230 | } |
| 231 | if (boundsChanged == BOUNDS_CHANGE_NONE) { |
| 232 | return false; |
| 233 | } |
| 234 | if ((boundsChanged & BOUNDS_CHANGE_SIZE) == BOUNDS_CHANGE_SIZE) { |
| 235 | resizeWindows(); |
| 236 | } |
| 237 | return true; |
| 238 | } |
| 239 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 240 | /** Return true if the current bound can get outputted to the rest of the system as-is. */ |
| 241 | private boolean useCurrentBounds() { |
| 242 | final DisplayContent displayContent = mStack.getDisplayContent(); |
| 243 | if (mFullscreen |
| 244 | || mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID |
| 245 | || mStack.mStackId == DOCKED_STACK_ID |
| 246 | || displayContent == null |
| 247 | || displayContent.getDockedStackLocked() != null) { |
| 248 | return true; |
| 249 | } |
| 250 | return false; |
| 251 | } |
| 252 | |
| 253 | /** Bounds of the task with other system factors taken into consideration. */ |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame^] | 254 | @Override |
| 255 | public void getBounds(Rect out) { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 256 | if (useCurrentBounds()) { |
| 257 | // No need to adjust the output bounds if fullscreen or the docked stack is visible |
| 258 | // since it is already what we want to represent to the rest of the system. |
| 259 | out.set(mBounds); |
| 260 | return; |
| 261 | } |
| 262 | |
| 263 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 264 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 265 | // system. |
| 266 | mStack.getDisplayContent().getLogicalDisplayRect(out); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 269 | void setDragResizing(boolean dragResizing) { |
Chong Zhang | 3005e75 | 2015-09-18 18:46:28 -0700 | [diff] [blame] | 270 | mDragResizing = dragResizing; |
| 271 | } |
| 272 | |
| 273 | boolean isDragResizing() { |
| 274 | return mDragResizing; |
| 275 | } |
| 276 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 277 | void updateDisplayInfo(final DisplayContent displayContent) { |
| 278 | if (displayContent == null) { |
| 279 | return; |
| 280 | } |
| 281 | if (mFullscreen) { |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 282 | setBounds(null, Configuration.EMPTY); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 283 | return; |
| 284 | } |
| 285 | final int newRotation = displayContent.getDisplayInfo().rotation; |
| 286 | if (mRotation == newRotation) { |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | // Device rotation changed. We don't want the task to move around on the screen when |
| 291 | // this happens, so update the task bounds so it stays in the same place. |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 292 | mTmpRect2.set(mBounds); |
| 293 | displayContent.rotateBounds(mRotation, newRotation, mTmpRect2); |
Wale Ogunwale | 1ed0d89 | 2015-09-28 13:27:44 -0700 | [diff] [blame] | 294 | if (setBounds(mTmpRect2, mOverrideConfig) != BOUNDS_CHANGE_NONE) { |
| 295 | // Post message to inform activity manager of the bounds change simulating |
| 296 | // a one-way call. We do this to prevent a deadlock between window manager |
| 297 | // lock and activity manager lock been held. |
| 298 | mService.mH.sendMessage(mService.mH.obtainMessage( |
| 299 | RESIZE_TASK, mTaskId, RESIZE_MODE_SYSTEM_SCREEN_ROTATION, mBounds)); |
| 300 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 303 | void resizeWindows() { |
| 304 | final ArrayList<WindowState> resizingWindows = mService.mResizingWindows; |
| 305 | for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) { |
| 306 | final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows; |
| 307 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 308 | final WindowState win = windows.get(winNdx); |
| 309 | if (!resizingWindows.contains(win)) { |
| 310 | if (DEBUG_RESIZE) Slog.d(TAG, "setBounds: Resizing " + win); |
| 311 | resizingWindows.add(win); |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 317 | boolean showForAllUsers() { |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 318 | final int tokensCount = mAppTokens.size(); |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 319 | return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers; |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Chong Zhang | 09b21ef | 2015-09-14 10:20:21 -0700 | [diff] [blame] | 322 | boolean inFreeformWorkspace() { |
| 323 | return mStack != null && mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID; |
| 324 | } |
| 325 | |
Chong Zhang | 9184ec6 | 2015-09-24 12:32:21 -0700 | [diff] [blame] | 326 | WindowState getTopAppMainWindow() { |
| 327 | final int tokensCount = mAppTokens.size(); |
| 328 | return tokensCount > 0 ? mAppTokens.get(tokensCount - 1).findMainWindow() : null; |
| 329 | } |
| 330 | |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 331 | @Override |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 332 | public boolean isFullscreen() { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 333 | if (useCurrentBounds()) { |
| 334 | return mFullscreen; |
| 335 | } |
| 336 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 337 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 338 | // system. |
| 339 | return true; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public DisplayInfo getDisplayInfo() { |
| 344 | return mStack.getDisplayContent().getDisplayInfo(); |
| 345 | } |
| 346 | |
| 347 | @Override |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 348 | public String toString() { |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 349 | return "{taskId=" + mTaskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}"; |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 350 | } |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 351 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame^] | 352 | @Override |
| 353 | public String toShortString() { |
| 354 | return "Task=" + mTaskId; |
| 355 | } |
| 356 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 357 | public void printTo(String prefix, PrintWriter pw) { |
| 358 | pw.print(prefix); pw.print("taskId="); pw.print(mTaskId); |
| 359 | pw.print(prefix); pw.print("appTokens="); pw.print(mAppTokens); |
| 360 | pw.print(prefix); pw.print("mdr="); pw.println(mDeferRemoval); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 361 | } |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 362 | } |