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 | |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
Chong Zhang | 73d4b44 | 2016-05-25 14:30:36 -0700 | [diff] [blame] | 20 | import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 21 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
Jorim Jaggi | d3ec507 | 2016-04-28 15:57:47 -0700 | [diff] [blame] | 22 | import static android.app.ActivityManager.StackId.HOME_STACK_ID; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 23 | import static android.app.ActivityManager.StackId.PINNED_STACK_ID; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 24 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 25 | import static android.content.res.Configuration.DENSITY_DPI_UNDEFINED; |
| 26 | import static android.content.res.Configuration.ORIENTATION_PORTRAIT; |
Winson Chung | 303c6b7 | 2016-10-24 17:12:49 -0700 | [diff] [blame] | 27 | import static android.view.Display.DEFAULT_DISPLAY; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 28 | import static android.view.WindowManager.DOCKED_BOTTOM; |
| 29 | import static android.view.WindowManager.DOCKED_INVALID; |
| 30 | import static android.view.WindowManager.DOCKED_LEFT; |
| 31 | import static android.view.WindowManager.DOCKED_RIGHT; |
| 32 | import static android.view.WindowManager.DOCKED_TOP; |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 33 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 34 | import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 35 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 36 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT; |
| 37 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 38 | import static com.android.server.wm.WindowManagerService.LAYER_OFFSET_DIM; |
Jorim Jaggi | 2917dc4 | 2016-04-11 11:39:13 -0700 | [diff] [blame] | 39 | |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 40 | import android.app.ActivityManager.StackId; |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 41 | import android.content.res.Configuration; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 42 | import android.graphics.Rect; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 43 | import android.graphics.Region; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 44 | import android.os.RemoteException; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 45 | import android.util.EventLog; |
Craig Mautner | f0ac5c8 | 2013-06-24 11:21:57 -0700 | [diff] [blame] | 46 | import android.util.Slog; |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 47 | import android.util.SparseArray; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 48 | import android.view.DisplayInfo; |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 49 | import android.view.Surface; |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 50 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 51 | import com.android.internal.policy.DividerSnapAlgorithm; |
| 52 | import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget; |
| 53 | import com.android.internal.policy.DockedDividerUtils; |
Craig Mautner | 2c2549c | 2013-11-12 08:31:15 -0800 | [diff] [blame] | 54 | import com.android.server.EventLogTags; |
Robert Carr | ecc06b3 | 2017-04-18 14:25:10 -0700 | [diff] [blame] | 55 | import com.android.server.UiThread; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 56 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 57 | import java.io.PrintWriter; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 58 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 59 | public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLayerUser, |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 60 | BoundsAnimationTarget { |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 61 | /** Minimum size of an adjusted stack bounds relative to original stack bounds. Used to |
| 62 | * restrict IME adjustment so that a min portion of top stack remains visible.*/ |
| 63 | private static final float ADJUSTED_STACK_FRACTION_MIN = 0.3f; |
| 64 | |
| 65 | /** Dimming amount for non-focused stack when stacks are IME-adjusted. */ |
| 66 | private static final float IME_ADJUST_DIM_AMOUNT = 0.25f; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 67 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 68 | /** Unique identifier */ |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 69 | final int mStackId; |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 70 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 71 | /** The service */ |
| 72 | private final WindowManagerService mService; |
| 73 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 74 | /** The display this stack sits under. */ |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 75 | // TODO: Track parent marks like this in WindowContainer. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 76 | private DisplayContent mDisplayContent; |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 77 | |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 78 | /** For comparison with DisplayContent bounds. */ |
| 79 | private Rect mTmpRect = new Rect(); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 80 | private Rect mTmpRect2 = new Rect(); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 81 | private Rect mTmpRect3 = new Rect(); |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 82 | |
| 83 | /** Content limits relative to the DisplayContent this sits in. */ |
| 84 | private Rect mBounds = new Rect(); |
| 85 | |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 86 | /** Stack bounds adjusted to screen content area (taking into account IM windows, etc.) */ |
| 87 | private final Rect mAdjustedBounds = new Rect(); |
| 88 | |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Fully adjusted IME bounds. These are different from {@link #mAdjustedBounds} because they |
| 91 | * represent the state when the animation has ended. |
| 92 | */ |
| 93 | private final Rect mFullyAdjustedImeBounds = new Rect(); |
| 94 | |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 95 | /** Whether mBounds is fullscreen */ |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 96 | private boolean mFillsParent = true; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 97 | |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 98 | // Device rotation as of the last time {@link #mBounds} was set. |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 99 | private int mRotation; |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 100 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 101 | /** Density as of last time {@link #mBounds} was set. */ |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 102 | private int mDensity; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 103 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 104 | /** Support for non-zero {@link android.view.animation.Animation#getBackgroundColor()} */ |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 105 | private DimLayer mAnimationBackgroundSurface; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 106 | |
| 107 | /** The particular window with an Animation with non-zero background color. */ |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 108 | private WindowStateAnimator mAnimationBackgroundAnimator; |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 109 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 110 | /** Application tokens that are exiting, but still on screen for animations. */ |
| 111 | final AppTokenList mExitingAppTokens = new AppTokenList(); |
Wale Ogunwale | 48458e1 | 2017-06-06 10:07:58 -0700 | [diff] [blame] | 112 | final AppTokenList mTmpAppTokens = new AppTokenList(); |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 113 | |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 114 | /** Detach this stack from its display when animation completes. */ |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 115 | // TODO: maybe tie this to WindowContainer#removeChild some how... |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 116 | boolean mDeferRemoval; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 117 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 118 | private final Rect mTmpAdjustedBounds = new Rect(); |
| 119 | private boolean mAdjustedForIme; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 120 | private boolean mImeGoingAway; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 121 | private WindowState mImeWin; |
| 122 | private float mMinimizeAmount; |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 123 | private float mAdjustImeAmount; |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 124 | private float mAdjustDividerAmount; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 125 | private final int mDockedStackMinimizeThickness; |
| 126 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 127 | // If this is true, we are in the bounds animating mode. The task will be down or upscaled to |
| 128 | // perfectly fit the region it would have been cropped to. We may also avoid certain logic we |
| 129 | // would otherwise apply while resizing, while resizing in the bounds animating mode. |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 130 | private boolean mBoundsAnimating = false; |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 131 | // Set when an animation has been requested but has not yet started from the UI thread. This is |
| 132 | // cleared when the animation actually starts. |
| 133 | private boolean mBoundsAnimatingRequested = false; |
Robert Carr | 7e4c90e | 2017-02-15 19:52:38 -0800 | [diff] [blame] | 134 | private boolean mBoundsAnimatingToFullscreen = false; |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 135 | private boolean mCancelCurrentBoundsAnimation = false; |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 136 | private Rect mBoundsAnimationTarget = new Rect(); |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 137 | private Rect mBoundsAnimationSourceHintBounds = new Rect(); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 138 | |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 139 | // Temporary storage for the new bounds that should be used after the configuration change. |
| 140 | // Will be cleared once the client retrieves the new bounds via getBoundsForNewConfiguration(). |
| 141 | private final Rect mBoundsAfterRotation = new Rect(); |
| 142 | |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 143 | Rect mPreAnimationBounds = new Rect(); |
| 144 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 145 | TaskStack(WindowManagerService service, int stackId) { |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 146 | mService = service; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 147 | mStackId = stackId; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 148 | mDockedStackMinimizeThickness = service.mContext.getResources().getDimensionPixelSize( |
| 149 | com.android.internal.R.dimen.docked_stack_minimize_thickness); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 150 | EventLog.writeEvent(EventLogTags.WM_STACK_CREATED, stackId); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | DisplayContent getDisplayContent() { |
| 154 | return mDisplayContent; |
| 155 | } |
| 156 | |
Jorim Jaggi | d3ec507 | 2016-04-28 15:57:47 -0700 | [diff] [blame] | 157 | Task findHomeTask() { |
| 158 | if (mStackId != HOME_STACK_ID) { |
| 159 | return null; |
| 160 | } |
| 161 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 162 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 163 | if (mChildren.get(i).isHomeTask()) { |
| 164 | return mChildren.get(i); |
Jorim Jaggi | d3ec507 | 2016-04-28 15:57:47 -0700 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | return null; |
| 168 | } |
| 169 | |
Wale Ogunwale | 15ead90 | 2016-09-02 14:30:11 -0700 | [diff] [blame] | 170 | boolean hasMultipleTaskWithHomeTaskNotTop() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 171 | return mChildren.size() > 1 && !mChildren.get(mChildren.size() - 1).isHomeTask(); |
Wale Ogunwale | 15ead90 | 2016-09-02 14:30:11 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 174 | /** |
| 175 | * Set the bounds of the stack and its containing tasks. |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 176 | * @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] | 177 | * @param configs Configuration for individual tasks, keyed by task id. |
| 178 | * @param taskBounds Bounds for individual tasks, keyed by task id. |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 179 | * @return True if the stack bounds was changed. |
| 180 | * */ |
Wale Ogunwale | a6e902e | 2015-09-21 18:37:15 -0700 | [diff] [blame] | 181 | boolean setBounds( |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 182 | Rect stackBounds, SparseArray<Configuration> configs, SparseArray<Rect> taskBounds, |
| 183 | SparseArray<Rect> taskTempInsetBounds) { |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 184 | setBounds(stackBounds); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 185 | |
| 186 | // Update bounds of containing tasks. |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 187 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) { |
| 188 | final Task task = mChildren.get(taskNdx); |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 189 | Configuration config = configs.get(task.mTaskId); |
| 190 | if (config != null) { |
| 191 | Rect bounds = taskBounds.get(task.mTaskId); |
Chong Zhang | 2e2c81a | 2016-07-15 11:28:17 -0700 | [diff] [blame] | 192 | task.resizeLocked(bounds, config, false /* forced */); |
| 193 | task.setTempInsetBounds(taskTempInsetBounds != null ? |
| 194 | taskTempInsetBounds.get(task.mTaskId) : null); |
Filip Gruszczynski | ebcc875 | 2015-08-25 16:51:05 -0700 | [diff] [blame] | 195 | } else { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 196 | 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] | 197 | } |
| 198 | } |
| 199 | return true; |
| 200 | } |
| 201 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 202 | void prepareFreezingTaskBounds() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 203 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) { |
| 204 | final Task task = mChildren.get(taskNdx); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 205 | task.prepareFreezingBounds(); |
| 206 | } |
| 207 | } |
| 208 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 209 | /** |
| 210 | * Overrides the adjusted bounds, i.e. sets temporary layout bounds which are different from |
| 211 | * the normal task bounds. |
| 212 | * |
| 213 | * @param bounds The adjusted bounds. |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 214 | */ |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 215 | private void setAdjustedBounds(Rect bounds) { |
| 216 | if (mAdjustedBounds.equals(bounds) && !isAnimatingForIme()) { |
| 217 | return; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | mAdjustedBounds.set(bounds); |
| 221 | final boolean adjusted = !mAdjustedBounds.isEmpty(); |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 222 | Rect insetBounds = null; |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 223 | if (adjusted && isAdjustedForMinimizedDockedStack()) { |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 224 | insetBounds = mBounds; |
Chong Zhang | 5117e27 | 2016-05-03 12:47:34 -0700 | [diff] [blame] | 225 | } else if (adjusted && mAdjustedForIme) { |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 226 | if (mImeGoingAway) { |
| 227 | insetBounds = mBounds; |
| 228 | } else { |
| 229 | insetBounds = mFullyAdjustedImeBounds; |
| 230 | } |
| 231 | } |
Chong Zhang | 741c0ba | 2016-05-27 12:52:11 -0700 | [diff] [blame] | 232 | alignTasksToAdjustedBounds(adjusted ? mAdjustedBounds : mBounds, insetBounds); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 233 | mDisplayContent.setLayoutNeeded(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | private void alignTasksToAdjustedBounds(Rect adjustedBounds, Rect tempInsetBounds) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 237 | if (mFillsParent) { |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 238 | return; |
| 239 | } |
Chong Zhang | 2e2c81a | 2016-07-15 11:28:17 -0700 | [diff] [blame] | 240 | |
| 241 | final boolean alignBottom = mAdjustedForIme && getDockSide() == DOCKED_TOP; |
| 242 | |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 243 | // Update bounds of containing tasks. |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 244 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) { |
| 245 | final Task task = mChildren.get(taskNdx); |
Chong Zhang | 2e2c81a | 2016-07-15 11:28:17 -0700 | [diff] [blame] | 246 | task.alignToAdjustedBounds(adjustedBounds, tempInsetBounds, alignBottom); |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 250 | private boolean setBounds(Rect bounds) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 251 | boolean oldFullscreen = mFillsParent; |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 252 | int rotation = Surface.ROTATION_0; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 253 | int density = DENSITY_DPI_UNDEFINED; |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 254 | if (mDisplayContent != null) { |
| 255 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 256 | rotation = mDisplayContent.getDisplayInfo().rotation; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 257 | density = mDisplayContent.getDisplayInfo().logicalDensityDpi; |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 258 | mFillsParent = bounds == null; |
| 259 | if (mFillsParent) { |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 260 | bounds = mTmpRect; |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 261 | } |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 264 | if (bounds == null) { |
Wale Ogunwale | 4a02d81 | 2015-02-12 23:01:38 -0800 | [diff] [blame] | 265 | // 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] | 266 | return false; |
| 267 | } |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 268 | if (mBounds.equals(bounds) && oldFullscreen == mFillsParent && mRotation == rotation) { |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 269 | return false; |
| 270 | } |
| 271 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 272 | if (mDisplayContent != null) { |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 273 | mDisplayContent.mDimLayerController.updateDimLayer(this); |
Filip Gruszczynski | 57b6cce | 2015-10-06 09:50:51 -0700 | [diff] [blame] | 274 | mAnimationBackgroundSurface.setBounds(bounds); |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 277 | mBounds.set(bounds); |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 278 | mRotation = rotation; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 279 | mDensity = density; |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 280 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 281 | updateAdjustedBounds(); |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 282 | |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 283 | return true; |
| 284 | } |
| 285 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 286 | /** Bounds of the stack without adjusting for other factors in the system like visibility |
| 287 | * of docked stack. |
| 288 | * Most callers should be using {@link #getBounds} as it take into consideration other system |
| 289 | * factors. */ |
| 290 | void getRawBounds(Rect out) { |
Craig Mautner | b660b9d | 2014-02-13 10:59:16 -0800 | [diff] [blame] | 291 | out.set(mBounds); |
| 292 | } |
| 293 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 294 | /** Return true if the current bound can get outputted to the rest of the system as-is. */ |
| 295 | private boolean useCurrentBounds() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 296 | if (mFillsParent |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 297 | || !StackId.isResizeableByDockedStack(mStackId) |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 298 | || mDisplayContent == null |
| 299 | || mDisplayContent.getDockedStackLocked() != null) { |
| 300 | return true; |
| 301 | } |
| 302 | return false; |
| 303 | } |
| 304 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 305 | public void getBounds(Rect out) { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 306 | if (useCurrentBounds()) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 307 | // If we're currently adjusting for IME or minimized docked stack, we use the adjusted |
| 308 | // bounds; otherwise, no need to adjust the output bounds if fullscreen or the docked |
| 309 | // stack is visible since it is already what we want to represent to the rest of the |
| 310 | // system. |
| 311 | if (!mAdjustedBounds.isEmpty()) { |
Chong Zhang | b816b86 | 2016-01-25 12:01:12 -0800 | [diff] [blame] | 312 | out.set(mAdjustedBounds); |
| 313 | } else { |
| 314 | out.set(mBounds); |
| 315 | } |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 316 | return; |
| 317 | } |
| 318 | |
| 319 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 320 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 321 | // system. |
| 322 | mDisplayContent.getLogicalDisplayRect(out); |
| 323 | } |
| 324 | |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 325 | /** |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 326 | * Sets the bounds animation target bounds ahead of an animation. This can't currently be done |
| 327 | * in onAnimationStart() since that is started on the UiThread. |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 328 | */ |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 329 | void setAnimationFinalBounds(Rect sourceHintBounds, Rect destBounds, boolean toFullscreen) { |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 330 | mBoundsAnimatingRequested = true; |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 331 | mBoundsAnimatingToFullscreen = toFullscreen; |
Winson Chung | 08f8189 | 2017-03-02 15:40:51 -0800 | [diff] [blame] | 332 | if (destBounds != null) { |
| 333 | mBoundsAnimationTarget.set(destBounds); |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 334 | } else { |
| 335 | mBoundsAnimationTarget.setEmpty(); |
| 336 | } |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 337 | if (sourceHintBounds != null) { |
| 338 | mBoundsAnimationSourceHintBounds.set(sourceHintBounds); |
| 339 | } else { |
| 340 | mBoundsAnimationSourceHintBounds.setEmpty(); |
| 341 | } |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 342 | |
| 343 | mPreAnimationBounds.set(mBounds); |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | /** |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 347 | * @return the final bounds for the bounds animation. |
Winson Chung | 08f8189 | 2017-03-02 15:40:51 -0800 | [diff] [blame] | 348 | */ |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 349 | void getFinalAnimationBounds(Rect outBounds) { |
| 350 | outBounds.set(mBoundsAnimationTarget); |
Winson Chung | 08f8189 | 2017-03-02 15:40:51 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /** |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 354 | * @return the final source bounds for the bounds animation. |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 355 | */ |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 356 | void getFinalAnimationSourceHintBounds(Rect outBounds) { |
| 357 | outBounds.set(mBoundsAnimationSourceHintBounds); |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | /** |
| 361 | * @return the final animation bounds if the task stack is currently being animated, or the |
| 362 | * current stack bounds otherwise. |
| 363 | */ |
| 364 | void getAnimationOrCurrentBounds(Rect outBounds) { |
| 365 | if ((mBoundsAnimatingRequested || mBoundsAnimating) && !mBoundsAnimationTarget.isEmpty()) { |
| 366 | getFinalAnimationBounds(outBounds); |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 367 | return; |
| 368 | } |
| 369 | getBounds(outBounds); |
| 370 | } |
| 371 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 372 | /** Bounds of the stack with other system factors taken into consideration. */ |
| 373 | @Override |
| 374 | public void getDimBounds(Rect out) { |
| 375 | getBounds(out); |
| 376 | } |
| 377 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 378 | void updateDisplayInfo(Rect bounds) { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 379 | if (mDisplayContent == null) { |
| 380 | return; |
| 381 | } |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 382 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 383 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) { |
| 384 | mChildren.get(taskNdx).updateDisplayInfo(mDisplayContent); |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 385 | } |
| 386 | if (bounds != null) { |
| 387 | setBounds(bounds); |
| 388 | return; |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 389 | } else if (mFillsParent) { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 390 | setBounds(null); |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | mTmpRect2.set(mBounds); |
| 395 | final int newRotation = mDisplayContent.getDisplayInfo().rotation; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 396 | final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi; |
| 397 | if (mRotation == newRotation && mDensity == newDensity) { |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 398 | setBounds(mTmpRect2); |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 399 | } |
Jorim Jaggi | eb1cb92 | 2016-04-27 20:37:45 -0700 | [diff] [blame] | 400 | |
| 401 | // If the rotation or density didn't match, we'll update it in onConfigurationChanged. |
Wale Ogunwale | 9d3de4c | 2015-02-01 16:49:44 -0800 | [diff] [blame] | 402 | } |
| 403 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 404 | /** @return true if bounds were updated to some non-empty value. */ |
| 405 | boolean updateBoundsAfterConfigChange() { |
Andrii Kulian | 0be2cfe | 2016-05-25 14:27:39 -0700 | [diff] [blame] | 406 | if (mDisplayContent == null) { |
| 407 | // If the stack is already detached we're not updating anything, |
| 408 | // as it's going away soon anyway. |
| 409 | return false; |
| 410 | } |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 411 | |
| 412 | if (mStackId == PINNED_STACK_ID) { |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 413 | getAnimationOrCurrentBounds(mTmpRect2); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 414 | boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged( |
| 415 | mTmpRect2, mTmpRect3); |
| 416 | if (updated) { |
| 417 | mBoundsAfterRotation.set(mTmpRect3); |
| 418 | |
| 419 | // Once we've set the bounds based on the rotation of the old bounds in the new |
| 420 | // orientation, clear the animation target bounds since they are obsolete, and |
| 421 | // cancel any currently running animations |
| 422 | mBoundsAnimationTarget.setEmpty(); |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 423 | mBoundsAnimationSourceHintBounds.setEmpty(); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 424 | mCancelCurrentBoundsAnimation = true; |
| 425 | return true; |
| 426 | } |
| 427 | } |
| 428 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 429 | final int newRotation = getDisplayInfo().rotation; |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 430 | final int newDensity = getDisplayInfo().logicalDensityDpi; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 431 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 432 | if (mRotation == newRotation && mDensity == newDensity) { |
Jorim Jaggi | eb1cb92 | 2016-04-27 20:37:45 -0700 | [diff] [blame] | 433 | // Nothing to do here as we already update the state in updateDisplayInfo. |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 434 | return false; |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 435 | } |
| 436 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 437 | if (mFillsParent) { |
Chong Zhang | ccc335c | 2016-05-13 11:04:38 -0700 | [diff] [blame] | 438 | // Update stack bounds again since rotation changed since updateDisplayInfo(). |
| 439 | setBounds(null); |
| 440 | // Return false since we don't need the client to resize. |
| 441 | return false; |
| 442 | } |
| 443 | |
Wale Ogunwale | 5952f9a | 2016-04-25 13:40:30 -0700 | [diff] [blame] | 444 | mTmpRect2.set(mBounds); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 445 | mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2); |
Winson Chung | cd1ff64 | 2016-10-26 09:44:43 -0700 | [diff] [blame] | 446 | switch (mStackId) { |
Winson Chung | cd1ff64 | 2016-10-26 09:44:43 -0700 | [diff] [blame] | 447 | case DOCKED_STACK_ID: |
| 448 | repositionDockedStackAfterRotation(mTmpRect2); |
| 449 | snapDockedStackAfterRotation(mTmpRect2); |
| 450 | final int newDockSide = getDockSide(mTmpRect2); |
| 451 | |
| 452 | // Update the dock create mode and clear the dock create bounds, these |
| 453 | // might change after a rotation and the original values will be invalid. |
| 454 | mService.setDockedStackCreateStateLocked( |
| 455 | (newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP) |
| 456 | ? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT |
| 457 | : DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, |
| 458 | null); |
| 459 | mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide); |
| 460 | break; |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 461 | } |
| 462 | |
Jorim Jaggi | eb1cb92 | 2016-04-27 20:37:45 -0700 | [diff] [blame] | 463 | mBoundsAfterRotation.set(mTmpRect2); |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 464 | return true; |
| 465 | } |
| 466 | |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 467 | void getBoundsForNewConfiguration(Rect outBounds) { |
Chong Zhang | 167bbfac | 2016-03-31 09:44:34 -0700 | [diff] [blame] | 468 | outBounds.set(mBoundsAfterRotation); |
| 469 | mBoundsAfterRotation.setEmpty(); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | /** |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 473 | * Some dock sides are not allowed by the policy. This method queries the policy and moves |
| 474 | * the docked stack around if needed. |
| 475 | * |
| 476 | * @param inOutBounds the bounds of the docked stack to adjust |
| 477 | */ |
| 478 | private void repositionDockedStackAfterRotation(Rect inOutBounds) { |
| 479 | int dockSide = getDockSide(inOutBounds); |
| 480 | if (mService.mPolicy.isDockSideAllowed(dockSide)) { |
| 481 | return; |
| 482 | } |
| 483 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 484 | dockSide = DockedDividerUtils.invertDockSide(dockSide); |
| 485 | switch (dockSide) { |
| 486 | case DOCKED_LEFT: |
| 487 | int movement = inOutBounds.left; |
| 488 | inOutBounds.left -= movement; |
| 489 | inOutBounds.right -= movement; |
| 490 | break; |
| 491 | case DOCKED_RIGHT: |
| 492 | movement = mTmpRect.right - inOutBounds.right; |
| 493 | inOutBounds.left += movement; |
| 494 | inOutBounds.right += movement; |
| 495 | break; |
| 496 | case DOCKED_TOP: |
| 497 | movement = inOutBounds.top; |
| 498 | inOutBounds.top -= movement; |
| 499 | inOutBounds.bottom -= movement; |
| 500 | break; |
| 501 | case DOCKED_BOTTOM: |
| 502 | movement = mTmpRect.bottom - inOutBounds.bottom; |
| 503 | inOutBounds.top += movement; |
| 504 | inOutBounds.bottom += movement; |
| 505 | break; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | /** |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 510 | * Snaps the bounds after rotation to the closest snap target for the docked stack. |
| 511 | */ |
| 512 | private void snapDockedStackAfterRotation(Rect outBounds) { |
| 513 | |
| 514 | // Calculate the current position. |
| 515 | final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 516 | final int dividerSize = mDisplayContent.getDockedDividerController().getContentWidth(); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 517 | final int dockSide = getDockSide(outBounds); |
| 518 | final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, |
| 519 | dockSide, dividerSize); |
| 520 | final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth; |
| 521 | final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight; |
| 522 | |
| 523 | // Snap the position to a target. |
| 524 | final int rotation = displayInfo.rotation; |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 525 | final int orientation = mDisplayContent.getConfiguration().orientation; |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 526 | mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds); |
| 527 | final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm( |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 528 | mService.mContext.getResources(), displayWidth, displayHeight, |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 529 | dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds, |
| 530 | isMinimizedDockAndHomeStackResizable()); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 531 | final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition); |
| 532 | |
| 533 | // Recalculate the bounds based on the position of the target. |
| 534 | DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, |
| 535 | outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, |
| 536 | dividerSize); |
| 537 | } |
| 538 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 539 | // TODO: Checkout the call points of this method and the ones below to see how they can fit in WC. |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 540 | void addTask(Task task, int position) { |
| 541 | addTask(task, position, task.showForAllUsers(), true /* moveParents */); |
Wale Ogunwale | 3fcb4a8 | 2015-04-06 14:00:13 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 544 | /** |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 545 | * Put a Task in this stack. Used for adding only. |
| 546 | * When task is added to top of the stack, the entire branch of the hierarchy (including stack |
| 547 | * and display) will be brought to top. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 548 | * @param task The task to add. |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 549 | * @param position Target position to add the task to. |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 550 | * @param showForAllUsers Whether to show the task regardless of the current user. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 551 | */ |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 552 | void addTask(Task task, int position, boolean showForAllUsers, boolean moveParents) { |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 553 | final TaskStack currentStack = task.mStack; |
| 554 | // TODO: We pass stack to task's constructor, but we still need to call this method. |
| 555 | // This doesn't make sense, mStack will already be set equal to "this" at this point. |
| 556 | if (currentStack != null && currentStack.mStackId != mStackId) { |
| 557 | throw new IllegalStateException("Trying to add taskId=" + task.mTaskId |
| 558 | + " to stackId=" + mStackId |
| 559 | + ", but it is already attached to stackId=" + task.mStack.mStackId); |
| 560 | } |
| 561 | |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 562 | // Add child task. |
| 563 | task.mStack = this; |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 564 | addChild(task, null); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 565 | |
| 566 | // Move child to a proper position, as some restriction for position might apply. |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 567 | positionChildAt(position, task, moveParents /* includingParents */, showForAllUsers); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | @Override |
| 571 | void positionChildAt(int position, Task child, boolean includingParents) { |
| 572 | positionChildAt(position, child, includingParents, child.showForAllUsers()); |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Overridden version of {@link TaskStack#positionChildAt(int, Task, boolean)}. Used in |
Wale Ogunwale | e1fe7fa2 | 2016-12-15 18:27:00 -0800 | [diff] [blame] | 577 | * {@link TaskStack#addTask(Task, int, boolean showForAllUsers, boolean)}, as it can receive |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 578 | * showForAllUsers param from {@link AppWindowToken} instead of {@link Task#showForAllUsers()}. |
| 579 | */ |
| 580 | private void positionChildAt(int position, Task child, boolean includingParents, |
| 581 | boolean showForAllUsers) { |
| 582 | final int targetPosition = findPositionForTask(child, position, showForAllUsers, |
| 583 | false /* addingNew */); |
| 584 | super.positionChildAt(targetPosition, child, includingParents); |
| 585 | |
| 586 | // Log positioning. |
| 587 | if (DEBUG_TASK_MOVEMENT) |
| 588 | Slog.d(TAG_WM, "positionTask: task=" + this + " position=" + position); |
| 589 | |
| 590 | final int toTop = targetPosition == mChildren.size() - 1 ? 1 : 0; |
| 591 | EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, child.mTaskId, toTop, targetPosition); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 594 | // TODO: We should really have users as a window container in the hierarchy so that we don't |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 595 | // have to do complicated things like we are doing in this method. |
| 596 | private int findPositionForTask(Task task, int targetPosition, boolean showForAllUsers, |
| 597 | boolean addingNew) { |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 598 | final boolean canShowTask = |
| 599 | showForAllUsers || mService.isCurrentProfileLocked(task.mUserId); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 600 | |
| 601 | final int stackSize = mChildren.size(); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 602 | int minPosition = 0; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 603 | int maxPosition = addingNew ? stackSize : stackSize - 1; |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 604 | |
| 605 | if (canShowTask) { |
| 606 | minPosition = computeMinPosition(minPosition, stackSize); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 607 | } else { |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 608 | maxPosition = computeMaxPosition(maxPosition); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 609 | } |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 610 | // Reset position based on minimum/maximum possible positions. |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 611 | return Math.min(Math.max(targetPosition, minPosition), maxPosition); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | /** Calculate the minimum possible position for a task that can be shown to the user. |
| 615 | * The minimum position will be above all other tasks that can't be shown. |
| 616 | * @param minPosition The minimum position the caller is suggesting. |
| 617 | * We will start adjusting up from here. |
| 618 | * @param size The size of the current task list. |
| 619 | */ |
| 620 | private int computeMinPosition(int minPosition, int size) { |
| 621 | while (minPosition < size) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 622 | final Task tmpTask = mChildren.get(minPosition); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 623 | final boolean canShowTmpTask = |
| 624 | tmpTask.showForAllUsers() |
| 625 | || mService.isCurrentProfileLocked(tmpTask.mUserId); |
| 626 | if (canShowTmpTask) { |
| 627 | break; |
| 628 | } |
| 629 | minPosition++; |
| 630 | } |
| 631 | return minPosition; |
| 632 | } |
| 633 | |
| 634 | /** Calculate the maximum possible position for a task that can't be shown to the user. |
| 635 | * The maximum position will be below all other tasks that can be shown. |
| 636 | * @param maxPosition The maximum position the caller is suggesting. |
| 637 | * We will start adjusting down from here. |
| 638 | */ |
| 639 | private int computeMaxPosition(int maxPosition) { |
| 640 | while (maxPosition > 0) { |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 641 | final Task tmpTask = mChildren.get(maxPosition); |
Wale Ogunwale | ddc1cb2 | 2015-07-25 19:23:04 -0700 | [diff] [blame] | 642 | final boolean canShowTmpTask = |
| 643 | tmpTask.showForAllUsers() |
| 644 | || mService.isCurrentProfileLocked(tmpTask.mUserId); |
| 645 | if (!canShowTmpTask) { |
| 646 | break; |
| 647 | } |
| 648 | maxPosition--; |
| 649 | } |
| 650 | return maxPosition; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 651 | } |
| 652 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 653 | /** |
Craig Mautner | 04a0ea6 | 2014-01-13 12:51:26 -0800 | [diff] [blame] | 654 | * Delete a Task from this stack. If it is the last Task in the stack, move this stack to the |
| 655 | * back. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 656 | * @param task The Task to delete. |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 657 | */ |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 658 | @Override |
| 659 | void removeChild(Task task) { |
| 660 | if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeChild: task=" + task); |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 661 | |
| 662 | super.removeChild(task); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 663 | task.mStack = null; |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 664 | |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 665 | if (mDisplayContent != null) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 666 | if (mChildren.isEmpty()) { |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 667 | getParent().positionChildAt(POSITION_BOTTOM, this, false /* includingParents */); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 668 | } |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 669 | mDisplayContent.setLayoutNeeded(); |
Craig Mautner | 04a0ea6 | 2014-01-13 12:51:26 -0800 | [diff] [blame] | 670 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 671 | for (int appNdx = mExitingAppTokens.size() - 1; appNdx >= 0; --appNdx) { |
| 672 | final AppWindowToken wtoken = mExitingAppTokens.get(appNdx); |
Bryce Lee | 6d41026 | 2017-02-28 15:30:17 -0800 | [diff] [blame] | 673 | if (wtoken.getTask() == task) { |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 674 | wtoken.mIsExiting = false; |
| 675 | mExitingAppTokens.remove(appNdx); |
| 676 | } |
| 677 | } |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 678 | } |
| 679 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 680 | void onDisplayChanged(DisplayContent dc) { |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 681 | if (mDisplayContent != null) { |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 682 | throw new IllegalStateException("onDisplayChanged: Already attached"); |
Craig Mautner | 4a1cb22 | 2013-12-04 16:14:06 -0800 | [diff] [blame] | 683 | } |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 684 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 685 | mDisplayContent = dc; |
Jorim Jaggi | bc5425c | 2016-03-01 13:51:16 +0100 | [diff] [blame] | 686 | mAnimationBackgroundSurface = new DimLayer(mService, this, mDisplayContent.getDisplayId(), |
| 687 | "animation background stackId=" + mStackId); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 688 | |
| 689 | Rect bounds = null; |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 690 | final TaskStack dockedStack = dc.getDockedStackIgnoringVisibility(); |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 691 | if (mStackId == DOCKED_STACK_ID |
Jorim Jaggi | 65002e1 | 2016-04-21 18:25:49 -0700 | [diff] [blame] | 692 | || (dockedStack != null && StackId.isResizeableByDockedStack(mStackId) |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 693 | && !dockedStack.fillsParent())) { |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 694 | // The existence of a docked stack affects the size of other static stack created since |
Jorim Jaggi | 65002e1 | 2016-04-21 18:25:49 -0700 | [diff] [blame] | 695 | // the docked stack occupies a dedicated region on screen, but only if the dock stack is |
| 696 | // not fullscreen. If it's fullscreen, it means that we are in the transition of |
| 697 | // dismissing it, so we must not resize this stack. |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 698 | bounds = new Rect(); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 699 | dc.getLogicalDisplayRect(mTmpRect); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 700 | mTmpRect2.setEmpty(); |
| 701 | if (dockedStack != null) { |
| 702 | dockedStack.getRawBounds(mTmpRect2); |
| 703 | } |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 704 | final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 705 | == DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
| 706 | getStackDockedModeBounds(mTmpRect, bounds, mStackId, mTmpRect2, |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 707 | mDisplayContent.mDividerControllerLocked.getContentWidth(), |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 708 | dockedOnTopOrLeft); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 709 | } else if (mStackId == PINNED_STACK_ID) { |
| 710 | // Update the bounds based on any changes to the display info |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 711 | getAnimationOrCurrentBounds(mTmpRect2); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 712 | boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged( |
| 713 | mTmpRect2, mTmpRect3); |
| 714 | if (updated) { |
| 715 | bounds = new Rect(mTmpRect3); |
| 716 | } |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | updateDisplayInfo(bounds); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 720 | super.onDisplayChanged(dc); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 721 | } |
| 722 | |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 723 | /** |
| 724 | * Determines the stack and task bounds of the other stack when in docked mode. The current task |
| 725 | * bounds is passed in but depending on the stack, the task and stack must match. Only in |
| 726 | * minimized mode with resizable launcher, the other stack ignores calculating the stack bounds |
| 727 | * and uses the task bounds passed in as the stack and task bounds, otherwise the stack bounds |
| 728 | * is calculated and is also used for its task bounds. |
| 729 | * If any of the out bounds are empty, it represents default bounds |
| 730 | * |
| 731 | * @param currentTempTaskBounds the current task bounds of the other stack |
| 732 | * @param outStackBounds the calculated stack bounds of the other stack |
| 733 | * @param outTempTaskBounds the calculated task bounds of the other stack |
| 734 | * @param ignoreVisibility ignore visibility in getting the stack bounds |
| 735 | */ |
| 736 | void getStackDockedModeBoundsLocked(Rect currentTempTaskBounds, Rect outStackBounds, |
| 737 | Rect outTempTaskBounds, boolean ignoreVisibility) { |
| 738 | outTempTaskBounds.setEmpty(); |
| 739 | |
| 740 | // When the home stack is resizable, should always have the same stack and task bounds |
Wale Ogunwale | 649c160 | 2017-04-24 10:15:31 -0700 | [diff] [blame] | 741 | if (mStackId == HOME_STACK_ID) { |
Winson Chung | f7fb5e3 | 2017-05-23 17:47:05 -0700 | [diff] [blame] | 742 | final Task homeTask = findHomeTask(); |
| 743 | if (homeTask != null && homeTask.isResizeable()) { |
Wale Ogunwale | 649c160 | 2017-04-24 10:15:31 -0700 | [diff] [blame] | 744 | // Calculate the home stack bounds when in docked mode and the home stack is |
| 745 | // resizeable. |
| 746 | getDisplayContent().mDividerControllerLocked |
| 747 | .getHomeStackBoundsInDockedMode(outStackBounds); |
| 748 | } else { |
| 749 | // Home stack isn't resizeable, so don't specify stack bounds. |
| 750 | outStackBounds.setEmpty(); |
| 751 | } |
| 752 | |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 753 | outTempTaskBounds.set(outStackBounds); |
| 754 | return; |
| 755 | } |
| 756 | |
| 757 | // When minimized state, the stack bounds for all non-home and docked stack bounds should |
| 758 | // match the passed task bounds |
| 759 | if (isMinimizedDockAndHomeStackResizable() && currentTempTaskBounds != null) { |
| 760 | outStackBounds.set(currentTempTaskBounds); |
| 761 | return; |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 762 | } |
| 763 | |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 764 | if ((mStackId != DOCKED_STACK_ID && !StackId.isResizeableByDockedStack(mStackId)) |
| 765 | || mDisplayContent == null) { |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 766 | outStackBounds.set(mBounds); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 767 | return; |
| 768 | } |
| 769 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 770 | final TaskStack dockedStack = mDisplayContent.getDockedStackIgnoringVisibility(); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 771 | if (dockedStack == null) { |
| 772 | // Not sure why you are calling this method when there is no docked stack... |
| 773 | throw new IllegalStateException( |
| 774 | "Calling getStackDockedModeBoundsLocked() when there is no docked stack."); |
| 775 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 776 | if (!ignoreVisibility && !dockedStack.isVisible()) { |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 777 | // The docked stack is being dismissed, but we caught before it finished being |
| 778 | // dismissed. In that case we want to treat it as if it is not occupying any space and |
| 779 | // let others occupy the whole display. |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 780 | mDisplayContent.getLogicalDisplayRect(outStackBounds); |
Filip Gruszczynski | 54977fe | 2015-10-19 17:26:45 -0700 | [diff] [blame] | 781 | return; |
| 782 | } |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 783 | |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 784 | final int dockedSide = dockedStack.getDockSide(); |
| 785 | if (dockedSide == DOCKED_INVALID) { |
| 786 | // 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] | 787 | Slog.e(TAG_WM, "Failed to get valid docked side for docked stack=" + dockedStack); |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 788 | outStackBounds.set(mBounds); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 789 | return; |
| 790 | } |
| 791 | |
| 792 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 793 | dockedStack.getRawBounds(mTmpRect2); |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 794 | final boolean dockedOnTopOrLeft = dockedSide == DOCKED_TOP || dockedSide == DOCKED_LEFT; |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 795 | getStackDockedModeBounds(mTmpRect, outStackBounds, mStackId, mTmpRect2, |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 796 | mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft); |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 797 | |
| 798 | } |
| 799 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 800 | /** |
Wale Ogunwale | ffc11bb | 2015-10-10 13:05:45 -0700 | [diff] [blame] | 801 | * 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] | 802 | * @param displayRect The bounds of the display the docked stack is on. |
| 803 | * @param outBounds Output bounds that should be used for the stack. |
| 804 | * @param stackId Id of stack we are calculating the bounds for. |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 805 | * @param dockedBounds Bounds of the docked stack. |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 806 | * @param dockDividerWidth We need to know the width of the divider make to the output bounds |
| 807 | * close to the side of the dock. |
| 808 | * @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] | 809 | */ |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 810 | private void getStackDockedModeBounds( |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 811 | Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth, |
| 812 | boolean dockOnTopOrLeft) { |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 813 | final boolean dockedStack = stackId == DOCKED_STACK_ID; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 814 | final boolean splitHorizontally = displayRect.width() > displayRect.height(); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 815 | |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 816 | outBounds.set(displayRect); |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 817 | if (dockedStack) { |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 818 | if (mService.mDockedStackCreateBounds != null) { |
| 819 | outBounds.set(mService.mDockedStackCreateBounds); |
| 820 | return; |
| 821 | } |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 822 | |
| 823 | // The initial bounds of the docked stack when it is created about half the screen space |
| 824 | // and its bounds can be adjusted after that. The bounds of all other stacks are |
| 825 | // adjusted to occupy whatever screen space the docked stack isn't occupying. |
| 826 | final DisplayInfo di = mDisplayContent.getDisplayInfo(); |
| 827 | mService.mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, |
| 828 | mTmpRect2); |
| 829 | final int position = new DividerSnapAlgorithm(mService.mContext.getResources(), |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 830 | di.logicalWidth, |
| 831 | di.logicalHeight, |
| 832 | dockDividerWidth, |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 833 | mDisplayContent.getConfiguration().orientation == ORIENTATION_PORTRAIT, |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 834 | mTmpRect2).getMiddleTarget().position; |
| 835 | |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 836 | if (dockOnTopOrLeft) { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 837 | if (splitHorizontally) { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 838 | outBounds.right = position; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 839 | } else { |
Jorim Jaggi | d434dcb | 2016-01-06 17:18:44 +0100 | [diff] [blame] | 840 | outBounds.bottom = position; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 841 | } |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 842 | } else { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 843 | if (splitHorizontally) { |
Andrii Kulian | ef3b272 | 2016-04-08 12:45:27 -0700 | [diff] [blame] | 844 | outBounds.left = position + dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 845 | } else { |
Andrii Kulian | ef3b272 | 2016-04-08 12:45:27 -0700 | [diff] [blame] | 846 | outBounds.top = position + dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 847 | } |
| 848 | } |
| 849 | return; |
| 850 | } |
| 851 | |
| 852 | // Other stacks occupy whatever space is left by the docked stack. |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 853 | if (!dockOnTopOrLeft) { |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 854 | if (splitHorizontally) { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 855 | outBounds.right = dockedBounds.left - dockDividerWidth; |
Wale Ogunwale | e45899a | 2015-10-01 11:30:34 -0700 | [diff] [blame] | 856 | } else { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 857 | outBounds.bottom = dockedBounds.top - dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 858 | } |
| 859 | } else { |
| 860 | if (splitHorizontally) { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 861 | outBounds.left = dockedBounds.right + dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 862 | } else { |
Filip Gruszczynski | ba47f81 | 2015-10-28 16:11:55 -0700 | [diff] [blame] | 863 | outBounds.top = dockedBounds.bottom + dockDividerWidth; |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 864 | } |
| 865 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 866 | DockedDividerUtils.sanitizeStackBounds(outBounds, !dockOnTopOrLeft); |
Wale Ogunwale | b34a7ad | 2015-08-14 11:05:30 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 869 | void resetDockedStackToMiddle() { |
| 870 | if (mStackId != DOCKED_STACK_ID) { |
| 871 | throw new IllegalStateException("Not a docked stack=" + this); |
| 872 | } |
| 873 | |
| 874 | mService.mDockedStackCreateBounds = null; |
| 875 | |
| 876 | final Rect bounds = new Rect(); |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 877 | final Rect tempBounds = new Rect(); |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 878 | getStackDockedModeBoundsLocked(null /* currentTempTaskBounds */, bounds, tempBounds, |
| 879 | true /*ignoreVisibility*/); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 880 | getController().requestResize(bounds); |
| 881 | } |
| 882 | |
| 883 | @Override |
| 884 | StackWindowController getController() { |
| 885 | return (StackWindowController) super.getController(); |
Wale Ogunwale | a9f9b37 | 2016-02-04 18:04:39 -0800 | [diff] [blame] | 886 | } |
| 887 | |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 888 | @Override |
| 889 | void removeIfPossible() { |
| 890 | if (isAnimating()) { |
| 891 | mDeferRemoval = true; |
| 892 | return; |
| 893 | } |
| 894 | removeImmediately(); |
| 895 | } |
| 896 | |
| 897 | @Override |
| 898 | void removeImmediately() { |
| 899 | super.removeImmediately(); |
| 900 | |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 901 | onRemovedFromDisplay(); |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * Removes the stack it from its current parent, so it can be either destroyed completely or |
| 906 | * re-parented. |
| 907 | */ |
| 908 | void onRemovedFromDisplay() { |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 909 | mDisplayContent.mDimLayerController.removeDimLayerUser(this); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 910 | EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 911 | |
| 912 | if (mAnimationBackgroundSurface != null) { |
| 913 | mAnimationBackgroundSurface.destroySurface(); |
| 914 | mAnimationBackgroundSurface = null; |
| 915 | } |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 916 | |
| 917 | if (mStackId == DOCKED_STACK_ID) { |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 918 | mDisplayContent.mDividerControllerLocked.notifyDockedStackExistsChanged(false); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 919 | } |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 920 | |
| 921 | mDisplayContent = null; |
| 922 | mService.mWindowPlacerLocked.requestTraversal(); |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 923 | } |
| 924 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 925 | void resetAnimationBackgroundAnimator() { |
| 926 | mAnimationBackgroundAnimator = null; |
| 927 | mAnimationBackgroundSurface.hide(); |
| 928 | } |
| 929 | |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 930 | void setAnimationBackground(WindowStateAnimator winAnimator, int color) { |
| 931 | int animLayer = winAnimator.mAnimLayer; |
| 932 | if (mAnimationBackgroundAnimator == null |
| 933 | || animLayer < mAnimationBackgroundAnimator.mAnimLayer) { |
| 934 | mAnimationBackgroundAnimator = winAnimator; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 935 | animLayer = mDisplayContent.getLayerForAnimationBackground(winAnimator); |
| 936 | mAnimationBackgroundSurface.show(animLayer - LAYER_OFFSET_DIM, |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 937 | ((color >> 24) & 0xff) / 255f, 0); |
| 938 | } |
| 939 | } |
| 940 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 941 | // TODO: Should each user have there own stacks? |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 942 | @Override |
Wale Ogunwale | 498e8c9 | 2015-02-13 09:42:46 -0800 | [diff] [blame] | 943 | void switchUser() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 944 | super.switchUser(); |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 945 | int top = mChildren.size(); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 946 | for (int taskNdx = 0; taskNdx < top; ++taskNdx) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 947 | Task task = mChildren.get(taskNdx); |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 948 | if (mService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 949 | mChildren.remove(taskNdx); |
| 950 | mChildren.add(task); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 951 | --top; |
| 952 | } |
| 953 | } |
| 954 | } |
| 955 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 956 | /** |
| 957 | * Adjusts the stack bounds if the IME is visible. |
| 958 | * |
| 959 | * @param imeWin The IME window. |
| 960 | */ |
Keisuke Kuroyanagi | 19d9a8f | 2016-05-12 16:49:02 -0700 | [diff] [blame] | 961 | void setAdjustedForIme(WindowState imeWin, boolean forceUpdate) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 962 | mImeWin = imeWin; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 963 | mImeGoingAway = false; |
Keisuke Kuroyanagi | 19d9a8f | 2016-05-12 16:49:02 -0700 | [diff] [blame] | 964 | if (!mAdjustedForIme || forceUpdate) { |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 965 | mAdjustedForIme = true; |
| 966 | mAdjustImeAmount = 0f; |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 967 | mAdjustDividerAmount = 0f; |
| 968 | updateAdjustForIme(0f, 0f, true /* force */); |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 969 | } |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 970 | } |
| 971 | |
| 972 | boolean isAdjustedForIme() { |
Chong Zhang | 5117e27 | 2016-05-03 12:47:34 -0700 | [diff] [blame] | 973 | return mAdjustedForIme; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 974 | } |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 975 | |
| 976 | boolean isAnimatingForIme() { |
| 977 | return mImeWin != null && mImeWin.isAnimatingLw(); |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * Update the stack's bounds (crop or position) according to the IME window's |
| 982 | * current position. When IME window is animated, the bottom stack is animated |
| 983 | * together to track the IME window's current position, and the top stack is |
| 984 | * cropped as necessary. |
| 985 | * |
| 986 | * @return true if a traversal should be performed after the adjustment. |
| 987 | */ |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 988 | boolean updateAdjustForIme(float adjustAmount, float adjustDividerAmount, boolean force) { |
| 989 | if (adjustAmount != mAdjustImeAmount |
| 990 | || adjustDividerAmount != mAdjustDividerAmount || force) { |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 991 | mAdjustImeAmount = adjustAmount; |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 992 | mAdjustDividerAmount = adjustDividerAmount; |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 993 | updateAdjustedBounds(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 994 | return isVisible(); |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 995 | } else { |
| 996 | return false; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 997 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | /** |
| 1001 | * Resets the adjustment after it got adjusted for the IME. |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 1002 | * @param adjustBoundsNow if true, reset and update the bounds immediately and forget about |
| 1003 | * animations; otherwise, set flag and animates the window away together |
| 1004 | * with IME window. |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1005 | */ |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 1006 | void resetAdjustedForIme(boolean adjustBoundsNow) { |
| 1007 | if (adjustBoundsNow) { |
| 1008 | mImeWin = null; |
| 1009 | mAdjustedForIme = false; |
| 1010 | mImeGoingAway = false; |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1011 | mAdjustImeAmount = 0f; |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 1012 | mAdjustDividerAmount = 0f; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 1013 | updateAdjustedBounds(); |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1014 | mService.setResizeDimLayer(false, mStackId, 1.0f); |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 1015 | } else { |
| 1016 | mImeGoingAway |= mAdjustedForIme; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 1017 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | /** |
| 1021 | * Sets the amount how much we currently minimize our stack. |
| 1022 | * |
| 1023 | * @param minimizeAmount The amount, between 0 and 1. |
| 1024 | * @return Whether the amount has changed and a layout is needed. |
| 1025 | */ |
| 1026 | boolean setAdjustedForMinimizedDock(float minimizeAmount) { |
| 1027 | if (minimizeAmount != mMinimizeAmount) { |
| 1028 | mMinimizeAmount = minimizeAmount; |
| 1029 | updateAdjustedBounds(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1030 | return isVisible(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1031 | } else { |
| 1032 | return false; |
| 1033 | } |
| 1034 | } |
| 1035 | |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 1036 | boolean shouldIgnoreInput() { |
| 1037 | return isAdjustedForMinimizedDockedStack() || mStackId == DOCKED_STACK_ID && |
| 1038 | isMinimizedDockAndHomeStackResizable(); |
Jorim Jaggi | 409635b | 2016-04-01 15:32:28 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 1041 | /** |
| 1042 | * Puts all visible tasks that are adjusted for IME into resizing mode and adds the windows |
| 1043 | * to the list of to be drawn windows the service is waiting for. |
| 1044 | */ |
| 1045 | void beginImeAdjustAnimation() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1046 | for (int j = mChildren.size() - 1; j >= 0; j--) { |
| 1047 | final Task task = mChildren.get(j); |
Wale Ogunwale | 44f2180 | 2016-09-02 12:49:48 -0700 | [diff] [blame] | 1048 | if (task.hasContentToDisplay()) { |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 1049 | task.setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1050 | task.setWaitingForDrawnIfResizingChanged(); |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * Resets the resizing state of all windows. |
| 1057 | */ |
| 1058 | void endImeAdjustAnimation() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1059 | for (int j = mChildren.size() - 1; j >= 0; j--) { |
| 1060 | mChildren.get(j).setDragResizing(false, DRAG_RESIZE_MODE_DOCKED_DIVIDER); |
Jorim Jaggi | ff71d20 | 2016-04-14 13:12:36 -0700 | [diff] [blame] | 1061 | } |
| 1062 | } |
| 1063 | |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1064 | int getMinTopStackBottom(final Rect displayContentRect, int originalStackBottom) { |
| 1065 | return displayContentRect.top + (int) |
| 1066 | ((originalStackBottom - displayContentRect.top) * ADJUSTED_STACK_FRACTION_MIN); |
| 1067 | } |
| 1068 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1069 | private boolean adjustForIME(final WindowState imeWin) { |
| 1070 | final int dockedSide = getDockSide(); |
| 1071 | final boolean dockedTopOrBottom = dockedSide == DOCKED_TOP || dockedSide == DOCKED_BOTTOM; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1072 | if (imeWin == null || !dockedTopOrBottom) { |
| 1073 | return false; |
| 1074 | } |
| 1075 | |
| 1076 | final Rect displayContentRect = mTmpRect; |
| 1077 | final Rect contentBounds = mTmpRect2; |
| 1078 | |
| 1079 | // Calculate the content bounds excluding the area occupied by IME |
| 1080 | getDisplayContent().getContentRect(displayContentRect); |
| 1081 | contentBounds.set(displayContentRect); |
Jorim Jaggi | 5ac2ba2 | 2016-04-11 21:14:12 -0700 | [diff] [blame] | 1082 | int imeTop = Math.max(imeWin.getFrameLw().top, contentBounds.top); |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 1083 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1084 | imeTop += imeWin.getGivenContentInsetsLw().top; |
| 1085 | if (contentBounds.bottom > imeTop) { |
| 1086 | contentBounds.bottom = imeTop; |
| 1087 | } |
| 1088 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1089 | final int yOffset = displayContentRect.bottom - contentBounds.bottom; |
| 1090 | |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1091 | final int dividerWidth = |
| 1092 | getDisplayContent().mDividerControllerLocked.getContentWidth(); |
| 1093 | final int dividerWidthInactive = |
| 1094 | getDisplayContent().mDividerControllerLocked.getContentWidthInactive(); |
| 1095 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1096 | if (dockedSide == DOCKED_TOP) { |
| 1097 | // If this stack is docked on top, we make it smaller so the bottom stack is not |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1098 | // occluded by IME. We shift its bottom up by the height of the IME, but |
| 1099 | // leaves at least 30% of the top stack visible. |
| 1100 | final int minTopStackBottom = |
| 1101 | getMinTopStackBottom(displayContentRect, mBounds.bottom); |
| 1102 | final int bottom = Math.max( |
| 1103 | mBounds.bottom - yOffset + dividerWidth - dividerWidthInactive, |
| 1104 | minTopStackBottom); |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1105 | mTmpAdjustedBounds.set(mBounds); |
| 1106 | mTmpAdjustedBounds.bottom = |
| 1107 | (int) (mAdjustImeAmount * bottom + (1 - mAdjustImeAmount) * mBounds.bottom); |
| 1108 | mFullyAdjustedImeBounds.set(mBounds); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1109 | } else { |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 1110 | // When the stack is on bottom and has no focus, it's only adjusted for divider width. |
| 1111 | final int dividerWidthDelta = dividerWidthInactive - dividerWidth; |
| 1112 | |
| 1113 | // When the stack is on bottom and has focus, it needs to be moved up so as to |
| 1114 | // not occluded by IME, and at the same time adjusted for divider width. |
| 1115 | // We try to move it up by the height of the IME window, but only to the extent |
| 1116 | // that leaves at least 30% of the top stack visible. |
| 1117 | // 'top' is where the top of bottom stack will move to in this case. |
| 1118 | final int topBeforeImeAdjust = mBounds.top - dividerWidth + dividerWidthInactive; |
| 1119 | final int minTopStackBottom = |
| 1120 | getMinTopStackBottom(displayContentRect, mBounds.top - dividerWidth); |
| 1121 | final int top = Math.max( |
| 1122 | mBounds.top - yOffset, minTopStackBottom + dividerWidthInactive); |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1123 | |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1124 | mTmpAdjustedBounds.set(mBounds); |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 1125 | // Account for the adjustment for IME and divider width separately. |
| 1126 | // (top - topBeforeImeAdjust) is the amount of movement due to IME only, |
| 1127 | // and dividerWidthDelta is due to divider width change only. |
| 1128 | mTmpAdjustedBounds.top = mBounds.top + |
| 1129 | (int) (mAdjustImeAmount * (top - topBeforeImeAdjust) + |
| 1130 | mAdjustDividerAmount * dividerWidthDelta); |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1131 | mFullyAdjustedImeBounds.set(mBounds); |
| 1132 | mFullyAdjustedImeBounds.top = top; |
| 1133 | mFullyAdjustedImeBounds.bottom = top + mBounds.height(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1134 | } |
| 1135 | return true; |
| 1136 | } |
| 1137 | |
| 1138 | private boolean adjustForMinimizedDockedStack(float minimizeAmount) { |
| 1139 | final int dockSide = getDockSide(); |
| 1140 | if (dockSide == DOCKED_INVALID && !mTmpAdjustedBounds.isEmpty()) { |
| 1141 | return false; |
| 1142 | } |
| 1143 | |
| 1144 | if (dockSide == DOCKED_TOP) { |
Winson Chung | 303c6b7 | 2016-10-24 17:12:49 -0700 | [diff] [blame] | 1145 | mService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1146 | int topInset = mTmpRect.top; |
| 1147 | mTmpAdjustedBounds.set(mBounds); |
| 1148 | mTmpAdjustedBounds.bottom = |
| 1149 | (int) (minimizeAmount * topInset + (1 - minimizeAmount) * mBounds.bottom); |
| 1150 | } else if (dockSide == DOCKED_LEFT) { |
| 1151 | mTmpAdjustedBounds.set(mBounds); |
Jorim Jaggi | bcff143 | 2016-04-01 15:49:45 -0700 | [diff] [blame] | 1152 | final int width = mBounds.width(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1153 | mTmpAdjustedBounds.right = |
| 1154 | (int) (minimizeAmount * mDockedStackMinimizeThickness |
| 1155 | + (1 - minimizeAmount) * mBounds.right); |
Jorim Jaggi | bcff143 | 2016-04-01 15:49:45 -0700 | [diff] [blame] | 1156 | mTmpAdjustedBounds.left = mTmpAdjustedBounds.right - width; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1157 | } else if (dockSide == DOCKED_RIGHT) { |
| 1158 | mTmpAdjustedBounds.set(mBounds); |
| 1159 | mTmpAdjustedBounds.left = |
| 1160 | (int) (minimizeAmount * (mBounds.right - mDockedStackMinimizeThickness) |
| 1161 | + (1 - minimizeAmount) * mBounds.left); |
| 1162 | } |
| 1163 | return true; |
| 1164 | } |
| 1165 | |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 1166 | private boolean isMinimizedDockAndHomeStackResizable() { |
| 1167 | return mDisplayContent.mDividerControllerLocked.isMinimizedDock() |
| 1168 | && mDisplayContent.mDividerControllerLocked.isHomeStackResizable(); |
| 1169 | } |
| 1170 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1171 | /** |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 1172 | * @return the distance in pixels how much the stack gets minimized from it's original size |
| 1173 | */ |
| 1174 | int getMinimizeDistance() { |
| 1175 | final int dockSide = getDockSide(); |
| 1176 | if (dockSide == DOCKED_INVALID) { |
| 1177 | return 0; |
| 1178 | } |
| 1179 | |
| 1180 | if (dockSide == DOCKED_TOP) { |
Winson Chung | 303c6b7 | 2016-10-24 17:12:49 -0700 | [diff] [blame] | 1181 | mService.getStableInsetsLocked(DEFAULT_DISPLAY, mTmpRect); |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 1182 | int topInset = mTmpRect.top; |
| 1183 | return mBounds.bottom - topInset; |
| 1184 | } else if (dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT) { |
| 1185 | return mBounds.width() - mDockedStackMinimizeThickness; |
| 1186 | } else { |
| 1187 | return 0; |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | /** |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1192 | * Updates the adjustment depending on it's current state. |
| 1193 | */ |
Chong Zhang | 5117e27 | 2016-05-03 12:47:34 -0700 | [diff] [blame] | 1194 | private void updateAdjustedBounds() { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1195 | boolean adjust = false; |
| 1196 | if (mMinimizeAmount != 0f) { |
| 1197 | adjust = adjustForMinimizedDockedStack(mMinimizeAmount); |
| 1198 | } else if (mAdjustedForIme) { |
| 1199 | adjust = adjustForIME(mImeWin); |
| 1200 | } |
| 1201 | if (!adjust) { |
| 1202 | mTmpAdjustedBounds.setEmpty(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1203 | } |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1204 | setAdjustedBounds(mTmpAdjustedBounds); |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1205 | |
Chong Zhang | b8da4a7 | 2016-05-17 15:07:26 -0700 | [diff] [blame] | 1206 | final boolean isImeTarget = (mService.getImeFocusStackLocked() == this); |
Chong Zhang | f347ab5 | 2016-04-18 21:02:01 -0700 | [diff] [blame] | 1207 | if (mAdjustedForIme && adjust && !isImeTarget) { |
| 1208 | final float alpha = Math.max(mAdjustImeAmount, mAdjustDividerAmount) |
| 1209 | * IME_ADJUST_DIM_AMOUNT; |
Chong Zhang | 198afac | 2016-04-15 12:03:11 -0700 | [diff] [blame] | 1210 | mService.setResizeDimLayer(true, mStackId, alpha); |
| 1211 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1212 | } |
| 1213 | |
Chong Zhang | 5117e27 | 2016-05-03 12:47:34 -0700 | [diff] [blame] | 1214 | void applyAdjustForImeIfNeeded(Task task) { |
| 1215 | if (mMinimizeAmount != 0f || !mAdjustedForIme || mAdjustedBounds.isEmpty()) { |
| 1216 | return; |
| 1217 | } |
| 1218 | |
| 1219 | final Rect insetBounds = mImeGoingAway ? mBounds : mFullyAdjustedImeBounds; |
| 1220 | task.alignToAdjustedBounds(mAdjustedBounds, insetBounds, getDockSide() == DOCKED_TOP); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1221 | mDisplayContent.setLayoutNeeded(); |
Chong Zhang | 5117e27 | 2016-05-03 12:47:34 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1224 | boolean isAdjustedForMinimizedDockedStack() { |
| 1225 | return mMinimizeAmount != 0f; |
| 1226 | } |
| 1227 | |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1228 | public void dump(String prefix, PrintWriter pw) { |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 1229 | pw.println(prefix + "mStackId=" + mStackId); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1230 | pw.println(prefix + "mDeferRemoval=" + mDeferRemoval); |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1231 | pw.println(prefix + "mFillsParent=" + mFillsParent); |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 1232 | pw.println(prefix + "mBounds=" + mBounds.toShortString()); |
Jorim Jaggi | af558e1 | 2016-04-27 22:56:56 -0700 | [diff] [blame] | 1233 | if (mMinimizeAmount != 0f) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1234 | pw.println(prefix + "mMinimizeAmount=" + mMinimizeAmount); |
Jorim Jaggi | af558e1 | 2016-04-27 22:56:56 -0700 | [diff] [blame] | 1235 | } |
| 1236 | if (mAdjustedForIme) { |
| 1237 | pw.println(prefix + "mAdjustedForIme=true"); |
| 1238 | pw.println(prefix + "mAdjustImeAmount=" + mAdjustImeAmount); |
| 1239 | pw.println(prefix + "mAdjustDividerAmount=" + mAdjustDividerAmount); |
| 1240 | } |
Jorim Jaggi | eb88d83 | 2016-04-13 20:17:43 -0700 | [diff] [blame] | 1241 | if (!mAdjustedBounds.isEmpty()) { |
| 1242 | pw.println(prefix + "mAdjustedBounds=" + mAdjustedBounds.toShortString()); |
| 1243 | } |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1244 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; taskNdx--) { |
| 1245 | mChildren.get(taskNdx).dump(prefix + " ", pw); |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1246 | } |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1247 | if (mAnimationBackgroundSurface.isDimming()) { |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 1248 | pw.println(prefix + "mWindowAnimationBackgroundSurface:"); |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1249 | mAnimationBackgroundSurface.printTo(prefix + " ", pw); |
| 1250 | } |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 1251 | if (!mExitingAppTokens.isEmpty()) { |
| 1252 | pw.println(); |
| 1253 | pw.println(" Exiting application tokens:"); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1254 | for (int i = mExitingAppTokens.size() - 1; i >= 0; i--) { |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 1255 | WindowToken token = mExitingAppTokens.get(i); |
| 1256 | pw.print(" Exiting App #"); pw.print(i); |
| 1257 | pw.print(' '); pw.print(token); |
| 1258 | pw.println(':'); |
| 1259 | token.dump(pw, " "); |
| 1260 | } |
| 1261 | } |
Craig Mautner | 00af9fe | 2013-03-25 09:13:41 -0700 | [diff] [blame] | 1262 | } |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1263 | |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1264 | /** Fullscreen status of the stack without adjusting for other factors in the system like |
| 1265 | * visibility of docked stack. |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1266 | * Most callers should be using {@link #fillsParent} as it take into consideration other |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1267 | * system factors. */ |
| 1268 | boolean getRawFullscreen() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1269 | return mFillsParent; |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1270 | } |
| 1271 | |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1272 | @Override |
Wale Ogunwale | 29bfbb8 | 2016-05-12 15:13:52 -0700 | [diff] [blame] | 1273 | public boolean dimFullscreen() { |
Matthew Ng | ae1ff4f | 2016-11-10 15:49:14 -0800 | [diff] [blame] | 1274 | return StackId.isHomeOrRecentsStack(mStackId) || fillsParent(); |
Wale Ogunwale | 29bfbb8 | 2016-05-12 15:13:52 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1277 | @Override |
| 1278 | boolean fillsParent() { |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1279 | if (useCurrentBounds()) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1280 | return mFillsParent; |
Wale Ogunwale | f175e8a | 2015-09-29 11:07:06 -0700 | [diff] [blame] | 1281 | } |
| 1282 | // The bounds has been adjusted to accommodate for a docked stack, but the docked stack |
| 1283 | // is not currently visible. Go ahead a represent it as fullscreen to the rest of the |
| 1284 | // system. |
| 1285 | return true; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1286 | } |
| 1287 | |
| 1288 | @Override |
| 1289 | public DisplayInfo getDisplayInfo() { |
| 1290 | return mDisplayContent.getDisplayInfo(); |
| 1291 | } |
| 1292 | |
| 1293 | @Override |
Wale Ogunwale | f0a60a9 | 2017-01-19 09:44:40 -0800 | [diff] [blame] | 1294 | public boolean isAttachedToDisplay() { |
| 1295 | return mDisplayContent != null; |
| 1296 | } |
| 1297 | |
| 1298 | @Override |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1299 | public String toString() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1300 | return "{stackId=" + mStackId + " tasks=" + mChildren + "}"; |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 1301 | } |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1302 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1303 | String getName() { |
| 1304 | return toShortString(); |
| 1305 | } |
| 1306 | |
Filip Gruszczynski | 0689ae9 | 2015-10-01 12:30:31 -0700 | [diff] [blame] | 1307 | @Override |
| 1308 | public String toShortString() { |
| 1309 | return "Stack=" + mStackId; |
| 1310 | } |
| 1311 | |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1312 | /** |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 1313 | * For docked workspace (or workspace that's side-by-side to the docked), provides |
| 1314 | * information which side of the screen was the dock anchored. |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1315 | */ |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1316 | int getDockSide() { |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1317 | return getDockSide(mBounds); |
| 1318 | } |
| 1319 | |
| 1320 | int getDockSide(Rect bounds) { |
Chong Zhang | c806d90 | 2015-11-30 09:44:27 -0800 | [diff] [blame] | 1321 | if (mStackId != DOCKED_STACK_ID && !StackId.isResizeableByDockedStack(mStackId)) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1322 | return DOCKED_INVALID; |
| 1323 | } |
| 1324 | if (mDisplayContent == null) { |
| 1325 | return DOCKED_INVALID; |
| 1326 | } |
| 1327 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1328 | final int orientation = mDisplayContent.getConfiguration().orientation; |
Jorim Jaggi | 8563943 | 2016-05-06 17:27:55 -0700 | [diff] [blame] | 1329 | return getDockSideUnchecked(bounds, mTmpRect, orientation); |
| 1330 | } |
| 1331 | |
| 1332 | static int getDockSideUnchecked(Rect bounds, Rect displayRect, int orientation) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1333 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 1334 | // Portrait mode, docked either at the top or the bottom. |
Jorim Jaggi | 8563943 | 2016-05-06 17:27:55 -0700 | [diff] [blame] | 1335 | if (bounds.top - displayRect.top <= displayRect.bottom - bounds.bottom) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1336 | return DOCKED_TOP; |
| 1337 | } else { |
| 1338 | return DOCKED_BOTTOM; |
| 1339 | } |
| 1340 | } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { |
| 1341 | // Landscape mode, docked either on the left or on the right. |
Jorim Jaggi | 8563943 | 2016-05-06 17:27:55 -0700 | [diff] [blame] | 1342 | if (bounds.left - displayRect.left <= displayRect.right - bounds.right) { |
Filip Gruszczynski | 923f826 | 2015-09-17 17:41:13 -0700 | [diff] [blame] | 1343 | return DOCKED_LEFT; |
| 1344 | } else { |
| 1345 | return DOCKED_RIGHT; |
| 1346 | } |
| 1347 | } else { |
| 1348 | return DOCKED_INVALID; |
| 1349 | } |
| 1350 | } |
Filip Gruszczynski | 3ddc5d6 | 2015-09-23 15:01:30 -0700 | [diff] [blame] | 1351 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1352 | boolean hasTaskForUser(int userId) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1353 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 1354 | final Task task = mChildren.get(i); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1355 | if (task.mUserId == userId) { |
| 1356 | return true; |
| 1357 | } |
| 1358 | } |
| 1359 | return false; |
| 1360 | } |
| 1361 | |
| 1362 | int taskIdFromPoint(int x, int y) { |
| 1363 | getBounds(mTmpRect); |
| 1364 | if (!mTmpRect.contains(x, y) || isAdjustedForMinimizedDockedStack()) { |
| 1365 | return -1; |
| 1366 | } |
| 1367 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1368 | for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) { |
| 1369 | final Task task = mChildren.get(taskNdx); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1370 | final WindowState win = task.getTopVisibleAppMainWindow(); |
| 1371 | if (win == null) { |
| 1372 | continue; |
| 1373 | } |
| 1374 | // We need to use the task's dim bounds (which is derived from the visible bounds of its |
| 1375 | // apps windows) for any touch-related tests. Can't use the task's original bounds |
| 1376 | // because it might be adjusted to fit the content frame. For example, the presence of |
| 1377 | // the IME adjusting the windows frames when the app window is the IME target. |
| 1378 | task.getDimBounds(mTmpRect); |
| 1379 | if (mTmpRect.contains(x, y)) { |
| 1380 | return task.mTaskId; |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | return -1; |
| 1385 | } |
| 1386 | |
| 1387 | void findTaskForResizePoint(int x, int y, int delta, |
| 1388 | DisplayContent.TaskForResizePointSearchResult results) { |
| 1389 | if (!StackId.isTaskResizeAllowed(mStackId)) { |
| 1390 | results.searchDone = true; |
| 1391 | return; |
| 1392 | } |
| 1393 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1394 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 1395 | final Task task = mChildren.get(i); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1396 | if (task.isFullscreen()) { |
| 1397 | results.searchDone = true; |
| 1398 | return; |
| 1399 | } |
| 1400 | |
| 1401 | // We need to use the task's dim bounds (which is derived from the visible bounds of |
| 1402 | // its apps windows) for any touch-related tests. Can't use the task's original |
| 1403 | // bounds because it might be adjusted to fit the content frame. One example is when |
| 1404 | // the task is put to top-left quadrant, the actual visible area would not start at |
| 1405 | // (0,0) after it's adjusted for the status bar. |
| 1406 | task.getDimBounds(mTmpRect); |
| 1407 | mTmpRect.inset(-delta, -delta); |
| 1408 | if (mTmpRect.contains(x, y)) { |
| 1409 | mTmpRect.inset(delta, delta); |
| 1410 | |
| 1411 | results.searchDone = true; |
| 1412 | |
| 1413 | if (!mTmpRect.contains(x, y)) { |
| 1414 | results.taskForResize = task; |
| 1415 | return; |
| 1416 | } |
| 1417 | // User touched inside the task. No need to look further, |
| 1418 | // focus transfer will be handled in ACTION_UP. |
| 1419 | return; |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | void setTouchExcludeRegion(Task focusedTask, int delta, Region touchExcludeRegion, |
| 1425 | Rect contentRect, Rect postExclude) { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1426 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 1427 | final Task task = mChildren.get(i); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1428 | AppWindowToken token = task.getTopVisibleAppToken(); |
| 1429 | if (token == null || !token.hasContentToDisplay()) { |
| 1430 | continue; |
| 1431 | } |
| 1432 | |
| 1433 | /** |
| 1434 | * Exclusion region is the region that TapDetector doesn't care about. |
| 1435 | * Here we want to remove all non-focused tasks from the exclusion region. |
| 1436 | * We also remove the outside touch area for resizing for all freeform |
| 1437 | * tasks (including the focused). |
| 1438 | * |
| 1439 | * We save the focused task region once we find it, and add it back at the end. |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 1440 | * |
| 1441 | * If the task is home stack and it is resizable in the minimized state, we want to |
| 1442 | * exclude the docked stack from touch so we need the entire screen area and not just a |
| 1443 | * small portion which the home stack currently is resized to. |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1444 | */ |
| 1445 | |
Matthew Ng | e15352e | 2016-12-20 15:36:29 -0800 | [diff] [blame] | 1446 | if (task.isHomeTask() && isMinimizedDockAndHomeStackResizable()) { |
| 1447 | mDisplayContent.getLogicalDisplayRect(mTmpRect); |
| 1448 | } else { |
| 1449 | task.getDimBounds(mTmpRect); |
| 1450 | } |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1451 | |
| 1452 | if (task == focusedTask) { |
| 1453 | // Add the focused task rect back into the exclude region once we are done |
| 1454 | // processing stacks. |
| 1455 | postExclude.set(mTmpRect); |
| 1456 | } |
| 1457 | |
| 1458 | final boolean isFreeformed = task.inFreeformWorkspace(); |
| 1459 | if (task != focusedTask || isFreeformed) { |
| 1460 | if (isFreeformed) { |
| 1461 | // If the task is freeformed, enlarge the area to account for outside |
| 1462 | // touch area for resize. |
| 1463 | mTmpRect.inset(-delta, -delta); |
| 1464 | // Intersect with display content rect. If we have system decor (status bar/ |
| 1465 | // navigation bar), we want to exclude that from the tap detection. |
| 1466 | // Otherwise, if the app is partially placed under some system button (eg. |
| 1467 | // Recents, Home), pressing that button would cause a full series of |
| 1468 | // unwanted transfer focus/resume/pause, before we could go home. |
| 1469 | mTmpRect.intersect(contentRect); |
| 1470 | } |
| 1471 | touchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); |
| 1472 | } |
| 1473 | } |
| 1474 | } |
| 1475 | |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1476 | public boolean setPinnedStackSize(Rect stackBounds, Rect tempTaskBounds) { |
| 1477 | // Hold the lock since this is called from the BoundsAnimator running on the UiThread |
| 1478 | synchronized (mService.mWindowMap) { |
| 1479 | if (mCancelCurrentBoundsAnimation) { |
| 1480 | return false; |
| 1481 | } |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 1482 | } |
| 1483 | |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1484 | try { |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1485 | mService.mActivityManager.resizePinnedStack(stackBounds, tempTaskBounds); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1486 | } catch (RemoteException e) { |
| 1487 | // I don't believe you. |
| 1488 | } |
| 1489 | return true; |
| 1490 | } |
| 1491 | |
Robert Carr | ecc06b3 | 2017-04-18 14:25:10 -0700 | [diff] [blame] | 1492 | void onAllWindowsDrawn() { |
Winson Chung | e7ba686 | 2017-05-24 12:13:33 -0700 | [diff] [blame] | 1493 | if (!mBoundsAnimating && !mBoundsAnimatingRequested) { |
Robert Carr | ecc06b3 | 2017-04-18 14:25:10 -0700 | [diff] [blame] | 1494 | return; |
| 1495 | } |
| 1496 | |
| 1497 | mService.mBoundsAnimationController.onAllWindowsDrawn(); |
| 1498 | } |
| 1499 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1500 | @Override // AnimatesBounds |
Winson Chung | ab76bbc | 2017-08-14 13:33:51 -0700 | [diff] [blame] | 1501 | public void onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate) { |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1502 | // Hold the lock since this is called from the BoundsAnimator running on the UiThread |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1503 | synchronized (mService.mWindowMap) { |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 1504 | mBoundsAnimatingRequested = false; |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1505 | mBoundsAnimating = true; |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 1506 | mCancelCurrentBoundsAnimation = false; |
Robert Carr | ecc06b3 | 2017-04-18 14:25:10 -0700 | [diff] [blame] | 1507 | |
| 1508 | // If we are changing UI mode, as in the PiP to fullscreen |
| 1509 | // transition, then we need to wait for the window to draw. |
| 1510 | if (schedulePipModeChangedCallback) { |
| 1511 | forAllWindows((w) -> { w.mWinAnimator.resetDrawState(); }, |
| 1512 | false /* traverseTopToBottom */); |
| 1513 | } |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1514 | } |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 1515 | |
| 1516 | if (mStackId == PINNED_STACK_ID) { |
| 1517 | try { |
| 1518 | mService.mActivityManager.notifyPinnedStackAnimationStarted(); |
| 1519 | } catch (RemoteException e) { |
| 1520 | // I don't believe you... |
| 1521 | } |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1522 | |
| 1523 | final PinnedStackWindowController controller = |
| 1524 | (PinnedStackWindowController) getController(); |
| 1525 | if (schedulePipModeChangedCallback && controller != null) { |
Winson Chung | ab76bbc | 2017-08-14 13:33:51 -0700 | [diff] [blame] | 1526 | // We need to schedule the PiP mode change before the animation up. It is possible |
| 1527 | // in this case for the animation down to not have been completed, so always |
| 1528 | // force-schedule and update to the client to ensure that it is notified that it |
| 1529 | // is no longer in picture-in-picture mode |
| 1530 | controller.updatePictureInPictureModeForPinnedStackAnimation(null, forceUpdate); |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1531 | } |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 1532 | } |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | @Override // AnimatesBounds |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1536 | public void onAnimationEnd(boolean schedulePipModeChangedCallback, Rect finalStackSize, |
| 1537 | boolean moveToFullscreen) { |
| 1538 | // Hold the lock since this is called from the BoundsAnimator running on the UiThread |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1539 | synchronized (mService.mWindowMap) { |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1540 | mBoundsAnimating = false; |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 1541 | for (int i = 0; i < mChildren.size(); i++) { |
| 1542 | final Task t = mChildren.get(i); |
| 1543 | t.clearPreserveNonFloatingState(); |
| 1544 | } |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 1545 | mService.requestTraversal(); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1546 | } |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 1547 | |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 1548 | if (mStackId == PINNED_STACK_ID) { |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 1549 | // Update to the final bounds if requested. This is done here instead of in the bounds |
| 1550 | // animator to allow us to coordinate this after we notify the PiP mode changed |
| 1551 | |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1552 | final PinnedStackWindowController controller = |
| 1553 | (PinnedStackWindowController) getController(); |
| 1554 | if (schedulePipModeChangedCallback && controller != null) { |
| 1555 | // We need to schedule the PiP mode change after the animation down, so use the |
| 1556 | // final bounds |
| 1557 | controller.updatePictureInPictureModeForPinnedStackAnimation( |
Winson Chung | ab76bbc | 2017-08-14 13:33:51 -0700 | [diff] [blame] | 1558 | mBoundsAnimationTarget, false /* forceUpdate */); |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1559 | } |
| 1560 | |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1561 | if (finalStackSize != null) { |
| 1562 | setPinnedStackSize(finalStackSize, null); |
| 1563 | } |
| 1564 | |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 1565 | try { |
| 1566 | mService.mActivityManager.notifyPinnedStackAnimationEnded(); |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1567 | if (moveToFullscreen) { |
| 1568 | mService.mActivityManager.moveTasksToFullscreenStack(mStackId, |
| 1569 | true /* onTop */); |
| 1570 | } |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 1571 | } catch (RemoteException e) { |
| 1572 | // I don't believe you... |
| 1573 | } |
| 1574 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1575 | } |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 1576 | |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1577 | /** |
| 1578 | * @return True if we are currently animating the pinned stack from fullscreen to non-fullscreen |
| 1579 | * bounds and we have a deferred PiP mode changed callback set with the animation. |
| 1580 | */ |
| 1581 | public boolean deferScheduleMultiWindowModeChanged() { |
| 1582 | if (mStackId == PINNED_STACK_ID) { |
| 1583 | return (mBoundsAnimatingRequested || mBoundsAnimating); |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 1584 | } |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1585 | return false; |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 1586 | } |
| 1587 | |
Robert Carr | c729460 | 2016-05-13 11:32:05 -0700 | [diff] [blame] | 1588 | public boolean hasMovementAnimations() { |
| 1589 | return StackId.hasMovementAnimations(mStackId); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1590 | } |
| 1591 | |
Robert Carr | 8f0a3ad | 2017-02-15 19:30:28 -0800 | [diff] [blame] | 1592 | public boolean isForceScaled() { |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1593 | return mBoundsAnimating; |
| 1594 | } |
| 1595 | |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 1596 | public boolean isAnimatingBounds() { |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1597 | return mBoundsAnimating; |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 1598 | } |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 1599 | |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 1600 | public boolean lastAnimatingBoundsWasToFullscreen() { |
| 1601 | return mBoundsAnimatingToFullscreen; |
| 1602 | } |
| 1603 | |
Winson Chung | 40a5f93 | 2017-04-13 16:39:36 -0700 | [diff] [blame] | 1604 | public boolean isAnimatingBoundsToFullscreen() { |
Robert Carr | 18f622f | 2017-05-08 11:20:43 -0700 | [diff] [blame] | 1605 | return isAnimatingBounds() && lastAnimatingBoundsWasToFullscreen(); |
Robert Carr | 7e4c90e | 2017-02-15 19:52:38 -0800 | [diff] [blame] | 1606 | } |
| 1607 | |
Winson Chung | 8bca9e4 | 2017-04-16 15:59:43 -0700 | [diff] [blame] | 1608 | public boolean pinnedStackResizeDisallowed() { |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 1609 | if (mBoundsAnimating && mCancelCurrentBoundsAnimation) { |
| 1610 | return true; |
| 1611 | } |
| 1612 | return false; |
| 1613 | } |
| 1614 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1615 | /** Returns true if a removal action is still being deferred. */ |
| 1616 | boolean checkCompleteDeferredRemoval() { |
| 1617 | if (isAnimating()) { |
| 1618 | return true; |
| 1619 | } |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1620 | if (mDeferRemoval) { |
| 1621 | removeImmediately(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1622 | } |
| 1623 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1624 | return super.checkCompleteDeferredRemoval(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1625 | } |
| 1626 | |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1627 | void stepAppWindowsAnimation(long currentTime) { |
| 1628 | super.stepAppWindowsAnimation(currentTime); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1629 | |
| 1630 | // TODO: Why aren't we just using the loop above for this? mAppAnimator.animating isn't set |
| 1631 | // below but is set in the loop above. See if it really matters... |
Wale Ogunwale | 48458e1 | 2017-06-06 10:07:58 -0700 | [diff] [blame] | 1632 | |
| 1633 | // Clear before using. |
| 1634 | mTmpAppTokens.clear(); |
| 1635 | // We copy the list as things can be removed from the exiting token list while we are |
| 1636 | // processing. |
| 1637 | mTmpAppTokens.addAll(mExitingAppTokens); |
| 1638 | for (int i = 0; i < mTmpAppTokens.size(); i++) { |
| 1639 | final AppWindowAnimator appAnimator = mTmpAppTokens.get(i).mAppAnimator; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1640 | appAnimator.wasAnimating = appAnimator.animating; |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1641 | if (appAnimator.stepAnimationLocked(currentTime)) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1642 | mService.mAnimator.setAnimating(true); |
| 1643 | mService.mAnimator.mAppWindowAnimating = true; |
| 1644 | } else if (appAnimator.wasAnimating) { |
| 1645 | // stopped animating, do one more pass through the layout |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1646 | appAnimator.mAppToken.setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER, |
| 1647 | "exiting appToken " + appAnimator.mAppToken + " done"); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1648 | if (DEBUG_ANIM) Slog.v(TAG_WM, |
| 1649 | "updateWindowsApps...: done animating exiting " + appAnimator.mAppToken); |
| 1650 | } |
| 1651 | } |
Wale Ogunwale | 48458e1 | 2017-06-06 10:07:58 -0700 | [diff] [blame] | 1652 | // Clear to avoid holding reference to tokens. |
| 1653 | mTmpAppTokens.clear(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1654 | } |
| 1655 | |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1656 | @Override |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1657 | int getOrientation() { |
Wale Ogunwale | 14a3fb9 | 2016-09-11 15:19:05 -0700 | [diff] [blame] | 1658 | return (StackId.canSpecifyOrientation(mStackId)) |
| 1659 | ? super.getOrientation() : SCREEN_ORIENTATION_UNSET; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1660 | } |
Wale Ogunwale | ecbcadd | 2016-02-21 14:18:51 -0800 | [diff] [blame] | 1661 | } |