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