1 /* 2 * Copyright (C) 2017 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 19 import android.graphics.Rect; 20 21 /** 22 * The target for a BoundsAnimation. 23 * @see BoundsAnimationController 24 */ 25 interface BoundsAnimationTarget { 26 27 /** 28 * Callback for the target to inform it that the animation has started, so it can do some 29 * necessary preparation. 30 * 31 * @param schedulePipModeChangedCallback whether or not to schedule the PiP mode changed 32 * callbacks 33 * @return whether to continue the animation 34 */ onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate, @BoundsAnimationController.AnimationType int animationType)35 boolean onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate, 36 @BoundsAnimationController.AnimationType int animationType); 37 38 /** 39 * @return Whether the animation should be paused waiting for the windows to draw before 40 * entering PiP. 41 */ shouldDeferStartOnMoveToFullscreen()42 boolean shouldDeferStartOnMoveToFullscreen(); 43 44 /** 45 * Sets the size of the target (without any intermediate steps, like scheduling animation) 46 * but freezes the bounds of any tasks in the target at taskBounds, to allow for more 47 * flexibility during resizing. Only works for the pinned stack at the moment. This will 48 * only be called between onAnimationStart() and onAnimationEnd(). 49 * 50 * @return Whether the target should continue to be animated and this call was successful. 51 * If false, the animation will be cancelled because the user has determined that the 52 * animation is now invalid and not required. In such a case, the cancel will trigger the 53 * animation end callback as well, but will not send any further size changes. 54 */ setPinnedStackSize(Rect stackBounds, Rect taskBounds)55 boolean setPinnedStackSize(Rect stackBounds, Rect taskBounds); 56 57 /** Sets the alpha of the animation target */ setPinnedStackAlpha(float alpha)58 boolean setPinnedStackAlpha(float alpha); 59 60 /** 61 * Callback for the target to inform it that the animation has ended, so it can do some 62 * necessary cleanup. 63 * 64 * @param schedulePipModeChangedCallback whether or not to schedule the PiP mode changed 65 * callbacks 66 * @param finalStackSize the final stack bounds to set on the target (can be to indicate that 67 * the animation was cancelled and the target does not need to update to the final stack bounds) 68 * @param moveToFullscreen whether or the target should reparent itself to the fullscreen stack 69 * when the animation completes 70 */ onAnimationEnd(boolean schedulePipModeChangedCallback, Rect finalStackSize, boolean moveToFullscreen)71 void onAnimationEnd(boolean schedulePipModeChangedCallback, Rect finalStackSize, 72 boolean moveToFullscreen); 73 74 /** @return True if the target is attached to the window hierarchy. */ isAttached()75 default boolean isAttached() { 76 return true; 77 } 78 } 79