| 1 |
/* |
| 2 |
* Copyright (C) 2018 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 android.view; |
| 18 |
|
| 19 |
import android.app.ActivityManager; |
| 20 |
import android.view.IRemoteAnimationFinishedCallback; |
| 21 |
import android.view.SurfaceControl; |
| 22 |
import android.graphics.GraphicBuffer; |
| 23 |
import android.window.PictureInPictureSurfaceTransaction; |
| 24 |
import android.window.TaskSnapshot; |
| 25 |
|
| 26 |
/** |
| 27 |
* Passed to the {@link IRecentsAnimationRunner} in order for the runner to control to let the |
| 28 |
* runner control certain aspects of the recents animation, and to notify window manager when the |
| 29 |
* animation has completed. |
| 30 |
* |
| 31 |
* {@hide} |
| 32 |
*/ |
| 33 |
interface IRecentsAnimationController { |
| 34 |
|
| 35 |
/** |
| 36 |
* Takes a screenshot of the task associated with the given {@param taskId}. Only valid for the |
| 37 |
* current set of task ids provided to the handler. |
| 38 |
*/ |
| 39 |
TaskSnapshot screenshotTask(int taskId); |
| 40 |
|
| 41 |
/** |
| 42 |
* Sets the final surface transaction on a Task. This is used by Launcher to notify the system |
| 43 |
* that animating Activity to PiP has completed and the associated task surface should be |
| 44 |
* updated accordingly. This should be called before `finish` |
| 45 |
* @param taskId for which the leash should be updated |
| 46 |
* @param finishTransaction leash operations for the final transform. |
| 47 |
* @param overlay the surface control for an overlay being shown above the pip (can be null) |
| 48 |
*/ |
| 49 |
void setFinishTaskTransaction(int taskId, |
| 50 |
in PictureInPictureSurfaceTransaction finishTransaction, in SurfaceControl overlay); |
| 51 |
|
| 52 |
/** |
| 53 |
* Notifies to the system that the animation into Recents should end, and all leashes associated |
| 54 |
* with remote animation targets should be relinquished. If {@param moveHomeToTop} is true, then |
| 55 |
* the home activity should be moved to the top. Otherwise, the home activity is hidden and the |
| 56 |
* user is returned to the app. |
| 57 |
* @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the |
| 58 |
* top resumed app, false otherwise. |
| 59 |
*/ |
| 60 |
@UnsupportedAppUsage |
| 61 |
void finish(boolean moveHomeToTop, boolean sendUserLeaveHint); |
| 62 |
|
| 63 |
/** |
| 64 |
* Called by the handler to indicate that the recents animation input consumer should be |
| 65 |
* enabled. This is currently used to work around an issue where registering an input consumer |
| 66 |
* mid-animation causes the existing motion event chain to be canceled. Instead, the caller |
| 67 |
* may register the recents animation input consumer prior to starting the recents animation |
| 68 |
* and then enable it mid-animation to start receiving touch events. |
| 69 |
*/ |
| 70 |
@UnsupportedAppUsage |
| 71 |
void setInputConsumerEnabled(boolean enabled); |
| 72 |
|
| 73 |
/** |
| 74 |
* Informs the system whether the animation targets passed into |
| 75 |
* IRecentsAnimationRunner.onAnimationStart are currently behind the system bars. If they are, |
| 76 |
* they can control the SystemUI flags, otherwise the SystemUI flags from home activity will be |
| 77 |
* taken. |
| 78 |
*/ |
| 79 |
@UnsupportedAppUsage |
| 80 |
void setAnimationTargetsBehindSystemBars(boolean behindSystemBars); |
| 81 |
|
| 82 |
/** |
| 83 |
* Clean up the screenshot of previous task which was created during recents animation that |
| 84 |
* was cancelled by a stack order change. |
| 85 |
* |
| 86 |
* @see {@link IRecentsAnimationRunner#onAnimationCanceled} |
| 87 |
*/ |
| 88 |
void cleanupScreenshot(); |
| 89 |
|
| 90 |
/** |
| 91 |
* Set a state for controller whether would like to cancel recents animations with deferred |
| 92 |
* task screenshot presentation. |
| 93 |
* |
| 94 |
* When we cancel the recents animation due to a stack order change, we can't just cancel it |
| 95 |
* immediately as it would lead to a flicker in Launcher if we just remove the task from the |
| 96 |
* leash. Instead we screenshot the previous task and replace the child of the leash with the |
| 97 |
* screenshot, so that Launcher can still control the leash lifecycle & make the next app |
| 98 |
* transition animate smoothly without flickering. |
| 99 |
* |
| 100 |
* @param defer When set {@code true}, means that the recents animation will defer canceling the |
| 101 |
* animation when a stack order change is triggered until the subsequent app |
| 102 |
* transition start and skip previous task's animation. |
| 103 |
* When set to {@code false}, means that the recents animation will be canceled |
| 104 |
* immediately when the stack order changes. |
| 105 |
* @param screenshot When set {@code true}, means that the system will take previous task's |
| 106 |
* screenshot and replace the contents of the leash with it when the next app |
| 107 |
* transition starting. The runner must call #cleanupScreenshot() to end the |
| 108 |
* recents animation. |
| 109 |
* When set to {@code false}, means that the system will simply wait for the |
| 110 |
* next app transition start to immediately cancel the recents animation. This |
| 111 |
* can be useful when you want an immediate transition into a state where the |
| 112 |
* task is shown in the home/recents activity (without waiting for a |
| 113 |
* screenshot). |
| 114 |
* |
| 115 |
* @see #cleanupScreenshot() |
| 116 |
* @see IRecentsAnimationRunner#onCancelled |
| 117 |
*/ |
| 118 |
void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot); |
| 119 |
|
| 120 |
/** |
| 121 |
* Sets a state for controller to decide which surface is the destination when the recents |
| 122 |
* animation is cancelled through fail safe mechanism. |
| 123 |
*/ |
| 124 |
void setWillFinishToHome(boolean willFinishToHome); |
| 125 |
|
| 126 |
/** |
| 127 |
* Stops controlling a task that is currently controlled by this recents animation. |
| 128 |
* |
| 129 |
* This method should be called when a task that has been received via {@link #onAnimationStart} |
| 130 |
* or {@link #onTaskAppeared} is no longer needed. After calling this method, the task will |
| 131 |
* either disappear from the screen, or jump to its final position in case it was the top task. |
| 132 |
* |
| 133 |
* @param taskId Id of the Task target to remove |
| 134 |
* @return {@code true} when target removed successfully, {@code false} otherwise. |
| 135 |
*/ |
| 136 |
boolean removeTask(int taskId); |
| 137 |
|
| 138 |
/** |
| 139 |
* Detach navigation bar from app. |
| 140 |
* |
| 141 |
* The system reparents the leash of navigation bar to the app when the recents animation starts |
| 142 |
* and Launcher should call this method to let system restore the navigation bar to its |
| 143 |
* original position when the quick switch gesture is finished and will run the fade-in |
| 144 |
* animation If {@param moveHomeToTop} is {@code true}. Otherwise, restore the navigtation bar |
| 145 |
* without animation. |
| 146 |
* |
| 147 |
* @param moveHomeToTop if {@code true}, the home activity should be moved to the top. |
| 148 |
* Otherwise, the home activity is hidden and the user is returned to the |
| 149 |
* app. |
| 150 |
*/ |
| 151 |
void detachNavigationBarFromApp(boolean moveHomeToTop); |
| 152 |
|
| 153 |
/** |
| 154 |
* Used for animating the navigation bar during app launch from recents in live tile mode. |
| 155 |
* |
| 156 |
* First fade out the navigation bar at the bottom of the display and then fade in to the app. |
| 157 |
* |
| 158 |
* @param duration the duration of the app launch animation |
| 159 |
*/ |
| 160 |
void animateNavigationBarToApp(long duration); |
| 161 |
} |