Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Andrii Kulian | 1893a61 | 2017-05-04 14:45:09 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId.PINNED_STACK_ID; |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 20 | |
| 21 | import android.app.ActivityManager.StackId; |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 22 | import android.app.WindowConfiguration; |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 23 | import android.content.res.Configuration; |
| 24 | import android.graphics.Rect; |
| 25 | import android.os.Handler; |
| 26 | import android.os.Looper; |
| 27 | import android.os.Message; |
| 28 | import android.util.Slog; |
| 29 | import android.util.SparseArray; |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 30 | import android.view.DisplayInfo; |
| 31 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 32 | import com.android.internal.annotations.VisibleForTesting; |
| 33 | |
| 34 | import java.lang.ref.WeakReference; |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 35 | |
| 36 | import static com.android.server.wm.WindowContainer.POSITION_BOTTOM; |
| 37 | import static com.android.server.wm.WindowContainer.POSITION_TOP; |
| 38 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; |
| 39 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 40 | |
| 41 | /** |
| 42 | * Controller for the stack container. This is created by activity manager to link activity stacks |
| 43 | * to the stack container they use in window manager. |
| 44 | * |
| 45 | * Test class: {@link StackWindowControllerTests} |
| 46 | */ |
| 47 | public class StackWindowController |
| 48 | extends WindowContainerController<TaskStack, StackWindowListener> { |
| 49 | |
| 50 | final int mStackId; |
| 51 | |
| 52 | private final H mHandler; |
| 53 | |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 54 | // Temp bounds only used in adjustConfigurationForBounds() |
| 55 | private final Rect mTmpRect = new Rect(); |
| 56 | private final Rect mTmpStableInsets = new Rect(); |
| 57 | private final Rect mTmpNonDecorInsets = new Rect(); |
| 58 | private final Rect mTmpDisplayBounds = new Rect(); |
| 59 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 60 | public StackWindowController(int stackId, StackWindowListener listener, |
Wale Ogunwale | f75962a | 2017-08-23 14:58:04 -0700 | [diff] [blame^] | 61 | int displayId, boolean onTop, Rect outBounds, Configuration overriderConfig) { |
| 62 | this(stackId, listener, displayId, onTop, outBounds, overriderConfig, |
Wale Ogunwale | 687b427 | 2017-07-27 02:56:23 -0700 | [diff] [blame] | 63 | WindowManagerService.getInstance()); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | @VisibleForTesting |
| 67 | public StackWindowController(int stackId, StackWindowListener listener, |
Wale Ogunwale | f75962a | 2017-08-23 14:58:04 -0700 | [diff] [blame^] | 68 | int displayId, boolean onTop, Rect outBounds, Configuration overrideConfig, |
Wale Ogunwale | 687b427 | 2017-07-27 02:56:23 -0700 | [diff] [blame] | 69 | WindowManagerService service) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 70 | super(listener, service); |
| 71 | mStackId = stackId; |
| 72 | mHandler = new H(new WeakReference<>(this), service.mH.getLooper()); |
| 73 | |
| 74 | synchronized (mWindowMap) { |
| 75 | final DisplayContent dc = mRoot.getDisplayContent(displayId); |
| 76 | if (dc == null) { |
| 77 | throw new IllegalArgumentException("Trying to add stackId=" + stackId |
| 78 | + " to unknown displayId=" + displayId); |
| 79 | } |
| 80 | |
| 81 | final TaskStack stack = dc.addStackToDisplay(stackId, onTop); |
Wale Ogunwale | f75962a | 2017-08-23 14:58:04 -0700 | [diff] [blame^] | 82 | if (overrideConfig != null) { |
| 83 | stack.onOverrideConfigurationChanged(overrideConfig); |
| 84 | } |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 85 | stack.setController(this); |
| 86 | getRawBounds(outBounds); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public void removeContainer() { |
| 92 | synchronized (mWindowMap) { |
| 93 | if (mContainer != null) { |
| 94 | mContainer.removeIfPossible(); |
| 95 | super.removeContainer(); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
Wale Ogunwale | cd501ec | 2017-04-07 08:53:41 -0700 | [diff] [blame] | 100 | public boolean isVisible() { |
| 101 | synchronized (mWindowMap) { |
| 102 | return mContainer != null && mContainer.isVisible(); |
| 103 | } |
| 104 | } |
| 105 | |
Andrii Kulian | 51c1b67 | 2017-04-07 18:39:32 -0700 | [diff] [blame] | 106 | public void reparent(int displayId, Rect outStackBounds, boolean onTop) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 107 | synchronized (mWindowMap) { |
| 108 | if (mContainer == null) { |
| 109 | throw new IllegalArgumentException("Trying to move unknown stackId=" + mStackId |
| 110 | + " to displayId=" + displayId); |
| 111 | } |
| 112 | |
| 113 | final DisplayContent targetDc = mRoot.getDisplayContent(displayId); |
| 114 | if (targetDc == null) { |
| 115 | throw new IllegalArgumentException("Trying to move stackId=" + mStackId |
| 116 | + " to unknown displayId=" + displayId); |
| 117 | } |
| 118 | |
Andrii Kulian | 51c1b67 | 2017-04-07 18:39:32 -0700 | [diff] [blame] | 119 | targetDc.moveStackToDisplay(mContainer, onTop); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 120 | getRawBounds(outStackBounds); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | public void positionChildAt(TaskWindowContainerController child, int position, Rect bounds, |
| 125 | Configuration overrideConfig) { |
| 126 | synchronized (mWindowMap) { |
| 127 | if (DEBUG_STACK) Slog.i(TAG_WM, "positionChildAt: positioning task=" + child |
| 128 | + " at " + position); |
| 129 | if (child.mContainer == null) { |
| 130 | if (DEBUG_STACK) Slog.i(TAG_WM, |
| 131 | "positionChildAt: could not find task=" + this); |
| 132 | return; |
| 133 | } |
| 134 | if (mContainer == null) { |
| 135 | if (DEBUG_STACK) Slog.i(TAG_WM, |
| 136 | "positionChildAt: could not find stack for task=" + mContainer); |
| 137 | return; |
| 138 | } |
| 139 | child.mContainer.positionAt(position, bounds, overrideConfig); |
| 140 | mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | public void positionChildAtTop(TaskWindowContainerController child, boolean includingParents) { |
| 145 | if (child == null) { |
| 146 | // TODO: Fix the call-points that cause this to happen. |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | synchronized(mWindowMap) { |
| 151 | final Task childTask = child.mContainer; |
| 152 | if (childTask == null) { |
| 153 | Slog.e(TAG_WM, "positionChildAtTop: task=" + child + " not found"); |
| 154 | return; |
| 155 | } |
| 156 | mContainer.positionChildAt(POSITION_TOP, childTask, includingParents); |
| 157 | |
| 158 | if (mService.mAppTransition.isTransitionSet()) { |
| 159 | childTask.setSendingToBottom(false); |
| 160 | } |
| 161 | mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded(); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | public void positionChildAtBottom(TaskWindowContainerController child) { |
| 166 | if (child == null) { |
| 167 | // TODO: Fix the call-points that cause this to happen. |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | synchronized(mWindowMap) { |
| 172 | final Task childTask = child.mContainer; |
| 173 | if (childTask == null) { |
| 174 | Slog.e(TAG_WM, "positionChildAtBottom: task=" + child + " not found"); |
| 175 | return; |
| 176 | } |
| 177 | mContainer.positionChildAt(POSITION_BOTTOM, childTask, false /* includingParents */); |
| 178 | |
| 179 | if (mService.mAppTransition.isTransitionSet()) { |
| 180 | childTask.setSendingToBottom(true); |
| 181 | } |
| 182 | mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded(); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Re-sizes a stack and its containing tasks. |
| 188 | * |
| 189 | * @param bounds New stack bounds. Passing in null sets the bounds to fullscreen. |
| 190 | * @param configs Configurations for tasks in the resized stack, keyed by task id. |
| 191 | * @param taskBounds Bounds for tasks in the resized stack, keyed by task id. |
| 192 | * @return True if the stack is now fullscreen. |
| 193 | */ |
| 194 | public boolean resize(Rect bounds, SparseArray<Configuration> configs, |
| 195 | SparseArray<Rect> taskBounds, SparseArray<Rect> taskTempInsetBounds) { |
| 196 | synchronized (mWindowMap) { |
| 197 | if (mContainer == null) { |
| 198 | throw new IllegalArgumentException("resizeStack: stack " + this + " not found."); |
| 199 | } |
| 200 | // We might trigger a configuration change. Save the current task bounds for freezing. |
| 201 | mContainer.prepareFreezingTaskBounds(); |
| 202 | if (mContainer.setBounds(bounds, configs, taskBounds, taskTempInsetBounds) |
| 203 | && mContainer.isVisible()) { |
| 204 | mContainer.getDisplayContent().setLayoutNeeded(); |
| 205 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 206 | } |
| 207 | return mContainer.getRawFullscreen(); |
| 208 | } |
| 209 | } |
| 210 | |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 211 | /** |
| 212 | * @see TaskStack.getStackDockedModeBoundsLocked(Rect, Rect, Rect, boolean) |
| 213 | */ |
| 214 | public void getStackDockedModeBounds(Rect currentTempTaskBounds, Rect outStackBounds, |
| 215 | Rect outTempTaskBounds, boolean ignoreVisibility) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 216 | synchronized (mWindowMap) { |
| 217 | if (mContainer != null) { |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 218 | mContainer.getStackDockedModeBoundsLocked(currentTempTaskBounds, outStackBounds, |
| 219 | outTempTaskBounds, ignoreVisibility); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 220 | return; |
| 221 | } |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 222 | outStackBounds.setEmpty(); |
| 223 | outTempTaskBounds.setEmpty(); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | public void prepareFreezingTaskBounds() { |
| 228 | synchronized (mWindowMap) { |
| 229 | if (mContainer == null) { |
| 230 | throw new IllegalArgumentException("prepareFreezingTaskBounds: stack " + this |
| 231 | + " not found."); |
| 232 | } |
| 233 | mContainer.prepareFreezingTaskBounds(); |
| 234 | } |
| 235 | } |
| 236 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 237 | private void getRawBounds(Rect outBounds) { |
| 238 | if (mContainer.getRawFullscreen()) { |
| 239 | outBounds.setEmpty(); |
| 240 | } else { |
| 241 | mContainer.getRawBounds(outBounds); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | public void getBounds(Rect outBounds) { |
| 246 | synchronized (mWindowMap) { |
| 247 | if (mContainer != null) { |
| 248 | mContainer.getBounds(outBounds); |
| 249 | return; |
| 250 | } |
| 251 | outBounds.setEmpty(); |
| 252 | } |
| 253 | } |
| 254 | |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 255 | public void getBoundsForNewConfiguration(Rect outBounds) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 256 | synchronized(mWindowMap) { |
Matthew Ng | aa2b620 | 2017-02-10 14:48:21 -0800 | [diff] [blame] | 257 | mContainer.getBoundsForNewConfiguration(outBounds); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 261 | /** |
| 262 | * Adjusts the screen size in dp's for the {@param config} for the given params. |
| 263 | */ |
| 264 | public void adjustConfigurationForBounds(Rect bounds, Rect insetBounds, |
| 265 | Rect nonDecorBounds, Rect stableBounds, boolean overrideWidth, |
| 266 | boolean overrideHeight, float density, Configuration config, |
| 267 | Configuration parentConfig) { |
| 268 | synchronized (mWindowMap) { |
| 269 | final TaskStack stack = mContainer; |
| 270 | final DisplayContent displayContent = stack.getDisplayContent(); |
| 271 | final DisplayInfo di = displayContent.getDisplayInfo(); |
| 272 | |
| 273 | // Get the insets and display bounds |
| 274 | mService.mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, |
| 275 | mTmpStableInsets); |
| 276 | mService.mPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, |
| 277 | mTmpNonDecorInsets); |
| 278 | mTmpDisplayBounds.set(0, 0, di.logicalWidth, di.logicalHeight); |
| 279 | |
| 280 | int width; |
| 281 | int height; |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 282 | |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 283 | final Rect parentAppBounds = parentConfig.windowConfiguration.getAppBounds(); |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 284 | |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 285 | config.windowConfiguration.setAppBounds(!bounds.isEmpty() ? bounds : null); |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 286 | boolean intersectParentBounds = false; |
| 287 | |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 288 | if (stack.getWindowConfiguration().tasksAreFloating()) { |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 289 | // Floating tasks should not be resized to the screen's bounds. |
| 290 | |
Andrii Kulian | 1893a61 | 2017-05-04 14:45:09 -0700 | [diff] [blame] | 291 | if (mStackId == PINNED_STACK_ID && bounds.width() == mTmpDisplayBounds.width() && |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 292 | bounds.height() == mTmpDisplayBounds.height()) { |
| 293 | // If the bounds we are animating is the same as the fullscreen stack |
| 294 | // dimensions, then apply the same inset calculations that we normally do for |
| 295 | // the fullscreen stack, without intersecting it with the display bounds |
| 296 | stableBounds.inset(mTmpStableInsets); |
| 297 | nonDecorBounds.inset(mTmpNonDecorInsets); |
Andrii Kulian | 1893a61 | 2017-05-04 14:45:09 -0700 | [diff] [blame] | 298 | // Move app bounds to zero to apply intersection with parent correctly. They are |
| 299 | // used only for evaluating width and height, so it's OK to move them around. |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 300 | config.windowConfiguration.getAppBounds().offsetTo(0, 0); |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 301 | intersectParentBounds = true; |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 302 | } |
| 303 | width = (int) (stableBounds.width() / density); |
| 304 | height = (int) (stableBounds.height() / density); |
| 305 | } else { |
| 306 | // For calculating screenWidthDp, screenWidthDp, we use the stable inset screen |
| 307 | // area, i.e. the screen area without the system bars. |
| 308 | // Additionally task dimensions should not be bigger than its parents dimensions. |
| 309 | // The non decor inset are areas that could never be removed in Honeycomb. See |
| 310 | // {@link WindowManagerPolicy#getNonDecorInsetsLw}. |
| 311 | intersectDisplayBoundsExcludeInsets(nonDecorBounds, |
| 312 | insetBounds != null ? insetBounds : bounds, mTmpNonDecorInsets, |
| 313 | mTmpDisplayBounds, overrideWidth, overrideHeight); |
| 314 | intersectDisplayBoundsExcludeInsets(stableBounds, |
| 315 | insetBounds != null ? insetBounds : bounds, mTmpStableInsets, |
| 316 | mTmpDisplayBounds, overrideWidth, overrideHeight); |
| 317 | width = Math.min((int) (stableBounds.width() / density), |
| 318 | parentConfig.screenWidthDp); |
| 319 | height = Math.min((int) (stableBounds.height() / density), |
| 320 | parentConfig.screenHeightDp); |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 321 | intersectParentBounds = true; |
| 322 | } |
| 323 | |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 324 | if (intersectParentBounds && config.windowConfiguration.getAppBounds() != null) { |
| 325 | config.windowConfiguration.getAppBounds().intersect(parentAppBounds); |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | config.screenWidthDp = width; |
| 329 | config.screenHeightDp = height; |
| 330 | config.smallestScreenWidthDp = getSmallestWidthForTaskBounds( |
| 331 | insetBounds != null ? insetBounds : bounds, density); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable |
| 337 | * inset areas. |
| 338 | * |
| 339 | * @param inOutBounds The inOutBounds to subtract the stable inset areas from. |
| 340 | */ |
| 341 | private void intersectDisplayBoundsExcludeInsets(Rect inOutBounds, Rect inInsetBounds, |
| 342 | Rect stableInsets, Rect displayBounds, boolean overrideWidth, boolean overrideHeight) { |
| 343 | mTmpRect.set(inInsetBounds); |
| 344 | mService.intersectDisplayInsetBounds(displayBounds, stableInsets, mTmpRect); |
| 345 | int leftInset = mTmpRect.left - inInsetBounds.left; |
| 346 | int topInset = mTmpRect.top - inInsetBounds.top; |
| 347 | int rightInset = overrideWidth ? 0 : inInsetBounds.right - mTmpRect.right; |
| 348 | int bottomInset = overrideHeight ? 0 : inInsetBounds.bottom - mTmpRect.bottom; |
| 349 | inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Calculates the smallest width for a task given the {@param bounds}. |
| 354 | * |
| 355 | * @return the smallest width to be used in the Configuration, in dips |
| 356 | */ |
| 357 | private int getSmallestWidthForTaskBounds(Rect bounds, float density) { |
| 358 | final DisplayContent displayContent = mContainer.getDisplayContent(); |
| 359 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 360 | |
| 361 | if (bounds == null || (bounds.width() == displayInfo.logicalWidth && |
| 362 | bounds.height() == displayInfo.logicalHeight)) { |
| 363 | // If the bounds are fullscreen, return the value of the fullscreen configuration |
| 364 | return displayContent.getConfiguration().smallestScreenWidthDp; |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 365 | } else if (mContainer.getWindowConfiguration().tasksAreFloating()) { |
Winson Chung | bdc646f | 2017-02-13 12:12:22 -0800 | [diff] [blame] | 366 | // For floating tasks, calculate the smallest width from the bounds of the task |
| 367 | return (int) (Math.min(bounds.width(), bounds.height()) / density); |
| 368 | } else { |
| 369 | // Iterating across all screen orientations, and return the minimum of the task |
| 370 | // width taking into account that the bounds might change because the snap algorithm |
| 371 | // snaps to a different value |
| 372 | return displayContent.getDockedDividerController() |
| 373 | .getSmallestWidthDpForBounds(bounds); |
| 374 | } |
| 375 | } |
| 376 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 377 | void requestResize(Rect bounds) { |
| 378 | mHandler.obtainMessage(H.REQUEST_RESIZE, bounds).sendToTarget(); |
| 379 | } |
| 380 | |
| 381 | @Override |
| 382 | public String toString() { |
| 383 | return "{StackWindowController stackId=" + mStackId + "}"; |
| 384 | } |
| 385 | |
| 386 | private static final class H extends Handler { |
| 387 | |
| 388 | static final int REQUEST_RESIZE = 0; |
| 389 | |
| 390 | private final WeakReference<StackWindowController> mController; |
| 391 | |
| 392 | H(WeakReference<StackWindowController> controller, Looper looper) { |
| 393 | super(looper); |
| 394 | mController = controller; |
| 395 | } |
| 396 | |
| 397 | @Override |
| 398 | public void handleMessage(Message msg) { |
| 399 | final StackWindowController controller = mController.get(); |
| 400 | final StackWindowListener listener = (controller != null) |
| 401 | ? controller.mListener : null; |
| 402 | if (listener == null) { |
| 403 | return; |
| 404 | } |
| 405 | switch (msg.what) { |
| 406 | case REQUEST_RESIZE: |
| 407 | listener.requestResize((Rect) msg.obj); |
| 408 | break; |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | } |