Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 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.graphics.GraphicBuffer; |
| 22 | |
| 23 | /** |
| 24 | * Passed to the {@link IRecentsAnimationRunner} in order for the runner to control to let the |
| 25 | * runner control certain aspects of the recents animation, and to notify window manager when the |
| 26 | * animation has completed. |
| 27 | * |
| 28 | * {@hide} |
| 29 | */ |
| 30 | interface IRecentsAnimationController { |
| 31 | |
| 32 | /** |
| 33 | * Takes a screenshot of the task associated with the given {@param taskId}. Only valid for the |
| 34 | * current set of task ids provided to the handler. |
| 35 | */ |
Andrei Onea | f4fb6fb | 2019-02-27 14:46:52 +0000 | [diff] [blame] | 36 | @UnsupportedAppUsage |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 37 | ActivityManager.TaskSnapshot screenshotTask(int taskId); |
| 38 | |
| 39 | /** |
| 40 | * Notifies to the system that the animation into Recents should end, and all leashes associated |
| 41 | * with remote animation targets should be relinquished. If {@param moveHomeToTop} is true, then |
| 42 | * the home activity should be moved to the top. Otherwise, the home activity is hidden and the |
| 43 | * user is returned to the app. |
Tracy Zhou | 9c675d4 | 2019-04-08 00:32:40 -0700 | [diff] [blame] | 44 | * @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the |
| 45 | * top resumed app, false otherwise. |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 46 | */ |
Andrei Onea | f4fb6fb | 2019-02-27 14:46:52 +0000 | [diff] [blame] | 47 | @UnsupportedAppUsage |
Tracy Zhou | 9c675d4 | 2019-04-08 00:32:40 -0700 | [diff] [blame] | 48 | void finish(boolean moveHomeToTop, boolean sendUserLeaveHint); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Called by the handler to indicate that the recents animation input consumer should be |
| 52 | * enabled. This is currently used to work around an issue where registering an input consumer |
| 53 | * mid-animation causes the existing motion event chain to be canceled. Instead, the caller |
| 54 | * may register the recents animation input consumer prior to starting the recents animation |
| 55 | * and then enable it mid-animation to start receiving touch events. |
| 56 | */ |
Andrei Onea | f4fb6fb | 2019-02-27 14:46:52 +0000 | [diff] [blame] | 57 | @UnsupportedAppUsage |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 58 | void setInputConsumerEnabled(boolean enabled); |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Informs the system whether the animation targets passed into |
| 62 | * IRecentsAnimationRunner.onAnimationStart are currently behind the system bars. If they are, |
| 63 | * they can control the SystemUI flags, otherwise the SystemUI flags from home activity will be |
| 64 | * taken. |
| 65 | */ |
Andrei Onea | f4fb6fb | 2019-02-27 14:46:52 +0000 | [diff] [blame] | 66 | @UnsupportedAppUsage |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame] | 67 | void setAnimationTargetsBehindSystemBars(boolean behindSystemBars); |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
Winson Chung | a840c32 | 2018-04-20 15:58:18 -0700 | [diff] [blame] | 70 | * Hides the current input method if one is showing. |
| 71 | */ |
| 72 | void hideCurrentInputMethod(); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 73 | |
| 74 | /** |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 75 | * Clean up the screenshot of previous task which was created during recents animation that |
| 76 | * was cancelled by a stack order change. |
| 77 | * |
| 78 | * @see {@link IRecentsAnimationRunner#onAnimationCanceled} |
| 79 | */ |
| 80 | void cleanupScreenshot(); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Set a state for controller whether would like to cancel recents animations with deferred |
| 84 | * task screenshot presentation. |
| 85 | * |
| 86 | * When we cancel the recents animation due to a stack order change, we can't just cancel it |
| 87 | * immediately as it would lead to a flicker in Launcher if we just remove the task from the |
| 88 | * leash. Instead we screenshot the previous task and replace the child of the leash with the |
| 89 | * screenshot, so that Launcher can still control the leash lifecycle & make the next app |
| 90 | * transition animate smoothly without flickering. |
| 91 | * |
| 92 | * @param defer When set {@code true}, means that the recents animation will defer canceling the |
| 93 | * animation when a stack order change is triggered until the subsequent app |
| 94 | * transition start and skip previous task's animation. |
| 95 | * When set to {@code false}, means that the recents animation will be canceled |
| 96 | * immediately when the stack order changes. |
| 97 | * @param screenshot When set {@code true}, means that the system will take previous task's |
| 98 | * screenshot and replace the contents of the leash with it when the next app |
| 99 | * transition starting. The runner must call #cleanupScreenshot() to end the |
| 100 | * recents animation. |
| 101 | * When set to {@code false}, means that the system will simply wait for the |
| 102 | * next app transition start to immediately cancel the recents animation. This |
| 103 | * can be useful when you want an immediate transition into a state where the |
| 104 | * task is shown in the home/recents activity (without waiting for a |
| 105 | * screenshot). |
| 106 | * |
| 107 | * @see #cleanupScreenshot() |
| 108 | * @see IRecentsAnimationRunner#onCancelled |
| 109 | */ |
| 110 | void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot); |
Tracy Zhou | 9e0354f | 2019-10-03 18:05:03 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Sets a state for controller to decide which surface is the destination when the recents |
| 114 | * animation is cancelled through fail safe mechanism. |
| 115 | */ |
| 116 | void setWillFinishToHome(boolean willFinishToHome); |
lumark | 04bceb9 | 2020-03-07 00:03:33 +0800 | [diff] [blame^] | 117 | |
| 118 | /** |
| 119 | * Stops controlling a task that is currently controlled by this recents animation. |
| 120 | * |
| 121 | * This method should be called when a task that has been received via {@link #onAnimationStart} |
| 122 | * or {@link #onTaskAppeared} is no longer needed. After calling this method, the task will |
| 123 | * either disappear from the screen, or jump to its final position in case it was the top task. |
| 124 | * |
| 125 | * @param taskId Id of the Task target to remove |
| 126 | * @return {@code true} when target removed successfully, {@code false} otherwise. |
| 127 | */ |
| 128 | boolean removeTask(int taskId); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 129 | } |