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      */
36     @UnsupportedAppUsage
screenshotTask(int taskId)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.
44      * @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the
45      *                          top resumed app, false otherwise.
46      */
47     @UnsupportedAppUsage
finish(boolean moveHomeToTop, boolean sendUserLeaveHint)48     void finish(boolean moveHomeToTop, boolean sendUserLeaveHint);
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      */
57     @UnsupportedAppUsage
setInputConsumerEnabled(boolean enabled)58     void setInputConsumerEnabled(boolean enabled);
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     */
66     @UnsupportedAppUsage
setAnimationTargetsBehindSystemBars(boolean behindSystemBars)67     void setAnimationTargetsBehindSystemBars(boolean behindSystemBars);
68 
69     /**
70      * Informs the system that the primary split-screen stack should be minimized.
71      */
setSplitScreenMinimized(boolean minimized)72     void setSplitScreenMinimized(boolean minimized);
73 
74     /**
75      * Hides the current input method if one is showing.
76      */
hideCurrentInputMethod()77     void hideCurrentInputMethod();
78 
79     /**
80      * This call is deprecated, use #setDeferCancelUntilNextTransition() instead
81      * TODO(138144750): Remove this method once there are no callers
82      * @deprecated
83      */
setCancelWithDeferredScreenshot(boolean screenshot)84     void setCancelWithDeferredScreenshot(boolean screenshot);
85 
86     /**
87      * Clean up the screenshot of previous task which was created during recents animation that
88      * was cancelled by a stack order change.
89      *
90      * @see {@link IRecentsAnimationRunner#onAnimationCanceled}
91      */
cleanupScreenshot()92     void cleanupScreenshot();
93 
94     /**
95      * Set a state for controller whether would like to cancel recents animations with deferred
96      * task screenshot presentation.
97      *
98      * When we cancel the recents animation due to a stack order change, we can't just cancel it
99      * immediately as it would lead to a flicker in Launcher if we just remove the task from the
100      * leash. Instead we screenshot the previous task and replace the child of the leash with the
101      * screenshot, so that Launcher can still control the leash lifecycle & make the next app
102      * transition animate smoothly without flickering.
103      *
104      * @param defer When set {@code true}, means that the recents animation will defer canceling the
105      *              animation when a stack order change is triggered until the subsequent app
106      *              transition start and skip previous task's animation.
107      *              When set to {@code false}, means that the recents animation will be canceled
108      *              immediately when the stack order changes.
109      * @param screenshot When set {@code true}, means that the system will take previous task's
110      *                   screenshot and replace the contents of the leash with it when the next app
111      *                   transition starting. The runner must call #cleanupScreenshot() to end the
112      *                   recents animation.
113      *                   When set to {@code false}, means that the system will simply wait for the
114      *                   next app transition start to immediately cancel the recents animation. This
115      *                   can be useful when you want an immediate transition into a state where the
116      *                   task is shown in the home/recents activity (without waiting for a
117      *                   screenshot).
118      *
119      * @see #cleanupScreenshot()
120      * @see IRecentsAnimationRunner#onCancelled
121      */
setDeferCancelUntilNextTransition(boolean defer, boolean screenshot)122     void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot);
123 }
124