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