blob: 3c9ce788b7061834fd0974f6b85f39bc8bc4832f [file] [log] [blame]
Jorim Jaggi33a701a2017-12-01 14:58:18 +01001/*
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
17package android.view;
18
Mathew Inwoode5ad5982018-08-17 15:07:52 +010019import android.annotation.UnsupportedAppUsage;
Jorim Jaggi33a701a2017-12-01 14:58:18 +010020import android.app.ActivityOptions;
21import android.os.IBinder;
22import android.os.Parcel;
23import android.os.Parcelable;
24
25/**
26 * Object that describes how to run a remote animation.
27 * <p>
28 * A remote animation lets another app control the entire app transition. It does so by
29 * <ul>
30 * <li>using {@link ActivityOptions#makeRemoteAnimation}</li>
31 * <li>using {@link IWindowManager#overridePendingAppTransitionRemote}</li>
32 * </ul>
33 * to register a {@link RemoteAnimationAdapter} that describes how the animation should be run:
34 * Along some meta-data, this object contains a callback that gets invoked from window manager when
35 * the transition is ready to be started.
36 * <p>
37 * Window manager supplies a list of {@link RemoteAnimationTarget}s into the callback. Each target
38 * contains information about the activity that is animating as well as
39 * {@link RemoteAnimationTarget#leash}. The controlling app can modify the leash like any other
40 * {@link SurfaceControl}, including the possibility to synchronize updating the leash's surface
41 * properties with a frame to be drawn using
42 * {@link SurfaceControl.Transaction#deferTransactionUntil}.
43 * <p>
44 * When the animation is done, the controlling app can invoke
45 * {@link IRemoteAnimationFinishedCallback} that gets supplied into
46 * {@link IRemoteAnimationRunner#onStartAnimation}
47 *
48 * @hide
49 */
50public class RemoteAnimationAdapter implements Parcelable {
51
52 private final IRemoteAnimationRunner mRunner;
53 private final long mDuration;
54 private final long mStatusBarTransitionDelay;
55
Jorim Jaggibc2aabe2018-03-08 17:27:43 +010056 /** @see #getCallingPid */
57 private int mCallingPid;
58
Jorim Jaggi33a701a2017-12-01 14:58:18 +010059 /**
60 * @param runner The interface that gets notified when we actually need to start the animation.
61 * @param duration The duration of the animation.
62 * @param statusBarTransitionDelay The desired delay for all visual animations in the
63 * status bar caused by this app animation in millis.
64 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +010065 @UnsupportedAppUsage
Jorim Jaggi33a701a2017-12-01 14:58:18 +010066 public RemoteAnimationAdapter(IRemoteAnimationRunner runner, long duration,
67 long statusBarTransitionDelay) {
68 mRunner = runner;
69 mDuration = duration;
70 mStatusBarTransitionDelay = statusBarTransitionDelay;
71 }
72
73 public RemoteAnimationAdapter(Parcel in) {
74 mRunner = IRemoteAnimationRunner.Stub.asInterface(in.readStrongBinder());
75 mDuration = in.readLong();
76 mStatusBarTransitionDelay = in.readLong();
77 }
78
79 public IRemoteAnimationRunner getRunner() {
80 return mRunner;
81 }
82
83 public long getDuration() {
84 return mDuration;
85 }
86
87 public long getStatusBarTransitionDelay() {
88 return mStatusBarTransitionDelay;
89 }
90
Jorim Jaggibc2aabe2018-03-08 17:27:43 +010091 /**
92 * To be called by system_server to keep track which pid is running this animation.
93 */
94 public void setCallingPid(int pid) {
95 mCallingPid = pid;
96 }
97
98 /**
99 * @return The pid of the process running the animation.
100 */
101 public int getCallingPid() {
102 return mCallingPid;
103 }
104
Jorim Jaggi33a701a2017-12-01 14:58:18 +0100105 @Override
106 public int describeContents() {
107 return 0;
108 }
109
110 @Override
111 public void writeToParcel(Parcel dest, int flags) {
112 dest.writeStrongInterface(mRunner);
113 dest.writeLong(mDuration);
114 dest.writeLong(mStatusBarTransitionDelay);
115 }
116
117 public static final Creator<RemoteAnimationAdapter> CREATOR
118 = new Creator<RemoteAnimationAdapter>() {
119 public RemoteAnimationAdapter createFromParcel(Parcel in) {
120 return new RemoteAnimationAdapter(in);
121 }
122
123 public RemoteAnimationAdapter[] newArray(int size) {
124 return new RemoteAnimationAdapter[size];
125 }
126 };
127}