Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 com.android.server.wm; |
| 18 | |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 19 | import android.util.proto.ProtoOutputStream; |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 20 | import android.view.SurfaceControl; |
| 21 | import android.view.SurfaceControl.Transaction; |
| 22 | import android.view.animation.Animation; |
| 23 | |
| 24 | import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; |
| 25 | |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 26 | import java.io.PrintWriter; |
| 27 | |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 28 | /** |
| 29 | * Interface that describes an animation and bridges the animation start to the component |
| 30 | * responsible for running the animation. |
| 31 | */ |
| 32 | interface AnimationAdapter { |
| 33 | |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 34 | long STATUS_BAR_TRANSITION_DURATION = 120L; |
| 35 | |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 36 | /** |
Jorim Jaggi | 82c1786 | 2018-02-21 17:50:18 +0100 | [diff] [blame] | 37 | * @return Whether we should show the wallpaper during the animation. |
| 38 | * @see Animation#getShowWallpaper() |
| 39 | */ |
| 40 | boolean getShowWallpaper(); |
| 41 | |
| 42 | /** |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 43 | * Requests to start the animation. |
| 44 | * |
| 45 | * @param animationLeash The surface to run the animation on. See {@link SurfaceAnimator} for an |
| 46 | * overview of the mechanism. This surface needs to be released by the |
| 47 | * component running the animation after {@code finishCallback} has been |
| 48 | * invoked, or after the animation was cancelled. |
| 49 | * @param t The Transaction to apply the initial frame of the animation. |
| 50 | * @param finishCallback The callback to be invoked when the animation has finished. |
| 51 | */ |
| 52 | void startAnimation(SurfaceControl animationLeash, Transaction t, |
| 53 | OnAnimationFinishedCallback finishCallback); |
| 54 | |
| 55 | /** |
| 56 | * Called when the animation that was started with {@link #startAnimation} was cancelled by the |
| 57 | * window manager. |
| 58 | * |
| 59 | * @param animationLeash The leash passed to {@link #startAnimation}. |
| 60 | */ |
| 61 | void onAnimationCancelled(SurfaceControl animationLeash); |
| 62 | |
| 63 | /** |
| 64 | * @return The approximate duration of the animation, in milliseconds. |
| 65 | */ |
| 66 | long getDurationHint(); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * If this animation is run as an app opening animation, this calculates the start time for all |
| 70 | * status bar transitions that happen as part of the app opening animation, which will be |
| 71 | * forwarded to SystemUI. |
| 72 | * |
| 73 | * @return the desired start time of the status bar transition, in uptime millis |
| 74 | */ |
| 75 | long getStatusBarTransitionsStartTime(); |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 76 | |
| 77 | void dump(PrintWriter pw, String prefix); |
| 78 | |
| 79 | default void writeToProto(ProtoOutputStream proto, long fieldId) { |
| 80 | final long token = proto.start(fieldId); |
| 81 | writeToProto(proto); |
| 82 | proto.end(token); |
| 83 | } |
| 84 | |
| 85 | void writeToProto(ProtoOutputStream proto); |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 86 | } |