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.graphics.GraphicBuffer; 21 import android.view.IRemoteAnimationFinishedCallback; 22 import android.view.RemoteAnimationTarget; 23 import android.view.SurfaceControl; 24 import android.window.PictureInPictureSurfaceTransaction; 25 import android.window.TaskSnapshot; 26 import android.window.WindowAnimationState; 27 28 import com.android.internal.os.IResultReceiver; 29 30 /** 31 * Passed to the {@link IRecentsAnimationRunner} in order for the runner to control to let the 32 * runner control certain aspects of the recents animation, and to notify window manager when the 33 * animation has completed. 34 * 35 * {@hide} 36 */ 37 interface IRecentsAnimationController { 38 39 /** 40 * Takes a screenshot of the task associated with the given {@param taskId}. Only valid for the 41 * current set of task ids provided to the handler. 42 */ screenshotTask(int taskId)43 TaskSnapshot screenshotTask(int taskId); 44 45 /** 46 * Sets the final surface transaction on a Task. This is used by Launcher to notify the system 47 * that animating Activity to PiP has completed and the associated task surface should be 48 * updated accordingly. This should be called before `finish` 49 * @param taskId for which the leash should be updated 50 * @param finishTransaction leash operations for the final transform. 51 * @param overlay the surface control for an overlay being shown above the pip (can be null) 52 */ setFinishTaskTransaction(int taskId, in PictureInPictureSurfaceTransaction finishTransaction, in SurfaceControl overlay)53 void setFinishTaskTransaction(int taskId, 54 in PictureInPictureSurfaceTransaction finishTransaction, in SurfaceControl overlay); 55 56 /** 57 * Notifies to the system that the animation into Recents should end, and all leashes associated 58 * with remote animation targets should be relinquished. If {@param moveHomeToTop} is true, then 59 * the home activity should be moved to the top. Otherwise, the home activity is hidden and the 60 * user is returned to the app. 61 * @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the 62 * top resumed app, false otherwise. 63 */ 64 @UnsupportedAppUsage finish(boolean moveHomeToTop, boolean sendUserLeaveHint, in IResultReceiver finishCb)65 void finish(boolean moveHomeToTop, boolean sendUserLeaveHint, in IResultReceiver finishCb); 66 67 /** 68 * Called by the handler to indicate that the recents animation input consumer should be 69 * enabled. This is currently used to work around an issue where registering an input consumer 70 * mid-animation causes the existing motion event chain to be canceled. Instead, the caller 71 * may register the recents animation input consumer prior to starting the recents animation 72 * and then enable it mid-animation to start receiving touch events. 73 */ 74 @UnsupportedAppUsage setInputConsumerEnabled(boolean enabled)75 void setInputConsumerEnabled(boolean enabled); 76 77 /** 78 * Informs the system whether the animation targets passed into 79 * IRecentsAnimationRunner.onAnimationStart are currently behind the system bars. If they are, 80 * they can control the SystemUI flags, otherwise the SystemUI flags from home activity will be 81 * taken. 82 */ 83 @UnsupportedAppUsage setAnimationTargetsBehindSystemBars(boolean behindSystemBars)84 void setAnimationTargetsBehindSystemBars(boolean behindSystemBars); 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 /** 125 * Sets a state for controller to decide which surface is the destination when the recents 126 * animation is cancelled through fail safe mechanism. 127 */ setWillFinishToHome(boolean willFinishToHome)128 void setWillFinishToHome(boolean willFinishToHome); 129 130 /** 131 * Stops controlling a task that is currently controlled by this recents animation. 132 * 133 * This method should be called when a task that has been received via {@link #onAnimationStart} 134 * or {@link #onTaskAppeared} is no longer needed. After calling this method, the task will 135 * either disappear from the screen, or jump to its final position in case it was the top task. 136 * 137 * @param taskId Id of the Task target to remove 138 * @return {@code true} when target removed successfully, {@code false} otherwise. 139 */ removeTask(int taskId)140 boolean removeTask(int taskId); 141 142 /** 143 * Detach navigation bar from app. 144 * 145 * The system reparents the leash of navigation bar to the app when the recents animation starts 146 * and Launcher should call this method to let system restore the navigation bar to its 147 * original position when the quick switch gesture is finished and will run the fade-in 148 * animation If {@param moveHomeToTop} is {@code true}. Otherwise, restore the navigtation bar 149 * without animation. 150 * 151 * @param moveHomeToTop if {@code true}, the home activity should be moved to the top. 152 * Otherwise, the home activity is hidden and the user is returned to the 153 * app. 154 */ detachNavigationBarFromApp(boolean moveHomeToTop)155 void detachNavigationBarFromApp(boolean moveHomeToTop); 156 157 /** 158 * Used for animating the navigation bar during app launch from recents in live tile mode. 159 * 160 * First fade out the navigation bar at the bottom of the display and then fade in to the app. 161 * 162 * @param duration the duration of the app launch animation 163 */ animateNavigationBarToApp(long duration)164 void animateNavigationBarToApp(long duration); 165 166 /** 167 * Hand off the ongoing animation of a set of remote targets, to be run by another handler using 168 * the given starting parameters. 169 * 170 * Once the handoff is complete, operations on the old leashes for the given targets as well as 171 * callbacks will become no-ops. 172 * 173 * The number of targets MUST match the number of states, and each state MUST match the target 174 * at the same index. 175 */ handOffAnimation(in RemoteAnimationTarget[] targets, in WindowAnimationState[] states)176 oneway void handOffAnimation(in RemoteAnimationTarget[] targets, 177 in WindowAnimationState[] states); 178 } 179