blob: cf40e7e4d308c38e960df2485276926cb09e533a [file] [log] [blame]
Aurimas Liutikas88c7ff12023-08-10 12:42:26 -07001/*
2 * Copyright (C) 2020 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
19import android.annotation.Nullable;
20import android.util.SparseArray;
21import android.util.proto.ProtoOutputStream;
22import android.view.InsetsController.AnimationType;
23import android.view.WindowInsets.Type.InsetsType;
24import android.view.inputmethod.ImeTracker;
25
26/**
27 * Interface representing a runner for an insets animation.
28 *
29 * @hide
30 */
31public interface InsetsAnimationControlRunner {
32
33 /**
34 * @return The {@link InsetsType} the animation of this runner controls.
35 */
36 @InsetsType int getTypes();
37
38 /**
39 * @return The {@link InsetsType} the animation of this runner is controlling. This can be
40 * changed if a control is revoked.
41 */
42 @InsetsType int getControllingTypes();
43
44 /**
45 * Notifies {@link InsetsType types} of control are getting revoked.
46 */
47 void notifyControlRevoked(@InsetsType int types);
48
49 /**
50 * Updates the surface positions of the controls owned by this runner if there is any.
51 *
52 * @param controls An array of {@link InsetsSourceControl} that the caller newly receives.
53 */
54 void updateSurfacePosition(SparseArray<InsetsSourceControl> controls);
55
56 /**
57 * Cancels the animation.
58 */
59 void cancel();
60
61 /**
62 * @return The animation this runner is running.
63 */
64 WindowInsetsAnimation getAnimation();
65
66 /**
67 * @return Whether {@link #getTypes()} contains a specific {@link InsetsType}.
68 */
69 default boolean controlsType(@InsetsType int type) {
70 return (getTypes() & type) != 0;
71 }
72
73 /**
74 * @return The animation type this runner is running.
75 */
76 @AnimationType int getAnimationType();
77
78 /**
79 * @return The token tracking the current IME request or {@code null} otherwise.
80 */
81 @Nullable
82 ImeTracker.Token getStatsToken();
83
84 /**
85 *
86 * Export the state of classes that implement this interface into a protocol buffer
87 * output stream.
88 *
89 * @param proto Stream to write the state to
90 * @param fieldId FieldId of the implementation class
91 */
92 void dumpDebug(ProtoOutputStream proto, long fieldId);
93}