blob: 983ab2eedf5ce5d8eb4ea8ab644f124d7a3063ed [file] [log] [blame]
Winson Chunge2d72172018-01-25 17:46:20 +00001/*
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
17package android.view;
18
19import android.app.ActivityManager;
20import android.view.IRemoteAnimationFinishedCallback;
21import 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 */
30interface 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 Oneaf4fb6fb2019-02-27 14:46:52 +000036 @UnsupportedAppUsage
Winson Chunge2d72172018-01-25 17:46:20 +000037 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 Zhou9c675d42019-04-08 00:32:40 -070044 * @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the
45 * top resumed app, false otherwise.
Winson Chunge2d72172018-01-25 17:46:20 +000046 */
Andrei Oneaf4fb6fb2019-02-27 14:46:52 +000047 @UnsupportedAppUsage
Tracy Zhou9c675d42019-04-08 00:32:40 -070048 void finish(boolean moveHomeToTop, boolean sendUserLeaveHint);
Winson Chunge2d72172018-01-25 17:46:20 +000049
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 Oneaf4fb6fb2019-02-27 14:46:52 +000057 @UnsupportedAppUsage
Winson Chunge2d72172018-01-25 17:46:20 +000058 void setInputConsumerEnabled(boolean enabled);
Jorim Jaggi50bf59c2018-03-09 17:29:48 +010059
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 Oneaf4fb6fb2019-02-27 14:46:52 +000066 @UnsupportedAppUsage
Jorim Jaggi50bf59c2018-03-09 17:29:48 +010067 void setAnimationTargetsBehindSystemBars(boolean behindSystemBars);
Winson Chungf557c3b2018-03-16 10:55:20 -070068
69 /**
Winson Chunga840c322018-04-20 15:58:18 -070070 * Hides the current input method if one is showing.
71 */
72 void hideCurrentInputMethod();
lumark54284462019-03-05 20:44:27 +080073
74 /**
lumark54284462019-03-05 20:44:27 +080075 * 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 Chung7a545ae2019-07-16 14:52:13 -070081
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 Zhou9e0354f2019-10-03 18:05:03 -0700111
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);
lumark04bceb92020-03-07 00:03:33 +0800117
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 Chunge2d72172018-01-25 17:46:20 +0000129}