Craig Mautner | c00204b | 2013-03-05 15:02:14 -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 android.app.ActivityManager.StackId; |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 20 | import android.content.res.Configuration; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 21 | import android.graphics.Rect; |
Craig Mautner | f0ac5c8 | 2013-06-24 11:21:57 -0700 | [diff] [blame] | 22 | import android.os.Debug; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 23 | import android.os.RemoteException; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 24 | import android.util.EventLog; |
Craig Mautner | f0ac5c8 | 2013-06-24 11:21:57 -0700 | [diff] [blame] | 25 | import android.util.Slog; |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 26 | import android.util.SparseArray; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 27 | import android.view.DisplayInfo; |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 28 | import android.view.Surface; |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 29 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 30 | import com.android.internal.policy.DividerSnapAlgorithm; |
| 31 | import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget; |
| 32 | import com.android.internal.policy.DockedDividerUtils; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 33 | import com.android.server.EventLogTags; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 34 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 35 | import java.io.PrintWriter; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 36 | import java.util.ArrayList; |
| 37 | |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 38 | import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
| 39 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
| 40 | import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 41 | import static android.app.ActivityManager.StackId.PINNED_STACK_ID; |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 42 | import static android.content.res.Configuration.ORIENTATION_PORTRAIT; |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 43 | import static android.view.WindowManager.DOCKED_BOTTOM; |
| 44 | import static android.view.WindowManager.DOCKED_INVALID; |
| 45 | import static android.view.WindowManager.DOCKED_LEFT; |
| 46 | import static android.view.WindowManager.DOCKED_RIGHT; |
| 47 | import static android.view.WindowManager.DOCKED_TOP; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 48 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT; |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 49 | import static com.android.server.wm.WindowManagerService.H.RESIZE_STACK; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 50 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 51 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 52 | public class TaskStack implements DimLayer.DimLayerUser, |
| 53 | BoundsAnimationController.AnimateBoundsUser { |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 54 | |
| 55 | // If the stack should be resized to fullscreen. |
| 56 | private static final boolean FULLSCREEN = true; |
| 57 | |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 58 | // When we have a top-bottom split screen, we shift the bottom stack up to accommodate |
| 59 | // the IME window. The static flag below controls whether to run animation when the |
| 60 | // IME window goes away. |
| 61 | private static final boolean ANIMATE_IME_GOING_AWAY = false; |
| 62 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 63 | /** Unique identifier */ |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 64 | final int mStackId; |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 65 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 66 | /** The service */ |
| 67 | private final WindowManagerService mService; |
| 68 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 69 | /** The display this stack sits under. */ |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 70 | private DisplayContent mDisplayContent; |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 71 | |
| 72 | /** The Tasks that define this stack. Oldest Tasks are at the bottom. The ordering must match |
| 73 | * mTaskHistory in the ActivityStack with the same mStackId */ |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 74 | private final ArrayList<Task> mTasks = new ArrayList<>(); |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 75 | |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 76 | /** For comparison with DisplayContent bounds. */ |
| 77 | private Rect mTmpRect = new Rect(); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 78 | private Rect mTmpRect2 = new Rect(); |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 79 | |
| 80 | /** Content limits relative to the DisplayContent this sits in. */ |
| 81 | private Rect mBounds = new Rect(); |
| 82 | |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 83 | /** Stack bounds adjusted to screen content area (taking into account IM windows, etc.) */ |
| 84 | private final Rect mAdjustedBounds = new Rect(); |
| 85 | |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 86 | /** Whether mBounds is fullscreen */ |
| 87 | private boolean mFullscreen = true; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 88 | |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 89 | // Device rotation as of the last time {@link #mBounds} was set. |
| 90 | int mRotation; |
| 91 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 92 | /** Support for non-zero {@link android.view.animation.Animation#getBackgroundColor()} */ |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 93 | DimLayer mAnimationBackgroundSurface; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 94 | |
| 95 | /** The particular window with an Animation with non-zero background color. */ |
| 96 | WindowStateAnimator mAnimationBackgroundAnimator; |
| 97 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 98 | /** Application tokens that are exiting, but still on screen for animations. */ |
| 99 | final AppTokenList mExitingAppTokens = new AppTokenList(); |
| 100 | |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 101 | /** Detach this stack from its display when animation completes. */ |
| 102 | boolean mDeferDetach; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 103 | |
| 104 | // Display rotation as of the last time the display information was updated for this stack. |
| 105 | private int mLastUpdateDisplayInfoRotation = -1; |
| 106 | // Display rotation as of the last time the configuration was updated for this stack. |
| 107 | private int mLastConfigChangedRotation = -1; |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 108 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 109 | // Whether the stack and all its tasks is currently being drag-resized |
| 110 | private boolean mDragResizing; |
| 111 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 112 | private final Rect mLastContentBounds = new Rect(); |
| 113 | private final Rect mTmpAdjustedBounds = new Rect(); |
| 114 | private boolean mAdjustedForIme; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 115 | private boolean mImeGoingAway; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 116 | private WindowState mImeWin; |
| 117 | private float mMinimizeAmount; |
| 118 | private final int mDockedStackMinimizeThickness; |
| 119 | |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 120 | // If this is true, the task will be down or upscaled |
| 121 | // to perfectly fit the region it would have been cropped |
| 122 | // to. |
| 123 | private boolean mForceScaleToCrop = false; |
| 124 | // By default, movement animations are applied to all |
| 125 | // window movement. If this is true, animations will not |
| 126 | // be applied within this stack. This is useful for example |
| 127 | // if the windows are moving as the result of a stack animation, |
| 128 | // in which case a second window animation would cause jitter. |
| 129 | private boolean mFreezeMovementAnimations = false; |
| 130 | |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 131 | // Temporary storage for the new bounds that should be used after the configuration change. |
| 132 | // Will be cleared once the client retrieves the new bounds via getBoundsForNewConfiguration(). |
| 133 | private final Rect mBoundsAfterRotation = new Rect(); |
| 134 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 135 | TaskStack(WindowManagerService service, int stackId) { |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 136 | mService = service; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 137 | mStackId = stackId; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 138 | mDockedStackMinimizeThickness = service.mContext.getResources().getDimensionPixelSize( |
| 139 | com.android.internal.R.dimen.docked_stack_minimize_thickness); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 140 | EventLog.writeEvent(EventLogTags.WM_STACK_CREATED, stackId); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | DisplayContent getDisplayContent() { |
| 144 | return mDisplayContent; |
| 145 | } |
| 146 | |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 147 | ArrayList<Task> getTasks() { |
| 148 | return mTasks; |
| 149 | } |
| 150 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 151 | /** |
| 152 | * Set the bounds of the stack and its containing tasks. |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 153 | * @param stackBounds New stack bounds. Passing in null sets the bounds to fullscreen. |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 154 | * @param configs Configuration for individual tasks, keyed by task id. |
| 155 | * @param taskBounds Bounds for individual tasks, keyed by task id. |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 156 | * @return True if the stack bounds was changed. |
| 157 | * */ |
Wale Ogunwale | a6e902e | 2015-09-21 18:37:15 -0700 | [diff] [blame] | 158 | boolean setBounds( |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 159 | Rect stackBounds, SparseArray<Configuration> configs, SparseArray<Rect> taskBounds, |
| 160 | SparseArray<Rect> taskTempInsetBounds) { |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 161 | setBounds(stackBounds); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 162 | |
| 163 | // Update bounds of containing tasks. |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 164 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 165 | final Task task = mTasks.get(taskNdx); |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 166 | Configuration config = configs.get(task.mTaskId); |
| 167 | if (config != null) { |
| 168 | Rect bounds = taskBounds.get(task.mTaskId); |
Chong Zhang | 2a88fc3 | 2016-01-11 17:14:24 -0800 | [diff] [blame] | 169 | if (task.isTwoFingerScrollMode()) { |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 170 | // This is a non-resizeable task that's docked (or side-by-side to the docked |
| 171 | // stack). It might have been scrolled previously, and after the stack resizing, |
| 172 | // it might no longer fully cover the stack area. |
| 173 | // Save the old bounds and re-apply the scroll. This adjusts the bounds to |
| 174 | // fit the new stack bounds. |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 175 | task.resizeLocked(bounds, config, false /* forced */); |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 176 | task.getBounds(mTmpRect); |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 177 | task.scrollLocked(mTmpRect); |
| 178 | } else { |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 179 | task.resizeLocked(bounds, config, false /* forced */); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 180 | task.setTempInsetBounds( |
| 181 | taskTempInsetBounds != null ? taskTempInsetBounds.get(task.mTaskId) |
| 182 | : null); |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 183 | } |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 184 | } else { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 185 | Slog.wtf(TAG_WM, "No config for task: " + task + ", is there a mismatch with AM?"); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | return true; |
| 189 | } |
| 190 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 191 | void prepareFreezingTaskBounds() { |
| 192 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 193 | final Task task = mTasks.get(taskNdx); |
| 194 | task.prepareFreezingBounds(); |
| 195 | } |
| 196 | } |
| 197 | |
Wale Ogunwale | b4ec0a3 | 2015-12-14 10:31:43 -0800 | [diff] [blame] | 198 | boolean isFullscreenBounds(Rect bounds) { |
| 199 | if (mDisplayContent == null || bounds == null) { |
| 200 | return true; |
| 201 | } |
| 202 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 203 | return mTmpRect.equals(bounds); |
| 204 | } |
| 205 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 206 | /** |
| 207 | * Overrides the adjusted bounds, i.e. sets temporary layout bounds which are different from |
| 208 | * the normal task bounds. |
| 209 | * |
| 210 | * @param bounds The adjusted bounds. |
| 211 | * @param keepInsets Whether to keep the insets from the original bounds or to calculate new |
| 212 | * ones depending on the adjusted bounds. |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 213 | * @return true if the adjusted bounds has changed. |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 214 | */ |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 215 | private boolean setAdjustedBounds(Rect bounds, boolean keepInsets) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 216 | if (mAdjustedBounds.equals(bounds)) { |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 217 | return false; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | mAdjustedBounds.set(bounds); |
| 221 | final boolean adjusted = !mAdjustedBounds.isEmpty(); |
| 222 | alignTasksToAdjustedBounds(adjusted ? mAdjustedBounds : mBounds, |
| 223 | adjusted && keepInsets ? mBounds : null); |
| 224 | mDisplayContent.layoutNeeded = true; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 225 | return true; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | private void alignTasksToAdjustedBounds(Rect adjustedBounds, Rect tempInsetBounds) { |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 229 | if (mFullscreen) { |
| 230 | return; |
| 231 | } |
| 232 | // Update bounds of containing tasks. |
| 233 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 234 | final Task task = mTasks.get(taskNdx); |
| 235 | if (task.isTwoFingerScrollMode()) { |
| 236 | // If we're scrolling we don't care about your bounds or configs, |
| 237 | // they should be null as if we were in fullscreen. |
| 238 | task.resizeLocked(null, null, false /* forced */); |
| 239 | task.getBounds(mTmpRect2); |
| 240 | task.scrollLocked(mTmpRect2); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 241 | } else if (task.isResizeable() && task.mOverrideConfig != Configuration.EMPTY) { |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 242 | task.getBounds(mTmpRect2); |
| 243 | mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 244 | task.setTempInsetBounds(tempInsetBounds); |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 245 | task.resizeLocked(mTmpRect2, task.mOverrideConfig, false /* forced */); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 250 | private boolean setBounds(Rect bounds) { |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 251 | boolean oldFullscreen = mFullscreen; |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 252 | int rotation = Surface.ROTATION_0; |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 253 | if (mDisplayContent != null) { |
| 254 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 255 | rotation = mDisplayContent.getDisplayInfo().rotation; |
Jorim Jaggi | 067e817 | 2016-02-03 18:24:12 -0800 | [diff] [blame] | 256 | mFullscreen = bounds == null; |
| 257 | if (mFullscreen) { |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 258 | bounds = mTmpRect; |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 259 | } |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 262 | if (bounds == null) { |
Wale Ogunwale | 4a02d81 | 2015-02-12 23:01:38 -0800 | [diff] [blame] | 263 | // Can't set to fullscreen if we don't have a display to get bounds from... |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 264 | return false; |
| 265 | } |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 266 | if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) { |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 267 | return false; |
| 268 | } |
| 269 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 270 | if (mDisplayContent != null) { |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 271 | mDisplayContent.mDimLayerController.updateDimLayer(this); |
Filip Gruszczynski | 57b6cce | 2015-10-06 09:50:51 -0700 | [diff] [blame] | 272 | mAnimationBackgroundSurface.setBounds(bounds); |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 275 | mBounds.set(bounds); |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 276 | mRotation = rotation; |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 277 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 278 | updateAdjustedBounds(); |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 279 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 280 | return true; |
| 281 | } |
| 282 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 283 | /** Bounds of the stack without adjusting for other factors in the system like visibility |
| 284 | * of docked stack. |
| 285 | * Most callers should be using {@link #getBounds} as it take into consideration other system |
| 286 | * factors. */ |
| 287 | void getRawBounds(Rect out) { |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 288 | out.set(mBounds); |
| 289 | } |
| 290 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 291 | /** Return true if the current bound can get outputted to the rest of the system as-is. */ |
| 292 | private boolean useCurrentBounds() { |
| 293 | if (mFullscreen |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 294 | || !StackId.isResizeableByDockedStack(mStackId) |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 295 | || mDisplayContent == null |
| 296 | || mDisplayContent.getDockedStackLocked() != null) { |
| 297 | return true; |
| 298 | } |
| 299 | return false; |
| 300 | } |
| 301 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 302 | public void getBounds(Rect out) { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 303 | if (useCurrentBounds()) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 304 | // If we're currently adjusting for IME or minimized docked stack, we use the adjusted |
| 305 | // bounds; otherwise, no need to adjust the output bounds if fullscreen or the docked |
| 306 | // stack is visible since it is already what we want to represent to the rest of the |
| 307 | // system. |
| 308 | if (!mAdjustedBounds.isEmpty()) { |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 309 | out.set(mAdjustedBounds); |
| 310 | } else { |
| 311 | out.set(mBounds); |
| 312 | } |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 313 | return; |
| 314 | } |
| 315 | |
| 316 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 317 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 318 | // system. |
| 319 | mDisplayContent.getLogicalDisplayRect(out); |
| 320 | } |
| 321 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 322 | /** Bounds of the stack with other system factors taken into consideration. */ |
| 323 | @Override |
| 324 | public void getDimBounds(Rect out) { |
| 325 | getBounds(out); |
| 326 | } |
| 327 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 328 | void updateDisplayInfo(Rect bounds) { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 329 | if (mDisplayContent == null) { |
| 330 | return; |
| 331 | } |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 332 | |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 333 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 334 | mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent); |
| 335 | } |
| 336 | if (bounds != null) { |
| 337 | setBounds(bounds); |
| 338 | return; |
| 339 | } else if (mFullscreen) { |
| 340 | setBounds(null); |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | mTmpRect2.set(mBounds); |
| 345 | final int newRotation = mDisplayContent.getDisplayInfo().rotation; |
| 346 | if (mRotation == newRotation) { |
| 347 | setBounds(mTmpRect2); |
| 348 | } else { |
| 349 | mLastUpdateDisplayInfoRotation = newRotation; |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 350 | updateBoundsAfterRotation(true); |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 354 | boolean onConfigurationChanged() { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 355 | mLastConfigChangedRotation = getDisplayInfo().rotation; |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 356 | return updateBoundsAfterRotation(false); |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 359 | boolean updateBoundsAfterRotation(boolean scheduleResize) { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 360 | if (mLastConfigChangedRotation != mLastUpdateDisplayInfoRotation) { |
| 361 | // We wait for the rotation values after configuration change and display info. update |
| 362 | // to be equal before updating the bounds due to rotation change otherwise things might |
| 363 | // get out of alignment... |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 364 | return false; |
Filip Gruszczynski | dce2d16 | 2016-01-12 15:40:13 -0800 | [diff] [blame] | 365 | } |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 366 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 367 | final int newRotation = getDisplayInfo().rotation; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 368 | |
| 369 | if (mRotation == newRotation) { |
| 370 | // Nothing to do here if the rotation didn't change |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 371 | return false; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 372 | } |
| 373 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 374 | mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2); |
| 375 | if (mStackId == DOCKED_STACK_ID) { |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 376 | repositionDockedStackAfterRotation(mTmpRect2); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 377 | snapDockedStackAfterRotation(mTmpRect2); |
| 378 | } |
| 379 | |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 380 | if (scheduleResize) { |
| 381 | // Post message to inform activity manager of the bounds change simulating |
| 382 | // a one-way call. We do this to prevent a deadlock between window manager |
| 383 | // lock and activity manager lock been held. |
| 384 | mService.mH.obtainMessage(RESIZE_STACK, mStackId, |
| 385 | 0 /*allowResizeInDockedMode*/, mTmpRect2).sendToTarget(); |
| 386 | } else { |
| 387 | mBoundsAfterRotation.set(mTmpRect2); |
| 388 | } |
| 389 | |
| 390 | return true; |
| 391 | } |
| 392 | |
| 393 | void getBoundsForNewConfiguration(Rect outBounds) { |
| 394 | outBounds.set(mBoundsAfterRotation); |
| 395 | mBoundsAfterRotation.setEmpty(); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | /** |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 399 | * Some dock sides are not allowed by the policy. This method queries the policy and moves |
| 400 | * the docked stack around if needed. |
| 401 | * |
| 402 | * @param inOutBounds the bounds of the docked stack to adjust |
| 403 | */ |
| 404 | private void repositionDockedStackAfterRotation(Rect inOutBounds) { |
| 405 | int dockSide = getDockSide(inOutBounds); |
| 406 | if (mService.mPolicy.isDockSideAllowed(dockSide)) { |
| 407 | return; |
| 408 | } |
| 409 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 410 | dockSide = DockedDividerUtils.invertDockSide(dockSide); |
| 411 | switch (dockSide) { |
| 412 | case DOCKED_LEFT: |
| 413 | int movement = inOutBounds.left; |
| 414 | inOutBounds.left -= movement; |
| 415 | inOutBounds.right -= movement; |
| 416 | break; |
| 417 | case DOCKED_RIGHT: |
| 418 | movement = mTmpRect.right - inOutBounds.right; |
| 419 | inOutBounds.left += movement; |
| 420 | inOutBounds.right += movement; |
| 421 | break; |
| 422 | case DOCKED_TOP: |
| 423 | movement = inOutBounds.top; |
| 424 | inOutBounds.top -= movement; |
| 425 | inOutBounds.bottom -= movement; |
| 426 | break; |
| 427 | case DOCKED_BOTTOM: |
| 428 | movement = mTmpRect.bottom - inOutBounds.bottom; |
| 429 | inOutBounds.top += movement; |
| 430 | inOutBounds.bottom += movement; |
| 431 | break; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | /** |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 436 | * Snaps the bounds after rotation to the closest snap target for the docked stack. |
| 437 | */ |
| 438 | private void snapDockedStackAfterRotation(Rect outBounds) { |
| 439 | |
| 440 | // Calculate the current position. |
| 441 | final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); |
| 442 | final int dividerSize = mService.getDefaultDisplayContentLocked() |
| 443 | .getDockedDividerController().getContentWidth(); |
| 444 | final int dockSide = getDockSide(outBounds); |
| 445 | final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, |
| 446 | dockSide, dividerSize); |
| 447 | final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth; |
| 448 | final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight; |
| 449 | |
| 450 | // Snap the position to a target. |
| 451 | final int rotation = displayInfo.rotation; |
| 452 | final int orientation = mService.mCurConfiguration.orientation; |
| 453 | mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds); |
| 454 | final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm( |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 455 | mService.mContext.getResources(), displayWidth, displayHeight, |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 456 | dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds); |
| 457 | final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition); |
| 458 | |
| 459 | // Recalculate the bounds based on the position of the target. |
| 460 | DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, |
| 461 | outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, |
| 462 | dividerSize); |
| 463 | } |
| 464 | |
Craig Mautner | 1bf2b87 | 2014-02-05 15:37:40 -0800 | [diff] [blame] | 465 | boolean isAnimating() { |
| 466 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 467 | final ArrayList<AppWindowToken> activities = mTasks.get(taskNdx).mAppTokens; |
| 468 | for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { |
| 469 | final ArrayList<WindowState> windows = activities.get(activityNdx).allAppWindows; |
| 470 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 471 | final WindowStateAnimator winAnimator = windows.get(winNdx).mWinAnimator; |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 472 | if (winAnimator.isAnimating() || winAnimator.mWin.mAnimatingExit) { |
Craig Mautner | 1bf2b87 | 2014-02-05 15:37:40 -0800 | [diff] [blame] | 473 | return true; |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | return false; |
| 479 | } |
| 480 | |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 481 | void addTask(Task task, boolean toTop) { |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 482 | addTask(task, toTop, task.showForAllUsers()); |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 485 | /** |
| 486 | * Put a Task in this stack. Used for adding and moving. |
| 487 | * @param task The task to add. |
| 488 | * @param toTop Whether to add it to the top or bottom. |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 489 | * @param showForAllUsers Whether to show the task regardless of the current user. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 490 | */ |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 491 | void addTask(Task task, boolean toTop, boolean showForAllUsers) { |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 492 | positionTask(task, toTop ? mTasks.size() : 0, showForAllUsers); |
| 493 | } |
| 494 | |
| 495 | void positionTask(Task task, int position, boolean showForAllUsers) { |
| 496 | final boolean canShowTask = |
| 497 | showForAllUsers || mService.isCurrentProfileLocked(task.mUserId); |
| 498 | mTasks.remove(task); |
| 499 | int stackSize = mTasks.size(); |
| 500 | int minPosition = 0; |
| 501 | int maxPosition = stackSize; |
| 502 | |
| 503 | if (canShowTask) { |
| 504 | minPosition = computeMinPosition(minPosition, stackSize); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 505 | } else { |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 506 | maxPosition = computeMaxPosition(maxPosition); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 507 | } |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 508 | // Reset position based on minimum/maximum possible positions. |
| 509 | position = Math.min(Math.max(position, minPosition), maxPosition); |
| 510 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 511 | if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 512 | "positionTask: task=" + task + " position=" + position); |
| 513 | mTasks.add(position, task); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 514 | |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 515 | // If we are moving the task across stacks, the scroll is no longer valid. |
| 516 | if (task.mStack != this) { |
| 517 | task.resetScrollLocked(); |
| 518 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 519 | task.mStack = this; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 520 | task.updateDisplayInfo(mDisplayContent); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 521 | boolean toTop = position == mTasks.size() - 1; |
raysb.kim | 00a2725 | 2014-11-11 08:38:21 +0900 | [diff] [blame] | 522 | if (toTop) { |
| 523 | mDisplayContent.moveStack(this, true); |
| 524 | } |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 525 | EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, task.mTaskId, toTop ? 1 : 0, position); |
| 526 | } |
| 527 | |
| 528 | /** Calculate the minimum possible position for a task that can be shown to the user. |
| 529 | * The minimum position will be above all other tasks that can't be shown. |
| 530 | * @param minPosition The minimum position the caller is suggesting. |
| 531 | * We will start adjusting up from here. |
| 532 | * @param size The size of the current task list. |
| 533 | */ |
| 534 | private int computeMinPosition(int minPosition, int size) { |
| 535 | while (minPosition < size) { |
| 536 | final Task tmpTask = mTasks.get(minPosition); |
| 537 | final boolean canShowTmpTask = |
| 538 | tmpTask.showForAllUsers() |
| 539 | || mService.isCurrentProfileLocked(tmpTask.mUserId); |
| 540 | if (canShowTmpTask) { |
| 541 | break; |
| 542 | } |
| 543 | minPosition++; |
| 544 | } |
| 545 | return minPosition; |
| 546 | } |
| 547 | |
| 548 | /** Calculate the maximum possible position for a task that can't be shown to the user. |
| 549 | * The maximum position will be below all other tasks that can be shown. |
| 550 | * @param maxPosition The maximum position the caller is suggesting. |
| 551 | * We will start adjusting down from here. |
| 552 | */ |
| 553 | private int computeMaxPosition(int maxPosition) { |
| 554 | while (maxPosition > 0) { |
| 555 | final Task tmpTask = mTasks.get(maxPosition - 1); |
| 556 | final boolean canShowTmpTask = |
| 557 | tmpTask.showForAllUsers() |
| 558 | || mService.isCurrentProfileLocked(tmpTask.mUserId); |
| 559 | if (!canShowTmpTask) { |
| 560 | break; |
| 561 | } |
| 562 | maxPosition--; |
| 563 | } |
| 564 | return maxPosition; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 565 | } |
| 566 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 567 | void moveTaskToTop(Task task) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 568 | if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "moveTaskToTop: task=" + task + " Callers=" |
Craig Mautner | f0ac5c8 | 2013-06-24 11:21:57 -0700 | [diff] [blame] | 569 | + Debug.getCallers(6)); |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 570 | mTasks.remove(task); |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 571 | addTask(task, true); |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 572 | } |
| 573 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 574 | void moveTaskToBottom(Task task) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 575 | if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "moveTaskToBottom: task=" + task); |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 576 | mTasks.remove(task); |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 577 | addTask(task, false); |
Craig Mautner | d9a2288 | 2013-03-16 15:00:36 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 580 | /** |
Craig Mautner | 04a0ea6 | 2014-01-13 12:51:26 -0800 | [diff] [blame] | 581 | * Delete a Task from this stack. If it is the last Task in the stack, move this stack to the |
| 582 | * back. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 583 | * @param task The Task to delete. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 584 | */ |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 585 | void removeTask(Task task) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 586 | if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeTask: task=" + task); |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 587 | mTasks.remove(task); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 588 | if (mDisplayContent != null) { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 589 | if (mTasks.isEmpty()) { |
| 590 | mDisplayContent.moveStack(this, false); |
| 591 | } |
| 592 | mDisplayContent.layoutNeeded = true; |
Craig Mautner | 04a0ea6 | 2014-01-13 12:51:26 -0800 | [diff] [blame] | 593 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 594 | for (int appNdx = mExitingAppTokens.size() - 1; appNdx >= 0; --appNdx) { |
| 595 | final AppWindowToken wtoken = mExitingAppTokens.get(appNdx); |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 596 | if (wtoken.mTask == task) { |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 597 | wtoken.mIsExiting = false; |
| 598 | mExitingAppTokens.remove(appNdx); |
| 599 | } |
| 600 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 601 | } |
| 602 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 603 | void attachDisplayContent(DisplayContent displayContent) { |
| 604 | if (mDisplayContent != null) { |
| 605 | throw new IllegalStateException("attachDisplayContent: Already attached"); |
Craig Mautner | 4a1cb22 | 2013-12-04 16:14:06 -0800 | [diff] [blame] | 606 | } |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 607 | |
| 608 | mDisplayContent = displayContent; |
Jorim Jaggi | bc5425c | 2016-03-01 13:51:16 +0100 | [diff] [blame] | 609 | mAnimationBackgroundSurface = new DimLayer(mService, this, mDisplayContent.getDisplayId(), |
| 610 | "animation background stackId=" + mStackId); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 611 | |
| 612 | Rect bounds = null; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 613 | final TaskStack dockedStack = mService.mStackIdToStack.get(DOCKED_STACK_ID); |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 614 | if (mStackId == DOCKED_STACK_ID |
| 615 | || (dockedStack != null && StackId.isResizeableByDockedStack(mStackId))) { |
| 616 | // The existence of a docked stack affects the size of other static stack created since |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 617 | // the docked stack occupies a dedicated region on screen. |
| 618 | bounds = new Rect(); |
| 619 | displayContent.getLogicalDisplayRect(mTmpRect); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 620 | mTmpRect2.setEmpty(); |
| 621 | if (dockedStack != null) { |
| 622 | dockedStack.getRawBounds(mTmpRect2); |
| 623 | } |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 624 | final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 625 | == DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
| 626 | getStackDockedModeBounds(mTmpRect, bounds, mStackId, mTmpRect2, |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 627 | mDisplayContent.mDividerControllerLocked.getContentWidth(), |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 628 | dockedOnTopOrLeft); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | updateDisplayInfo(bounds); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Wale Ogunwale | 961f485 | 2016-02-01 20:25:54 -0800 | [diff] [blame] | 634 | void getStackDockedModeBoundsLocked(Rect outBounds, boolean ignoreVisibility) { |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 635 | if ((mStackId != DOCKED_STACK_ID && !StackId.isResizeableByDockedStack(mStackId)) |
| 636 | || mDisplayContent == null) { |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 637 | outBounds.set(mBounds); |
| 638 | return; |
| 639 | } |
| 640 | |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 641 | final TaskStack dockedStack = mService.mStackIdToStack.get(DOCKED_STACK_ID); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 642 | if (dockedStack == null) { |
| 643 | // Not sure why you are calling this method when there is no docked stack... |
| 644 | throw new IllegalStateException( |
| 645 | "Calling getStackDockedModeBoundsLocked() when there is no docked stack."); |
| 646 | } |
Wale Ogunwale | 961f485 | 2016-02-01 20:25:54 -0800 | [diff] [blame] | 647 | if (!ignoreVisibility && !dockedStack.isVisibleLocked()) { |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 648 | // The docked stack is being dismissed, but we caught before it finished being |
| 649 | // dismissed. In that case we want to treat it as if it is not occupying any space and |
| 650 | // let others occupy the whole display. |
Wale Ogunwale | ccb6ce2 | 2016-01-14 15:36:35 -0800 | [diff] [blame] | 651 | mDisplayContent.getLogicalDisplayRect(outBounds); |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 652 | return; |
| 653 | } |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 654 | |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 655 | final int dockedSide = dockedStack.getDockSide(); |
| 656 | if (dockedSide == DOCKED_INVALID) { |
| 657 | // Not sure how you got here...Only thing we can do is return current bounds. |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 658 | Slog.e(TAG_WM, "Failed to get valid docked side for docked stack=" + dockedStack); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 659 | outBounds.set(mBounds); |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 664 | dockedStack.getRawBounds(mTmpRect2); |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 665 | final boolean dockedOnTopOrLeft = dockedSide == DOCKED_TOP || dockedSide == DOCKED_LEFT; |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 666 | getStackDockedModeBounds(mTmpRect, outBounds, mStackId, mTmpRect2, |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 667 | mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 668 | |
| 669 | } |
| 670 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 671 | /** |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 672 | * Outputs the bounds a stack should be given the presence of a docked stack on the display. |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 673 | * @param displayRect The bounds of the display the docked stack is on. |
| 674 | * @param outBounds Output bounds that should be used for the stack. |
| 675 | * @param stackId Id of stack we are calculating the bounds for. |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 676 | * @param dockedBounds Bounds of the docked stack. |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 677 | * @param dockDividerWidth We need to know the width of the divider make to the output bounds |
| 678 | * close to the side of the dock. |
| 679 | * @param dockOnTopOrLeft If the docked stack is on the top or left side of the screen. |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 680 | */ |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 681 | private void getStackDockedModeBounds( |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 682 | Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth, |
| 683 | boolean dockOnTopOrLeft) { |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 684 | final boolean dockedStack = stackId == DOCKED_STACK_ID; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 685 | final boolean splitHorizontally = displayRect.width() > displayRect.height(); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 686 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 687 | outBounds.set(displayRect); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 688 | if (dockedStack) { |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 689 | if (mService.mDockedStackCreateBounds != null) { |
| 690 | outBounds.set(mService.mDockedStackCreateBounds); |
| 691 | return; |
| 692 | } |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 693 | |
| 694 | // The initial bounds of the docked stack when it is created about half the screen space |
| 695 | // and its bounds can be adjusted after that. The bounds of all other stacks are |
| 696 | // adjusted to occupy whatever screen space the docked stack isn't occupying. |
| 697 | final DisplayInfo di = mDisplayContent.getDisplayInfo(); |
| 698 | mService.mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, |
| 699 | mTmpRect2); |
| 700 | final int position = new DividerSnapAlgorithm(mService.mContext.getResources(), |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 701 | di.logicalWidth, |
| 702 | di.logicalHeight, |
| 703 | dockDividerWidth, |
| 704 | mService.mCurConfiguration.orientation == ORIENTATION_PORTRAIT, |
| 705 | mTmpRect2).getMiddleTarget().position; |
| 706 | |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 707 | if (dockOnTopOrLeft) { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 708 | if (splitHorizontally) { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 709 | outBounds.right = position; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 710 | } else { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 711 | outBounds.bottom = position; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 712 | } |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 713 | } else { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 714 | if (splitHorizontally) { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 715 | outBounds.left = position - dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 716 | } else { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 717 | outBounds.top = position - dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 718 | } |
| 719 | } |
| 720 | return; |
| 721 | } |
| 722 | |
| 723 | // Other stacks occupy whatever space is left by the docked stack. |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 724 | if (!dockOnTopOrLeft) { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 725 | if (splitHorizontally) { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 726 | outBounds.right = dockedBounds.left - dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 727 | } else { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 728 | outBounds.bottom = dockedBounds.top - dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 729 | } |
| 730 | } else { |
| 731 | if (splitHorizontally) { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 732 | outBounds.left = dockedBounds.right + dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 733 | } else { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 734 | outBounds.top = dockedBounds.bottom + dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 735 | } |
| 736 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 737 | DockedDividerUtils.sanitizeStackBounds(outBounds, !dockOnTopOrLeft); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 738 | } |
| 739 | |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 740 | void resetDockedStackToMiddle() { |
| 741 | if (mStackId != DOCKED_STACK_ID) { |
| 742 | throw new IllegalStateException("Not a docked stack=" + this); |
| 743 | } |
| 744 | |
| 745 | mService.mDockedStackCreateBounds = null; |
| 746 | |
| 747 | final Rect bounds = new Rect(); |
| 748 | getStackDockedModeBoundsLocked(bounds, true /*ignoreVisibility*/); |
| 749 | mService.mH.obtainMessage(RESIZE_STACK, DOCKED_STACK_ID, |
| 750 | 1 /*allowResizeInDockedMode*/, bounds).sendToTarget(); |
| 751 | } |
| 752 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 753 | void detachDisplay() { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 754 | EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId); |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 755 | |
| 756 | boolean doAnotherLayoutPass = false; |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 757 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 758 | final AppTokenList appWindowTokens = mTasks.get(taskNdx).mAppTokens; |
| 759 | for (int appNdx = appWindowTokens.size() - 1; appNdx >= 0; --appNdx) { |
| 760 | final WindowList appWindows = appWindowTokens.get(appNdx).allAppWindows; |
| 761 | for (int winNdx = appWindows.size() - 1; winNdx >= 0; --winNdx) { |
Filip Gruszczynski | d66af6a | 2015-08-31 08:57:24 -0700 | [diff] [blame] | 762 | // We are in the middle of changing the state of displays/stacks/tasks. We need |
| 763 | // to finish that, before we let layout interfere with it. |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 764 | mService.removeWindowLocked(appWindows.get(winNdx)); |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 765 | doAnotherLayoutPass = true; |
| 766 | } |
| 767 | } |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 768 | } |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 769 | if (doAnotherLayoutPass) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 770 | mService.mWindowPlacerLocked.requestTraversal(); |
Craig Mautner | bc2a6df | 2014-06-13 15:08:48 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Craig Mautner | 00a6675 | 2015-03-23 14:00:47 -0700 | [diff] [blame] | 773 | close(); |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 774 | } |
| 775 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 776 | void resetAnimationBackgroundAnimator() { |
| 777 | mAnimationBackgroundAnimator = null; |
| 778 | mAnimationBackgroundSurface.hide(); |
| 779 | } |
| 780 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 781 | void setAnimationBackground(WindowStateAnimator winAnimator, int color) { |
| 782 | int animLayer = winAnimator.mAnimLayer; |
| 783 | if (mAnimationBackgroundAnimator == null |
| 784 | || animLayer < mAnimationBackgroundAnimator.mAnimLayer) { |
| 785 | mAnimationBackgroundAnimator = winAnimator; |
| 786 | animLayer = mService.adjustAnimationBackground(winAnimator); |
| 787 | mAnimationBackgroundSurface.show(animLayer - WindowManagerService.LAYER_OFFSET_DIM, |
| 788 | ((color >> 24) & 0xff) / 255f, 0); |
| 789 | } |
| 790 | } |
| 791 | |
Wale Ogunwale | 498e8c9 | 2015-02-13 09:42:46 -0800 | [diff] [blame] | 792 | void switchUser() { |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 793 | int top = mTasks.size(); |
| 794 | for (int taskNdx = 0; taskNdx < top; ++taskNdx) { |
| 795 | Task task = mTasks.get(taskNdx); |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 796 | if (mService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) { |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 797 | mTasks.remove(taskNdx); |
| 798 | mTasks.add(task); |
| 799 | --top; |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 804 | void close() { |
Craig Mautner | 00a6675 | 2015-03-23 14:00:47 -0700 | [diff] [blame] | 805 | if (mAnimationBackgroundSurface != null) { |
| 806 | mAnimationBackgroundSurface.destroySurface(); |
| 807 | mAnimationBackgroundSurface = null; |
| 808 | } |
Filip Gruszczynski | 26ed265 | 2015-08-10 11:02:53 -0700 | [diff] [blame] | 809 | mDisplayContent = null; |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 810 | } |
| 811 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 812 | /** |
| 813 | * Adjusts the stack bounds if the IME is visible. |
| 814 | * |
| 815 | * @param imeWin The IME window. |
| 816 | */ |
| 817 | void setAdjustedForIme(WindowState imeWin) { |
| 818 | mAdjustedForIme = true; |
| 819 | mImeWin = imeWin; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 820 | mImeGoingAway = false; |
| 821 | } |
| 822 | |
| 823 | boolean isAdjustedForIme() { |
| 824 | return mAdjustedForIme || mImeGoingAway; |
| 825 | } |
| 826 | void clearImeGoingAway() { |
| 827 | mImeGoingAway = false; |
| 828 | } |
| 829 | |
| 830 | boolean isAnimatingForIme() { |
| 831 | return mImeWin != null && mImeWin.isAnimatingLw(); |
| 832 | } |
| 833 | |
| 834 | /** |
| 835 | * Update the stack's bounds (crop or position) according to the IME window's |
| 836 | * current position. When IME window is animated, the bottom stack is animated |
| 837 | * together to track the IME window's current position, and the top stack is |
| 838 | * cropped as necessary. |
| 839 | * |
| 840 | * @return true if a traversal should be performed after the adjustment. |
| 841 | */ |
| 842 | boolean updateAdjustForIme() { |
| 843 | boolean stopped = false; |
| 844 | if (mImeGoingAway && (!ANIMATE_IME_GOING_AWAY || !isAnimatingForIme())) { |
| 845 | mImeWin = null; |
| 846 | mAdjustedForIme = false; |
| 847 | stopped = true; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 848 | } |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 849 | // Make sure to run a traversal when the animation stops so that the stack |
| 850 | // is moved to its final position. |
| 851 | return updateAdjustedBounds() || stopped; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | /** |
| 855 | * Resets the adjustment after it got adjusted for the IME. |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 856 | * @param adjustBoundsNow if true, reset and update the bounds immediately and forget about |
| 857 | * animations; otherwise, set flag and animates the window away together |
| 858 | * with IME window. |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 859 | */ |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 860 | void resetAdjustedForIme(boolean adjustBoundsNow) { |
| 861 | if (adjustBoundsNow) { |
| 862 | mImeWin = null; |
| 863 | mAdjustedForIme = false; |
| 864 | mImeGoingAway = false; |
| 865 | updateAdjustedBounds(); |
| 866 | } else { |
| 867 | mImeGoingAway |= mAdjustedForIme; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 868 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | /** |
| 872 | * Sets the amount how much we currently minimize our stack. |
| 873 | * |
| 874 | * @param minimizeAmount The amount, between 0 and 1. |
| 875 | * @return Whether the amount has changed and a layout is needed. |
| 876 | */ |
| 877 | boolean setAdjustedForMinimizedDock(float minimizeAmount) { |
| 878 | if (minimizeAmount != mMinimizeAmount) { |
| 879 | mMinimizeAmount = minimizeAmount; |
| 880 | updateAdjustedBounds(); |
| 881 | return isVisibleForUserLocked(); |
| 882 | } else { |
| 883 | return false; |
| 884 | } |
| 885 | } |
| 886 | |
Jorim Jaggi | 409635b | 2016-04-01 15:32:28 -0700 | [diff] [blame] | 887 | boolean isAdjustedForMinimizedDock() { |
| 888 | return mMinimizeAmount != 0f; |
| 889 | } |
| 890 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 891 | private boolean adjustForIME(final WindowState imeWin) { |
| 892 | final int dockedSide = getDockSide(); |
| 893 | final boolean dockedTopOrBottom = dockedSide == DOCKED_TOP || dockedSide == DOCKED_BOTTOM; |
| 894 | final Rect adjustedBounds = mTmpAdjustedBounds; |
| 895 | if (imeWin == null || !dockedTopOrBottom) { |
| 896 | return false; |
| 897 | } |
| 898 | |
| 899 | final Rect displayContentRect = mTmpRect; |
| 900 | final Rect contentBounds = mTmpRect2; |
| 901 | |
| 902 | // Calculate the content bounds excluding the area occupied by IME |
| 903 | getDisplayContent().getContentRect(displayContentRect); |
| 904 | contentBounds.set(displayContentRect); |
| 905 | int imeTop = Math.max(imeWin.getDisplayFrameLw().top, contentBounds.top); |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 906 | |
| 907 | // if IME window is animating, get its actual vertical shown position (but no smaller than |
| 908 | // the final target vertical position) |
| 909 | if (imeWin.isAnimatingLw()) { |
| 910 | imeTop = Math.max(imeTop, imeWin.getShownPositionLw().y); |
| 911 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 912 | imeTop += imeWin.getGivenContentInsetsLw().top; |
| 913 | if (contentBounds.bottom > imeTop) { |
| 914 | contentBounds.bottom = imeTop; |
| 915 | } |
| 916 | |
| 917 | // If content bounds not changing, nothing to do. |
| 918 | if (mLastContentBounds.equals(contentBounds)) { |
| 919 | return true; |
| 920 | } |
| 921 | |
| 922 | // Content bounds changed, need to apply adjustments depending on dock sides. |
| 923 | mLastContentBounds.set(contentBounds); |
| 924 | adjustedBounds.set(mBounds); |
| 925 | final int yOffset = displayContentRect.bottom - contentBounds.bottom; |
| 926 | |
| 927 | if (dockedSide == DOCKED_TOP) { |
| 928 | // If this stack is docked on top, we make it smaller so the bottom stack is not |
| 929 | // occluded by IME. We shift its bottom up by the height of the IME (capped by |
| 930 | // the display content rect). Note that we don't change the task bounds. |
| 931 | adjustedBounds.bottom = Math.max( |
| 932 | adjustedBounds.bottom - yOffset, displayContentRect.top); |
| 933 | } else { |
| 934 | // If this stack is docked on bottom, we shift it up so that it's not occluded by |
| 935 | // IME. We try to move it up by the height of the IME window (although the best |
| 936 | // we could do is to make the top stack fully collapsed). |
| 937 | final int dividerWidth = getDisplayContent().mDividerControllerLocked |
| 938 | .getContentWidth(); |
| 939 | adjustedBounds.top = Math.max( |
| 940 | adjustedBounds.top - yOffset, displayContentRect.top + dividerWidth); |
| 941 | adjustedBounds.bottom = adjustedBounds.top + mBounds.height(); |
| 942 | } |
| 943 | return true; |
| 944 | } |
| 945 | |
| 946 | private boolean adjustForMinimizedDockedStack(float minimizeAmount) { |
| 947 | final int dockSide = getDockSide(); |
| 948 | if (dockSide == DOCKED_INVALID && !mTmpAdjustedBounds.isEmpty()) { |
| 949 | return false; |
| 950 | } |
| 951 | |
| 952 | if (dockSide == DOCKED_TOP) { |
| 953 | mService.getStableInsetsLocked(mTmpRect); |
| 954 | int topInset = mTmpRect.top; |
| 955 | mTmpAdjustedBounds.set(mBounds); |
| 956 | mTmpAdjustedBounds.bottom = |
| 957 | (int) (minimizeAmount * topInset + (1 - minimizeAmount) * mBounds.bottom); |
| 958 | } else if (dockSide == DOCKED_LEFT) { |
| 959 | mTmpAdjustedBounds.set(mBounds); |
Jorim Jaggi | bcff143 | 2016-04-01 15:49:45 -0700 | [diff] [blame] | 960 | final int width = mBounds.width(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 961 | mTmpAdjustedBounds.right = |
| 962 | (int) (minimizeAmount * mDockedStackMinimizeThickness |
| 963 | + (1 - minimizeAmount) * mBounds.right); |
Jorim Jaggi | bcff143 | 2016-04-01 15:49:45 -0700 | [diff] [blame] | 964 | mTmpAdjustedBounds.left = mTmpAdjustedBounds.right - width; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 965 | } else if (dockSide == DOCKED_RIGHT) { |
| 966 | mTmpAdjustedBounds.set(mBounds); |
| 967 | mTmpAdjustedBounds.left = |
| 968 | (int) (minimizeAmount * (mBounds.right - mDockedStackMinimizeThickness) |
| 969 | + (1 - minimizeAmount) * mBounds.left); |
| 970 | } |
| 971 | return true; |
| 972 | } |
| 973 | |
| 974 | /** |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 975 | * @return the distance in pixels how much the stack gets minimized from it's original size |
| 976 | */ |
| 977 | int getMinimizeDistance() { |
| 978 | final int dockSide = getDockSide(); |
| 979 | if (dockSide == DOCKED_INVALID) { |
| 980 | return 0; |
| 981 | } |
| 982 | |
| 983 | if (dockSide == DOCKED_TOP) { |
| 984 | mService.getStableInsetsLocked(mTmpRect); |
| 985 | int topInset = mTmpRect.top; |
| 986 | return mBounds.bottom - topInset; |
| 987 | } else if (dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT) { |
| 988 | return mBounds.width() - mDockedStackMinimizeThickness; |
| 989 | } else { |
| 990 | return 0; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | /** |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 995 | * Updates the adjustment depending on it's current state. |
| 996 | */ |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 997 | boolean updateAdjustedBounds() { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 998 | boolean adjust = false; |
| 999 | if (mMinimizeAmount != 0f) { |
| 1000 | adjust = adjustForMinimizedDockedStack(mMinimizeAmount); |
| 1001 | } else if (mAdjustedForIme) { |
| 1002 | adjust = adjustForIME(mImeWin); |
| 1003 | } |
| 1004 | if (!adjust) { |
| 1005 | mTmpAdjustedBounds.setEmpty(); |
| 1006 | mLastContentBounds.setEmpty(); |
| 1007 | } |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 1008 | return setAdjustedBounds(mTmpAdjustedBounds, isAdjustedForMinimizedDockedStack()); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | boolean isAdjustedForMinimizedDockedStack() { |
| 1012 | return mMinimizeAmount != 0f; |
| 1013 | } |
| 1014 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1015 | public void dump(String prefix, PrintWriter pw) { |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 1016 | pw.println(prefix + "mStackId=" + mStackId); |
| 1017 | pw.println(prefix + "mDeferDetach=" + mDeferDetach); |
| 1018 | pw.println(prefix + "mFullscreen=" + mFullscreen); |
| 1019 | pw.println(prefix + "mBounds=" + mBounds.toShortString()); |
| 1020 | for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; taskNdx--) { |
| 1021 | mTasks.get(taskNdx).dump(prefix + " ", pw); |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1022 | } |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1023 | if (mAnimationBackgroundSurface.isDimming()) { |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 1024 | pw.println(prefix + "mWindowAnimationBackgroundSurface:"); |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1025 | mAnimationBackgroundSurface.printTo(prefix + " ", pw); |
| 1026 | } |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 1027 | if (!mExitingAppTokens.isEmpty()) { |
| 1028 | pw.println(); |
| 1029 | pw.println(" Exiting application tokens:"); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1030 | for (int i = mExitingAppTokens.size() - 1; i >= 0; i--) { |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 1031 | WindowToken token = mExitingAppTokens.get(i); |
| 1032 | pw.print(" Exiting App #"); pw.print(i); |
| 1033 | pw.print(' '); pw.print(token); |
| 1034 | pw.println(':'); |
| 1035 | token.dump(pw, " "); |
| 1036 | } |
| 1037 | } |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1038 | } |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1039 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1040 | /** Fullscreen status of the stack without adjusting for other factors in the system like |
| 1041 | * visibility of docked stack. |
| 1042 | * Most callers should be using {@link #isFullscreen} as it take into consideration other |
| 1043 | * system factors. */ |
| 1044 | boolean getRawFullscreen() { |
| 1045 | return mFullscreen; |
| 1046 | } |
| 1047 | |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1048 | @Override |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1049 | public boolean isFullscreen() { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1050 | if (useCurrentBounds()) { |
| 1051 | return mFullscreen; |
| 1052 | } |
| 1053 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 1054 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 1055 | // system. |
| 1056 | return true; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1057 | } |
| 1058 | |
| 1059 | @Override |
| 1060 | public DisplayInfo getDisplayInfo() { |
| 1061 | return mDisplayContent.getDisplayInfo(); |
| 1062 | } |
| 1063 | |
| 1064 | @Override |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1065 | public String toString() { |
| 1066 | return "{stackId=" + mStackId + " tasks=" + mTasks + "}"; |
| 1067 | } |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1068 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 1069 | @Override |
| 1070 | public String toShortString() { |
| 1071 | return "Stack=" + mStackId; |
| 1072 | } |
| 1073 | |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1074 | /** |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 1075 | * For docked workspace (or workspace that's side-by-side to the docked), provides |
| 1076 | * information which side of the screen was the dock anchored. |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1077 | */ |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1078 | int getDockSide() { |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1079 | return getDockSide(mBounds); |
| 1080 | } |
| 1081 | |
| 1082 | int getDockSide(Rect bounds) { |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 1083 | if (mStackId != DOCKED_STACK_ID && !StackId.isResizeableByDockedStack(mStackId)) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1084 | return DOCKED_INVALID; |
| 1085 | } |
| 1086 | if (mDisplayContent == null) { |
| 1087 | return DOCKED_INVALID; |
| 1088 | } |
| 1089 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 1090 | final int orientation = mService.mCurConfiguration.orientation; |
| 1091 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 1092 | // Portrait mode, docked either at the top or the bottom. |
Jorim Jaggi | 067e817 | 2016-02-03 18:24:12 -0800 | [diff] [blame] | 1093 | if (bounds.top - mTmpRect.top <= mTmpRect.bottom - bounds.bottom) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1094 | return DOCKED_TOP; |
| 1095 | } else { |
| 1096 | return DOCKED_BOTTOM; |
| 1097 | } |
| 1098 | } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { |
| 1099 | // Landscape mode, docked either on the left or on the right. |
Jorim Jaggi | 067e817 | 2016-02-03 18:24:12 -0800 | [diff] [blame] | 1100 | if (bounds.left - mTmpRect.left <= mTmpRect.right - bounds.right) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1101 | return DOCKED_LEFT; |
| 1102 | } else { |
| 1103 | return DOCKED_RIGHT; |
| 1104 | } |
| 1105 | } else { |
| 1106 | return DOCKED_INVALID; |
| 1107 | } |
| 1108 | } |
Filip Gruszczynski | 3ddc5d6 | 2015-09-23 15:01:30 -0700 | [diff] [blame] | 1109 | |
| 1110 | boolean isVisibleLocked() { |
Jorim Jaggi | 7998e48 | 2016-02-12 18:47:06 -0800 | [diff] [blame] | 1111 | final boolean keyguardOn = mService.mPolicy.isKeyguardShowingOrOccluded() |
| 1112 | && !mService.mAnimator.mKeyguardGoingAway; |
Chong Zhang | 75b3720 | 2015-12-04 14:16:36 -0800 | [diff] [blame] | 1113 | if (keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) { |
Wale Ogunwale | ccb6ce2 | 2016-01-14 15:36:35 -0800 | [diff] [blame] | 1114 | // The keyguard is showing and the stack shouldn't show on top of the keyguard. |
Wale Ogunwale | 961f485 | 2016-02-01 20:25:54 -0800 | [diff] [blame] | 1115 | return false; |
Chong Zhang | 75b3720 | 2015-12-04 14:16:36 -0800 | [diff] [blame] | 1116 | } |
Wale Ogunwale | ccb6ce2 | 2016-01-14 15:36:35 -0800 | [diff] [blame] | 1117 | |
Filip Gruszczynski | 3ddc5d6 | 2015-09-23 15:01:30 -0700 | [diff] [blame] | 1118 | for (int i = mTasks.size() - 1; i >= 0; i--) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1119 | final Task task = mTasks.get(i); |
Filip Gruszczynski | 3ddc5d6 | 2015-09-23 15:01:30 -0700 | [diff] [blame] | 1120 | for (int j = task.mAppTokens.size() - 1; j >= 0; j--) { |
| 1121 | if (!task.mAppTokens.get(j).hidden) { |
| 1122 | return true; |
| 1123 | } |
| 1124 | } |
| 1125 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1126 | |
| 1127 | return false; |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * @return true if a the stack is visible for the current in user, ignoring any other visibility |
| 1132 | * aspects, and false otherwise |
| 1133 | */ |
| 1134 | boolean isVisibleForUserLocked() { |
| 1135 | for (int i = mTasks.size() - 1; i >= 0; i--) { |
| 1136 | final Task task = mTasks.get(i); |
| 1137 | if (task.isVisibleForUser()) { |
| 1138 | return true; |
| 1139 | } |
| 1140 | } |
Filip Gruszczynski | 3ddc5d6 | 2015-09-23 15:01:30 -0700 | [diff] [blame] | 1141 | return false; |
| 1142 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1143 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1144 | boolean isDragResizing() { |
| 1145 | return mDragResizing; |
| 1146 | } |
| 1147 | |
Jorim Jaggi | c662d8e | 2016-02-05 16:54:54 -0800 | [diff] [blame] | 1148 | private void setDragResizingLocked(boolean resizing) { |
| 1149 | if (mDragResizing == resizing) { |
| 1150 | return; |
| 1151 | } |
| 1152 | mDragResizing = resizing; |
| 1153 | for (int i = mTasks.size() - 1; i >= 0 ; i--) { |
| 1154 | mTasks.get(i).resetDragResizingChangeReported(); |
| 1155 | } |
| 1156 | } |
| 1157 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1158 | @Override // AnimatesBounds |
| 1159 | public boolean setSize(Rect bounds) { |
| 1160 | synchronized (mService.mWindowMap) { |
| 1161 | if (mDisplayContent == null) { |
| 1162 | return false; |
| 1163 | } |
| 1164 | } |
| 1165 | try { |
Wale Ogunwale | e75a9ad | 2016-03-18 20:43:49 -0700 | [diff] [blame] | 1166 | mService.mActivityManager.resizeStack(mStackId, bounds, false, true, false, -1); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1167 | } catch (RemoteException e) { |
| 1168 | } |
| 1169 | return true; |
| 1170 | } |
| 1171 | |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1172 | public boolean setPinnedStackSize(Rect bounds, Rect tempTaskBounds) { |
| 1173 | synchronized (mService.mWindowMap) { |
| 1174 | if (mDisplayContent == null) { |
| 1175 | return false; |
| 1176 | } |
| 1177 | if (mStackId != PINNED_STACK_ID) { |
| 1178 | Slog.w(TAG_WM, "Attempt to use pinned stack resize animation helper on" |
| 1179 | + "non pinned stack"); |
| 1180 | return false; |
| 1181 | } |
| 1182 | } |
| 1183 | try { |
| 1184 | mService.mActivityManager.resizePinnedStack(bounds, tempTaskBounds); |
| 1185 | } catch (RemoteException e) { |
| 1186 | // I don't believe you. |
| 1187 | } |
| 1188 | return true; |
| 1189 | } |
| 1190 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1191 | @Override // AnimatesBounds |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1192 | public void onAnimationStart() { |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1193 | synchronized (mService.mWindowMap) { |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1194 | mFreezeMovementAnimations = true; |
| 1195 | mForceScaleToCrop = true; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | @Override // AnimatesBounds |
| 1200 | public void onAnimationEnd() { |
| 1201 | synchronized (mService.mWindowMap) { |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1202 | mFreezeMovementAnimations = false; |
| 1203 | mForceScaleToCrop = false; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1204 | mService.requestTraversal(); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1205 | } |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 1206 | if (mStackId == PINNED_STACK_ID) { |
| 1207 | try { |
| 1208 | mService.mActivityManager.notifyPinnedStackAnimationEnded(); |
| 1209 | } catch (RemoteException e) { |
| 1210 | // I don't believe you... |
| 1211 | } |
| 1212 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1213 | } |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 1214 | |
| 1215 | @Override |
| 1216 | public void moveToFullscreen() { |
| 1217 | try { |
| 1218 | mService.mActivityManager.moveTasksToFullscreenStack(mStackId, true); |
| 1219 | } catch (RemoteException e) { |
| 1220 | e.printStackTrace(); |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | @Override |
| 1225 | public void getFullScreenBounds(Rect bounds) { |
| 1226 | getDisplayContent().getContentRect(bounds); |
| 1227 | } |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1228 | |
| 1229 | public boolean getFreezeMovementAnimations() { |
| 1230 | return mFreezeMovementAnimations; |
| 1231 | } |
| 1232 | |
| 1233 | public boolean getForceScaleToCrop() { |
| 1234 | return mForceScaleToCrop; |
| 1235 | } |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 1236 | } |