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