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