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