• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      */
screenshotTask(int taskId)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      */
setFinishTaskTransaction(int taskId, in PictureInPictureSurfaceTransaction finishTransaction, in SurfaceControl overlay)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
finish(boolean moveHomeToTop, boolean sendUserLeaveHint)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
setInputConsumerEnabled(boolean enabled)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
setAnimationTargetsBehindSystemBars(boolean behindSystemBars)80     void setAnimationTargetsBehindSystemBars(boolean behindSystemBars);
81 
82     /**
83      * Hides the current input method if one is showing.
84      */
hideCurrentInputMethod()85     void hideCurrentInputMethod();
86 
87     /**
88      * Clean up the screenshot of previous task which was created during recents animation that
89      * was cancelled by a stack order change.
90      *
91      * @see {@link IRecentsAnimationRunner#onAnimationCanceled}
92      */
cleanupScreenshot()93     void cleanupScreenshot();
94 
95     /**
96      * Set a state for controller whether would like to cancel recents animations with deferred
97      * task screenshot presentation.
98      *
99      * When we cancel the recents animation due to a stack order change, we can't just cancel it
100      * immediately as it would lead to a flicker in Launcher if we just remove the task from the
101      * leash. Instead we screenshot the previous task and replace the child of the leash with the
102      * screenshot, so that Launcher can still control the leash lifecycle & make the next app
103      * transition animate smoothly without flickering.
104      *
105      * @param defer When set {@code true}, means that the recents animation will defer canceling the
106      *              animation when a stack order change is triggered until the subsequent app
107      *              transition start and skip previous task's animation.
108      *              When set to {@code false}, means that the recents animation will be canceled
109      *              immediately when the stack order changes.
110      * @param screenshot When set {@code true}, means that the system will take previous task's
111      *                   screenshot and replace the contents of the leash with it when the next app
112      *                   transition starting. The runner must call #cleanupScreenshot() to end the
113      *                   recents animation.
114      *                   When set to {@code false}, means that the system will simply wait for the
115      *                   next app transition start to immediately cancel the recents animation. This
116      *                   can be useful when you want an immediate transition into a state where the
117      *                   task is shown in the home/recents activity (without waiting for a
118      *                   screenshot).
119      *
120      * @see #cleanupScreenshot()
121      * @see IRecentsAnimationRunner#onCancelled
122      */
setDeferCancelUntilNextTransition(boolean defer, boolean screenshot)123     void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot);
124 
125     /**
126      * Sets a state for controller to decide which surface is the destination when the recents
127      * animation is cancelled through fail safe mechanism.
128      */
setWillFinishToHome(boolean willFinishToHome)129     void setWillFinishToHome(boolean willFinishToHome);
130 
131     /**
132      * Stops controlling a task that is currently controlled by this recents animation.
133      *
134      * This method should be called when a task that has been received via {@link #onAnimationStart}
135      * or {@link #onTaskAppeared} is no longer needed.  After calling this method, the task will
136      * either disappear from the screen, or jump to its final position in case it was the top task.
137      *
138      * @param taskId Id of the Task target to remove
139      * @return {@code true} when target removed successfully, {@code false} otherwise.
140      */
removeTask(int taskId)141     boolean removeTask(int taskId);
142 
143     /**
144      * Detach navigation bar from app.
145      *
146      * The system reparents the leash of navigation bar to the app when the recents animation starts
147      * and Launcher should call this method to let system restore the navigation bar to its
148      * original position when the quick switch gesture is finished and will run the fade-in
149      * animation If {@param moveHomeToTop} is {@code true}. Otherwise, restore the navigtation bar
150      * without animation.
151      *
152      * @param moveHomeToTop if {@code true}, the home activity should be moved to the top.
153      *                      Otherwise, the home activity is hidden and the user is returned to the
154      *                      app.
155      */
detachNavigationBarFromApp(boolean moveHomeToTop)156     void detachNavigationBarFromApp(boolean moveHomeToTop);
157 
158     /**
159      * Used for animating the navigation bar during app launch from recents in live tile mode.
160      *
161      * First fade out the navigation bar at the bottom of the display and then fade in to the app.
162      *
163      * @param duration the duration of the app launch animation
164      */
animateNavigationBarToApp(long duration)165     void animateNavigationBarToApp(long duration);
166 }
167